Interface Element
- All Superinterfaces:
InteractionSource
- All Known Subinterfaces:
ElementArrow
,ElementBox
,ElementCircle
,ElementCone
,ElementCylinder
,ElementEllipsoid
,ElementImage
,ElementObject
,ElementPlane
,ElementPoints
,ElementPolygon
,ElementSegment
,ElementSphere
,ElementSpring
,ElementSurface
,ElementTessellation
,ElementTetrahedron
,ElementText
,ElementTrail
,Group
,Set
- All Known Implementing Classes:
AbstractTile
,Element
,ElementArrow
,ElementBox
,ElementCircle
,ElementCone
,ElementCylinder
,ElementEllipsoid
,ElementImage
,ElementObject
,ElementPlane
,ElementPoints
,ElementPolygon
,ElementSegment
,ElementSphere
,ElementSpring
,ElementSurface
,ElementTessellation
,ElementTetrahedron
,ElementText
,ElementTrail
,Group
,Set
Title: Element
Description: A basic individual, interactive 3D element.
- Version:
- March 2005
- Author:
- Francisco Esquembre
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
A class to save and load Element data. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The id for the target that allows to reposition the element.static final int
The id for the target that allows to resize the element. -
Method Summary
Modifier and TypeMethodDescriptionReturns the DrawingPanel3D in which it (or its final ancestor group) is displayed.getName()
Gets the name of the elementdouble
getSizeX()
Get the size along the X axisdouble
getSizeY()
Get the size along the Y axisdouble
getSizeZ()
Get the size along the Z axisgetStyle()
Gets the style of the elementReturns a clone of the element transformationdouble
getX()
Get the X coordinate of the elementdouble
getY()
Get the Y coordinate of the elementdouble
getZ()
Get the Z coordinate of the elementboolean
Whether the element is visiblevoid
loadUnmutableObjects
(XMLControl control) Loads unmutable objects of the Element, such as the style, as well as perform any extra implementation-specific initialization.void
Gives a name to the element.void
setSizeX
(double sizeX) Set the size along the X axisvoid
setSizeXYZ
(double[] size) Sets the size of the element.void
setSizeXYZ
(double sizeX, double sizeY, double sizeZ) Set the size along the X, Y and Z axesvoid
setSizeY
(double sizeY) Set the size along the Y axisvoid
setSizeZ
(double sizeZ) Set the size along the Z axisvoid
setTransformation
(Transformation transformation) Sets the internal transformation of the element, that is, the transformation that converts the standard XYZ axes to the body's internal reference axes.void
setVisible
(boolean _visible) Sets the visibility of the elementvoid
setX
(double x) Set the X coordinate of the elementvoid
setXYZ
(double[] pos) Sets the coordinates of the element.void
setXYZ
(double x, double y, double z) Set the X, Y, and Z coordinates of the elementvoid
setY
(double y) Set the Y coordinate of the elementvoid
setZ
(double z) Set the Z coordinate of the elementdouble[]
toBodyFrame
(double[] vector) This method converts a double[3] vector from the space's frame to the body's frame.double[]
toSpaceFrame
(double[] vector) This method transforms a double[3] vector from the body's frame to the space's frame.Methods inherited from interface org.opensourcephysics.display3d.core.interaction.InteractionSource
addInteractionListener, getInteractionTarget, removeInteractionListener
-
Field Details
-
TARGET_POSITION
static final int TARGET_POSITIONThe id for the target that allows to reposition the element.- See Also:
-
TARGET_SIZE
static final int TARGET_SIZEThe id for the target that allows to resize the element.- See Also:
-
-
Method Details
-
getDrawingPanel3D
DrawingPanel3D getDrawingPanel3D()Returns the DrawingPanel3D in which it (or its final ancestor group) is displayed.- Returns:
- DrawingPanel3D
-
setName
Gives a name to the element. Naming an element is optional, but the element may use its name to identify itself in XML files, for instance.- Parameters:
name
- String
-
getName
String getName()Gets the name of the element- Returns:
- String the name
-
setX
void setX(double x) Set the X coordinate of the element- Parameters:
x
- double
-
getX
double getX()Get the X coordinate of the element- Returns:
- double
-
setY
void setY(double y) Set the Y coordinate of the element- Parameters:
y
- double
-
getY
double getY()Get the Y coordinate of the element- Returns:
- double
-
setZ
void setZ(double z) Set the Z coordinate of the element- Parameters:
z
- double
-
getZ
double getZ()Get the Z coordinate of the element- Returns:
- double
-
setXYZ
void setXYZ(double x, double y, double z) Set the X, Y, and Z coordinates of the element- Parameters:
x
- doubley
- doublez
- double
-
setXYZ
void setXYZ(double[] pos) Sets the coordinates of the element. If pos.length<=2 it sets only X and Y. If pos.length>2 it sets X, Y, and Z.- Parameters:
pos
- double[]
-
setSizeX
void setSizeX(double sizeX) Set the size along the X axis- Parameters:
sizeX
- double
-
getSizeX
double getSizeX()Get the size along the X axis- Returns:
- double
-
setSizeY
void setSizeY(double sizeY) Set the size along the Y axis- Parameters:
sizeY
- double
-
getSizeY
double getSizeY()Get the size along the Y axis- Returns:
- double
-
setSizeZ
void setSizeZ(double sizeZ) Set the size along the Z axis- Parameters:
sizeZ
- double
-
getSizeZ
double getSizeZ()Get the size along the Z axis- Returns:
- double
-
setSizeXYZ
void setSizeXYZ(double sizeX, double sizeY, double sizeZ) Set the size along the X, Y and Z axes- Parameters:
sizeX
- doublesizeY
- doublesizeZ
- double
-
setSizeXYZ
void setSizeXYZ(double[] size) Sets the size of the element. If size.length<=2 it sets only the size in X and Y. If size.length>3 it sets the size in X, Y, and Z.- Parameters:
size
- double[]
-
setVisible
void setVisible(boolean _visible) Sets the visibility of the element- Parameters:
_visible
- boolean
-
isVisible
boolean isVisible()Whether the element is visible- Returns:
- boolean
-
getStyle
Style getStyle()Gets the style of the element- Returns:
- Style
- See Also:
-
setTransformation
Sets the internal transformation of the element, that is, the transformation that converts the standard XYZ axes to the body's internal reference axes. The transformation is copied and cannot be accessed by users directy. This implies that changing the original transformation has no effect on the element unless a new setTransformation() is invoked. The transformation uses the body's position as its origin.- Parameters:
transformation
- the new transformation- See Also:
-
getTransformation
Transformation getTransformation()Returns a clone of the element transformation- Returns:
- Transformation a clone of the element's transformation
-
toSpaceFrame
double[] toSpaceFrame(double[] vector) This method transforms a double[3] vector from the body's frame to the space's frame.- Parameters:
vector
- double[] The original coordinates in the body frame- Returns:
- double[] The same array once transformed
-
toBodyFrame
This method converts a double[3] vector from the space's frame to the body's frame. This only works properly if the internal transformation is not set (i.e. it is the identity) or if it is invertible. Otherwise, a call to this method will throw an UnsupportedOperationException exception.- Parameters:
vector
- double[] The original coordinates in the space- Returns:
- double[] The same array with the body coordinates
- Throws:
UnsupportedOperationException
-
loadUnmutableObjects
Loads unmutable objects of the Element, such as the style, as well as perform any extra implementation-specific initialization. For the internal use of the XML loeader. Not to be used by final users.- Parameters:
control
- XMLControl
-