org.opensourcephysics.display3d.simple3d
Class ElementTrail

java.lang.Object
  extended byorg.opensourcephysics.display3d.simple3d.Element
      extended byorg.opensourcephysics.display3d.simple3d.ElementTrail
All Implemented Interfaces:
Element, ElementTrail, org.opensourcephysics.display3d.core.interaction.InteractionSource

public class ElementTrail
extends Element
implements ElementTrail

Title: ElementSegment

Description: A Segment using the painter's algorithm


Field Summary
protected  java.util.ArrayList list
           
 
Fields inherited from class org.opensourcephysics.display3d.simple3d.Element
targetPosition, targetSize
 
Fields inherited from interface org.opensourcephysics.display3d.core.Element
TARGET_POSITION, TARGET_SIZE
 
Constructor Summary
ElementTrail()
           
 
Method Summary
 void addPoint(double[] point)
          Adds a new double[] point to the trail.
 void addPoint(double x, double y, double z)
          Adds a new (x,y,z) point to the trail.
 void clear()
          Clears all points from the trail.
 void getExtrema(double[] min, double[] max)
           
static XML.ObjectLoader getLoader()
          Returns an XML.ObjectLoader to save and load object data.
 int getMaximumPoints()
          Returns the maximum number of points allowed for the trail
 boolean isConnected()
          Gets the connected flag.
 void moveToPoint(double x, double y, double z)
          Starts a new (x,y,z) trail segment by moving to a new point without drawing.
 void setConnected(boolean connected)
          Sets the connected flag.
 void setMaximumPoints(int maximum)
          Sets the maximum number of points for the trail.
 
Methods inherited from class org.opensourcephysics.display3d.simple3d.Element
addInteractionListener, getHotSpotBodyCoordinates, getInteractionTarget, getName, getSizeX, getSizeY, getSizeZ, getStyle, getTargetHit, getTransformation, getX, getY, getZ, isReallyVisible, isVisible, loadUnmutableObjects, removeInteractionListener, setName, setSizeX, setSizeXYZ, setSizeXYZ, setSizeY, setSizeZ, setTransformation, setVisible, setX, setXYZ, setXYZ, setY, setZ, toBodyFrame, toSpaceFrame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opensourcephysics.display3d.core.Element
getName, getSizeX, getSizeY, getSizeZ, getStyle, getTransformation, getX, getY, getZ, isVisible, loadUnmutableObjects, setName, setSizeX, setSizeXYZ, setSizeXYZ, setSizeY, setSizeZ, setTransformation, setVisible, setX, setXYZ, setXYZ, setY, setZ, toBodyFrame, toSpaceFrame
 
Methods inherited from interface org.opensourcephysics.display3d.core.interaction.InteractionSource
addInteractionListener, getInteractionTarget, removeInteractionListener
 

Field Detail

list

protected java.util.ArrayList list
Constructor Detail

ElementTrail

public ElementTrail()
Method Detail

addPoint

public void addPoint(double x,
                     double y,
                     double z)
Description copied from interface: ElementTrail
Adds a new (x,y,z) point to the trail.

Specified by:
addPoint in interface ElementTrail
Parameters:
x - double
y - double
z - double

addPoint

public void addPoint(double[] point)
Description copied from interface: ElementTrail
Adds a new double[] point to the trail.

Specified by:
addPoint in interface ElementTrail
Parameters:
point - double[] The array with the coordinates of the point. If the length of the array is 2, the coordinates are asumed to be X and Y (Z=0). If it is 3, then X, Y, and Z (as usual).

moveToPoint

public void moveToPoint(double x,
                        double y,
                        double z)
Description copied from interface: ElementTrail
Starts a new (x,y,z) trail segment by moving to a new point without drawing. (Equivalent to setting the connected flag to false and adding one singlepoint, then setting the flag back to true.)

Specified by:
moveToPoint in interface ElementTrail
Parameters:
x - double
y - double
z - double

setMaximumPoints

public void setMaximumPoints(int maximum)
Description copied from interface: ElementTrail
Sets the maximum number of points for the trail. Once the maximum is reached, adding a new point will cause remotion of the first one. This is useful to keep trails down to a reasonable size, since very long trails can slow down the rendering (in certain implementations). If the value is 0 (the default) the trail grows forever without discarding old points.

Specified by:
setMaximumPoints in interface ElementTrail
Parameters:
maximum - int

getMaximumPoints

public int getMaximumPoints()
Description copied from interface: ElementTrail
Returns the maximum number of points allowed for the trail

Specified by:
getMaximumPoints in interface ElementTrail
Returns:
int

setConnected

public void setConnected(boolean connected)
Description copied from interface: ElementTrail
Sets the connected flag. Successive points are connected by a segment if this flag is true. Each point is marked as a colored pixel if the trail is not connected. Setting it temporarily to false helps create discontinuous trails.

Specified by:
setConnected in interface ElementTrail
Parameters:
connected - boolean

isConnected

public boolean isConnected()
Description copied from interface: ElementTrail
Gets the connected flag.

Specified by:
isConnected in interface ElementTrail
See Also:
ElementTrail.setConnected(boolean)

clear

public void clear()
Description copied from interface: ElementTrail
Clears all points from the trail.

Specified by:
clear in interface ElementTrail

getExtrema

public void getExtrema(double[] min,
                       double[] max)
Parameters:
min - double[] A previously allocated double[3] array that will hold the minimum point
max - double[] A previously allocated double[3] array that will hold the maximum point

getLoader

public static XML.ObjectLoader getLoader()
Returns an XML.ObjectLoader to save and load object data.

Returns:
the XML.ObjectLoader