Class Element
java.lang.Object
org.opensourcephysics.display3d.simple3d.Element
- All Implemented Interfaces:
Element
,InteractionSource
- Direct Known Subclasses:
AbstractTile
,ElementCircle
,ElementImage
,ElementPoints
,ElementPolygon
,ElementSegment
,ElementSpring
,ElementText
,ElementTrail
,Group
Title: Element
Interaction: An Element includes the following targets:
- TARGET_POSITION : Allows the element to be repositioned
- TARGET_SIZE : Allows the element to be resized
Copyright: Open Source Physics project
- Version:
- June 2005
- Author:
- Francisco Esquembre
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opensourcephysics.display3d.core.Element
Element.Loader
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final InteractionTarget
protected final InteractionTarget
Fields inherited from interface org.opensourcephysics.display3d.core.Element
TARGET_POSITION, TARGET_SIZE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInteractionListener
(InteractionListener listener) Adds the specified interaction listener to receive interaction events to any of its targets from this source.protected int
final DrawingPanel3D
Returns the DrawingPanel3D in which it (or its final ancestor group) is displayed.protected double[]
Returns the body coordinates of the specified hotspotgetInteractionTarget
(int target) Gives access to one of the targets of this source.final String
getName()
Gets the name of the elementfinal double
getSizeX()
Get the size along the X axisfinal double
getSizeY()
Get the size along the Y axisfinal double
getSizeZ()
Get the size along the Z axisfinal Style
getStyle()
Gets the style of the elementprotected InteractionTarget
getTargetHit
(int x, int y) Gets the target that is under the (x,y) position of the screenReturns a clone of the element transformationfinal double
getX()
Get the X coordinate of the elementfinal double
getY()
Get the Y coordinate of the elementfinal double
getZ()
Get the Z coordinate of the elementprotected final boolean
Returns the real visibility status of the element, which will be false if it belongs to an invisible groupfinal boolean
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
removeInteractionListener
(InteractionListener listener) Removes the specified interaction listenervoid
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.
-
Field Details
-
targetPosition
-
targetSize
-
-
Constructor Details
-
Element
public Element()
-
-
Method Details
-
getDrawingPanel3D
Returns the DrawingPanel3D in which it (or its final ancestor group) is displayed.- Specified by:
getDrawingPanel3D
in interfaceElement
- Returns:
- DrawingPanel3D
-
getAxesMode
protected int getAxesMode() -
setName
Description copied from interface:Element
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. -
getName
Description copied from interface:Element
Gets the name of the element -
setX
public void setX(double x) Description copied from interface:Element
Set the X coordinate of the element -
getX
public final double getX()Description copied from interface:Element
Get the X coordinate of the element -
setY
public void setY(double y) Description copied from interface:Element
Set the Y coordinate of the element -
getY
public final double getY()Description copied from interface:Element
Get the Y coordinate of the element -
setZ
public void setZ(double z) Description copied from interface:Element
Set the Z coordinate of the element -
getZ
public final double getZ()Description copied from interface:Element
Get the Z coordinate of the element -
setXYZ
public void setXYZ(double x, double y, double z) Description copied from interface:Element
Set the X, Y, and Z coordinates of the element -
setXYZ
public void setXYZ(double[] pos) Description copied from interface:Element
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. -
setSizeX
public void setSizeX(double sizeX) Description copied from interface:Element
Set the size along the X axis -
getSizeX
public final double getSizeX()Description copied from interface:Element
Get the size along the X axis -
setSizeY
public void setSizeY(double sizeY) Description copied from interface:Element
Set the size along the Y axis -
getSizeY
public final double getSizeY()Description copied from interface:Element
Get the size along the Y axis -
setSizeZ
public void setSizeZ(double sizeZ) Description copied from interface:Element
Set the size along the Z axis -
getSizeZ
public final double getSizeZ()Description copied from interface:Element
Get the size along the Z axis -
setSizeXYZ
public void setSizeXYZ(double sizeX, double sizeY, double sizeZ) Description copied from interface:Element
Set the size along the X, Y and Z axes- Specified by:
setSizeXYZ
in interfaceElement
- Parameters:
sizeX
- doublesizeY
- doublesizeZ
- double
-
setSizeXYZ
public void setSizeXYZ(double[] size) Description copied from interface:Element
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.- Specified by:
setSizeXYZ
in interfaceElement
- Parameters:
size
- double[]
-
setVisible
public void setVisible(boolean _visible) Description copied from interface:Element
Sets the visibility of the element- Specified by:
setVisible
in interfaceElement
- Parameters:
_visible
- boolean
-
isVisible
public final boolean isVisible()Description copied from interface:Element
Whether the element is visible -
isReallyVisible
protected final boolean isReallyVisible()Returns the real visibility status of the element, which will be false if it belongs to an invisible group- Returns:
- boolean
-
getStyle
Description copied from interface:Element
Gets the style of the element -
getTransformation
Description copied from interface:Element
Returns a clone of the element transformation- Specified by:
getTransformation
in interfaceElement
- Returns:
- Transformation a clone of the element's transformation
-
setTransformation
Description copied from interface:Element
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.- Specified by:
setTransformation
in interfaceElement
- Parameters:
transformation
- the new transformation- See Also:
-
toSpaceFrame
public double[] toSpaceFrame(double[] vector) Description copied from interface:Element
This method transforms a double[3] vector from the body's frame to the space's frame.- Specified by:
toSpaceFrame
in interfaceElement
- Parameters:
vector
- double[] The original coordinates in the body frame- Returns:
- double[] The same array once transformed
-
toBodyFrame
Description copied from interface:Element
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.- Specified by:
toBodyFrame
in interfaceElement
- Parameters:
vector
- double[] The original coordinates in the space- Returns:
- double[] The same array with the body coordinates
- Throws:
UnsupportedOperationException
-
getInteractionTarget
Description copied from interface:InteractionSource
Gives access to one of the targets of this source. Sources should document the list of their available targets.- Specified by:
getInteractionTarget
in interfaceInteractionSource
- Parameters:
target
- An integer number that identifies the target in the source.- Returns:
- InteractionTarget
-
addInteractionListener
Description copied from interface:InteractionSource
Adds the specified interaction listener to receive interaction events to any of its targets from this source.- Specified by:
addInteractionListener
in interfaceInteractionSource
- Parameters:
listener
- An object that implements the InteractionListener interface- See Also:
-
removeInteractionListener
Description copied from interface:InteractionSource
Removes the specified interaction listener- Specified by:
removeInteractionListener
in interfaceInteractionSource
- See Also:
-
getTargetHit
Gets the target that is under the (x,y) position of the screen- Parameters:
x
- inty
- int- Returns:
- InteractionTarget
-
getHotSpotBodyCoordinates
Returns the body coordinates of the specified hotspot- Returns:
- double[]
-
loadUnmutableObjects
Description copied from interface:Element
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.- Specified by:
loadUnmutableObjects
in interfaceElement
- Parameters:
control
- XMLControl
-