org.opensourcephysics.display3d.simple3d
Class Element

java.lang.Object
  extended byorg.opensourcephysics.display3d.simple3d.Element
All Implemented Interfaces:
Element, org.opensourcephysics.display3d.core.interaction.InteractionSource
Direct Known Subclasses:
AbstractTile, ElementCircle, ElementImage, 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


Nested Class Summary
 
Nested classes inherited from class org.opensourcephysics.display3d.core.Element
Element.Loader
 
Field Summary
protected  InteractionTarget targetPosition
           
protected  InteractionTarget targetSize
           
 
Fields inherited from interface org.opensourcephysics.display3d.core.Element
TARGET_POSITION, TARGET_SIZE
 
Constructor Summary
Element()
           
 
Method Summary
 void addInteractionListener(org.opensourcephysics.display3d.core.interaction.InteractionListener listener)
           
protected  double[] getHotSpotBodyCoordinates(InteractionTarget target)
          Returns the body coordinates of the specified hotspot
 org.opensourcephysics.display3d.core.interaction.InteractionTarget getInteractionTarget(int target)
           
 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
protected  InteractionTarget getTargetHit(int x, int y)
          Gets the target that is under the (x,y) position of the screen
 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
protected  boolean isReallyVisible()
          Returns the real visibility status of the element, which will be false if it belongs to an invisible group
 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(org.opensourcephysics.display3d.core.interaction.InteractionListener 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

targetPosition

protected final InteractionTarget targetPosition

targetSize

protected final InteractionTarget targetSize
Constructor Detail

Element

public Element()
Method Detail

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

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

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 org.opensourcephysics.display3d.core.interaction.InteractionTarget getInteractionTarget(int target)
Specified by:
getInteractionTarget in interface org.opensourcephysics.display3d.core.interaction.InteractionSource

addInteractionListener

public void addInteractionListener(org.opensourcephysics.display3d.core.interaction.InteractionListener listener)
Specified by:
addInteractionListener in interface org.opensourcephysics.display3d.core.interaction.InteractionSource

removeInteractionListener

public void removeInteractionListener(org.opensourcephysics.display3d.core.interaction.InteractionListener listener)
Specified by:
removeInteractionListener in interface org.opensourcephysics.display3d.core.interaction.InteractionSource

getTargetHit

protected InteractionTarget getTargetHit(int x,
                                         int y)
Gets the target that is under the (x,y) position of the screen

Parameters:
x - int
y - int
Returns:
InteractionTarget

getHotSpotBodyCoordinates

protected double[] getHotSpotBodyCoordinates(InteractionTarget target)
Returns the body coordinates of the specified hotspot

Returns:
double[]

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