org.opensourcephysics.display3d.core
Interface Element

All Superinterfaces:
org.opensourcephysics.display3d.core.interaction.InteractionSource
All Known Subinterfaces:
ElementArrow, ElementBox, ElementCircle, ElementCone, ElementCylinder, ElementEllipsoid, ElementImage, ElementPlane, ElementPolygon, ElementSegment, ElementSphere, ElementSpring, ElementSurface, ElementText, ElementTrail, Group
All Known Implementing Classes:
Element, ElementArrow, ElementBox, ElementCircle, ElementCone, ElementCylinder, ElementEllipsoid, ElementImage, ElementPlane, ElementPolygon, ElementSegment, ElementSphere, ElementSpring, ElementSurface, ElementText, ElementTrail, Group

public interface Element
extends org.opensourcephysics.display3d.core.interaction.InteractionSource

Title: Element

Description: A basic individual, interactive 3D element.


Nested Class Summary
static class Element.Loader
          A class to save and load Element data.
 
Field Summary
static int TARGET_POSITION
          The id for the target that allows to reposition the element.
static int TARGET_SIZE
          The id for the target that allows to resize the element.
 
Method Summary
 java.lang.String getName()
          Gets the name of the element
 double getSizeX()
          Get the size along the X axis
 double getSizeY()
          Get the size along the Y axis
 double getSizeZ()
          Get the size along the Z axis
 Style getStyle()
          Gets the style of the element
 Transformation getTransformation()
          Returns a clone of the element transformation
 double getX()
          Get the X coordinate of the element
 double getY()
          Get the Y coordinate of the element
 double getZ()
          Get the Z coordinate of the element
 boolean isVisible()
          Whether the element is visible
 void loadUnmutableObjects(XMLControl control)
          Loads unmutable objects of the Element, such as the style, as well as perform any extra implementation-specific initialization.
 void setName(java.lang.String name)
          Gives a name to the element.
 void setSizeX(double sizeX)
          Set the size along the X axis
 void 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 axes
 void setSizeY(double sizeY)
          Set the size along the Y axis
 void setSizeZ(double sizeZ)
          Set the size along the Z axis
 void 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 element
 void setX(double x)
          Set the X coordinate of the element
 void 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 element
 void setY(double y)
          Set the Y coordinate of the element
 void setZ(double z)
          Set the Z coordinate of the element
 double[] 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 Detail

TARGET_POSITION

public static final int TARGET_POSITION
The id for the target that allows to reposition the element.

See Also:
Constant Field Values

TARGET_SIZE

public static final int TARGET_SIZE
The id for the target that allows to resize the element.

See Also:
Constant Field Values
Method Detail

setName

public void setName(java.lang.String name)
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

public java.lang.String getName()
Gets the name of the element

Returns:
String the name

setX

public void setX(double x)
Set the X coordinate of the element

Parameters:
x - double

getX

public double getX()
Get the X coordinate of the element

Returns:
double

setY

public void setY(double y)
Set the Y coordinate of the element

Parameters:
y - double

getY

public double getY()
Get the Y coordinate of the element

Returns:
double

setZ

public void setZ(double z)
Set the Z coordinate of the element

Parameters:
z - double

getZ

public double getZ()
Get the Z coordinate of the element

Returns:
double

setXYZ

public void setXYZ(double x,
                   double y,
                   double z)
Set the X, Y, and Z coordinates of the element

Parameters:
x - double
y - double
z - double

setXYZ

public 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

public void setSizeX(double sizeX)
Set the size along the X axis

Parameters:
sizeX - double

getSizeX

public double getSizeX()
Get the size along the X axis

Returns:
double

setSizeY

public void setSizeY(double sizeY)
Set the size along the Y axis

Parameters:
sizeY - double

getSizeY

public double getSizeY()
Get the size along the Y axis

Returns:
double

setSizeZ

public void setSizeZ(double sizeZ)
Set the size along the Z axis

Parameters:
sizeZ - double

getSizeZ

public double getSizeZ()
Get the size along the Z axis

Returns:
double

setSizeXYZ

public void setSizeXYZ(double sizeX,
                       double sizeY,
                       double sizeZ)
Set the size along the X, Y and Z axes

Parameters:
sizeX - double
sizeY - double
sizeZ - double

setSizeXYZ

public 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

public void setVisible(boolean _visible)
Sets the visibility of the element

Parameters:
_visible - boolean

isVisible

public boolean isVisible()
Whether the element is visible

Returns:
boolean

getStyle

public Style getStyle()
Gets the style of the element

Returns:
Style
See Also:
Style

setTransformation

public void 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. 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:
Transformation

getTransformation

public Transformation getTransformation()
Returns a clone of the element transformation

Returns:
Transformation a clone of the element's transformation

toSpaceFrame

public 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

public double[] toBodyFrame(double[] vector)
                     throws java.lang.UnsupportedOperationException
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:
java.lang.UnsupportedOperationException

loadUnmutableObjects

public void loadUnmutableObjects(XMLControl control)
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