org.opensourcephysics.display3d.simple3d
Class Element

java.lang.Object
  extended by org.opensourcephysics.display3d.simple3d.Element
All Implemented Interfaces:
Element, InteractionSource
Direct Known Subclasses:
AbstractTile, ElementCircle, ElementImage, ElementPoints, ElementPolygon, ElementSegment, ElementSpring, ElementText, ElementTrail, Group

public abstract class Element
extends java.lang.Object
implements Element

Title: Element

Interaction: An Element includes the following targets:

The actual position (and implementation) of the target depends on the element.

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
 
Fields inherited from interface org.opensourcephysics.display3d.core.Element
TARGET_POSITION, TARGET_SIZE
 
Constructor Summary
Element()
           
 
Method Summary
 void addInteractionListener(InteractionListener listener)
          Adds the specified interaction listener to receive interaction events to any of its targets from this source.
 DrawingPanel3D getDrawingPanel3D()
          Returns the DrawingPanel3D in which it (or its final ancestor group) is displayed.
 InteractionTarget getInteractionTarget(int target)
          Gives access to one of the targets of this source.
 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 removeInteractionListener(InteractionListener listener)
          Removes the specified interaction listener
 void setName(java.lang.String aName)
          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 class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Element

public Element()
Method Detail

getDrawingPanel3D

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

Specified by:
getDrawingPanel3D in interface Element
Returns:
DrawingPanel3D

setName

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

Specified by:
setName in interface Element
Parameters:
aName - String

getName

public final java.lang.String getName()
Description copied from interface: Element
Gets the name of the element

Specified by:
getName in interface Element
Returns:
String the name

setX

public void setX(double x)
Description copied from interface: Element
Set the X coordinate of the element

Specified by:
setX in interface Element
Parameters:
x - double

getX

public final double getX()
Description copied from interface: Element
Get the X coordinate of the element

Specified by:
getX in interface Element
Returns:
double

setY

public void setY(double y)
Description copied from interface: Element
Set the Y coordinate of the element

Specified by:
setY in interface Element
Parameters:
y - double

getY

public final double getY()
Description copied from interface: Element
Get the Y coordinate of the element

Specified by:
getY in interface Element
Returns:
double

setZ

public void setZ(double z)
Description copied from interface: Element
Set the Z coordinate of the element

Specified by:
setZ in interface Element
Parameters:
z - double

getZ

public final double getZ()
Description copied from interface: Element
Get the Z coordinate of the element

Specified by:
getZ in interface Element
Returns:
double

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

Specified by:
setXYZ in interface Element
Parameters:
x - double
y - double
z - double

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.

Specified by:
setXYZ in interface Element
Parameters:
pos - double[]

setSizeX

public void setSizeX(double sizeX)
Description copied from interface: Element
Set the size along the X axis

Specified by:
setSizeX in interface Element
Parameters:
sizeX - double

getSizeX

public final double getSizeX()
Description copied from interface: Element
Get the size along the X axis

Specified by:
getSizeX in interface Element
Returns:
double

setSizeY

public void setSizeY(double sizeY)
Description copied from interface: Element
Set the size along the Y axis

Specified by:
setSizeY in interface Element
Parameters:
sizeY - double

getSizeY

public final double getSizeY()
Description copied from interface: Element
Get the size along the Y axis

Specified by:
getSizeY in interface Element
Returns:
double

setSizeZ

public void setSizeZ(double sizeZ)
Description copied from interface: Element
Set the size along the Z axis

Specified by:
setSizeZ in interface Element
Parameters:
sizeZ - double

getSizeZ

public final double getSizeZ()
Description copied from interface: Element
Get the size along the Z axis

Specified by:
getSizeZ in interface Element
Returns:
double

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 interface Element
Parameters:
sizeX - double
sizeY - double
sizeZ - 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 interface Element
Parameters:
size - double[]

setVisible

public void setVisible(boolean _visible)
Description copied from interface: Element
Sets the visibility of the element

Specified by:
setVisible in interface Element
Parameters:
_visible - boolean

isVisible

public final boolean isVisible()
Description copied from interface: Element
Whether the element is visible

Specified by:
isVisible in interface Element
Returns:
boolean

getStyle

public final Style getStyle()
Description copied from interface: Element
Gets the style of the element

Specified by:
getStyle in interface Element
Returns:
Style
See Also:
Style

getTransformation

public Transformation getTransformation()
Description copied from interface: Element
Returns a clone of the element transformation

Specified by:
getTransformation in interface Element
Returns:
Transformation a clone of the element's transformation

setTransformation

public void setTransformation(Transformation transformation)
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 interface Element
Parameters:
transformation - the new transformation
See Also:
Transformation

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 interface Element
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
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 interface Element
Parameters:
vector - double[] The original coordinates in the space
Returns:
double[] The same array with the body coordinates
Throws:
java.lang.UnsupportedOperationException

getInteractionTarget

public InteractionTarget getInteractionTarget(int target)
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 interface InteractionSource
Parameters:
target - An integer number that identifies the target in the source.
Returns:
InteractionTarget

addInteractionListener

public void addInteractionListener(InteractionListener listener)
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 interface InteractionSource
Parameters:
listener - An object that implements the InteractionListener interface
See Also:
InteractionListener

removeInteractionListener

public void removeInteractionListener(InteractionListener listener)
Description copied from interface: InteractionSource
Removes the specified interaction listener

Specified by:
removeInteractionListener in interface InteractionSource
See Also:
InteractionListener

loadUnmutableObjects

public void loadUnmutableObjects(XMLControl control)
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 interface Element
Parameters:
control - XMLControl