org.opensourcephysics.display3d.core
Interface ElementTrail

All Superinterfaces:
Element, org.opensourcephysics.display3d.core.interaction.InteractionSource
All Known Implementing Classes:
ElementTrail

public interface ElementTrail
extends Element

Title: ElementTrail

Description:

A trail of 3D pixels on the screen.

This object is often used to show the path of a moving object.


Nested Class Summary
static class ElementTrail.Loader
           
 
Field Summary
 
Fields inherited from interface org.opensourcephysics.display3d.core.Element
TARGET_POSITION, TARGET_SIZE
 
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.
 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 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
 

Method Detail

addPoint

public void addPoint(double x,
                     double y,
                     double z)
Adds a new (x,y,z) point to the trail.

Parameters:
x - double
y - double
z - double

addPoint

public void addPoint(double[] point)
Adds a new double[] point to the trail.

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).

setMaximumPoints

public void setMaximumPoints(int maximum)
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.

Parameters:
maximum - int

getMaximumPoints

public int getMaximumPoints()
Returns the maximum number of points allowed for the trail

Returns:
int

setConnected

public void setConnected(boolean connected)
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.

Parameters:
connected - boolean

isConnected

public boolean isConnected()
Gets the connected flag.

See Also:
setConnected(boolean)

moveToPoint

public void moveToPoint(double x,
                        double y,
                        double z)
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.)

Parameters:
x - double
y - double
z - double

clear

public void clear()
Clears all points from the trail.