org.opensourcephysics.display3d.core
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

public interface Element
extends InteractionSource

Title: Element

Description: A basic individual, interactive 3D element.

Version:
March 2005
Author:
Francisco Esquembre

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
 DrawingPanel3D getDrawingPanel3D()
          Returns the DrawingPanel3D in which it (or its final ancestor group) is displayed.
 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

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

See Also:
Constant Field Values

TARGET_SIZE

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

See Also:
Constant Field Values
Method Detail

getDrawingPanel3D

DrawingPanel3D getDrawingPanel3D()
Returns the DrawingPanel3D in which it (or its final ancestor group) is displayed.

Returns:
DrawingPanel3D

setName

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

java.lang.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 - double
y - double
z - 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 - double
sizeY - double
sizeZ - 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:
Style

setTransformation

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

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

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

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