org.opensourcephysics.display3d.simple3d
Class ElementTrail

java.lang.Object
  extended by org.opensourcephysics.display3d.simple3d.Element
      extended by org.opensourcephysics.display3d.simple3d.ElementTrail
All Implemented Interfaces:
Data, Element, ElementTrail, InteractionSource

public class ElementTrail
extends Element
implements ElementTrail

Title: ElementSegment

Description: A Segment using the painter's algorithm

Version:
March 2005
Author:
Francisco Esquembre

Field Summary
protected  int datasetID
           
protected  java.util.ArrayList<org.opensourcephysics.display3d.simple3d.ElementTrail.TrailPoint> 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.
 java.lang.String[] getColumnNames()
          The column names to be used in the data display tool
 double[][] getData2D()
          Gets a 2D array of data.
 double[][][] getData3D()
          Gets a 3D array of data.
 java.util.List<Data> getDataList()
          Some Data objects (e.g., a Group) do not contain data, but a list of Data objects which do.
 java.util.ArrayList<Dataset> getDatasets()
          Gets a list of OSP Datasets.
 void getExtrema(double[] min, double[] max)
          Returns the extreme points of a box that contains the element.
 java.awt.Color[] getFillColors()
          Fill color to use for this data
 int getID()
          Returns a unique identifier for this Data
 java.awt.Color[] getLineColors()
          Line color to use for this data
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
 int getNumberOfPoints()
           
 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 setGhostPoint(double[] _point, boolean _connected)
          Sets a temporary point that is displayed as the last point of the trail but is not meant to be a permanent part of the trail.
 void setID(int id)
          Sets the ID number of this Data
 void setMaximumPoints(int maximum)
          Sets the maximum number of points for the trail.
 void setXLabel(java.lang.String _label)
          Sets the label of the X coordinate when the data is displayed in a table
 void setYLabel(java.lang.String _label)
          Sets the label of the Y coordinate when the data is displayed in a table
 void setZLabel(java.lang.String _label)
          Sets the label of the Z coordinate when the data is displayed in a table
 
Methods inherited from class org.opensourcephysics.display3d.simple3d.Element
addInteractionListener, getAxesMode, getDrawingPanel3D, 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
getDrawingPanel3D, 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
 
Methods inherited from interface org.opensourcephysics.display.Data
getName
 

Field Detail

list

protected java.util.ArrayList<org.opensourcephysics.display3d.simple3d.ElementTrail.TrailPoint> list

datasetID

protected int datasetID
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

setXLabel

public void setXLabel(java.lang.String _label)
Description copied from interface: ElementTrail
Sets the label of the X coordinate when the data is displayed in a table

Specified by:
setXLabel in interface ElementTrail

setYLabel

public void setYLabel(java.lang.String _label)
Description copied from interface: ElementTrail
Sets the label of the Y coordinate when the data is displayed in a table

Specified by:
setYLabel in interface ElementTrail

setZLabel

public void setZLabel(java.lang.String _label)
Description copied from interface: ElementTrail
Sets the label of the Z coordinate when the data is displayed in a table

Specified by:
setZLabel in interface ElementTrail

getNumberOfPoints

public int getNumberOfPoints()

setGhostPoint

public void setGhostPoint(double[] _point,
                          boolean _connected)
Description copied from interface: ElementTrail
Sets a temporary point that is displayed as the last point of the trail but is not meant to be a permanent part of the trail. The point can be changed at will and even removed (by passing a null array as point), but if not null, it is always drawn following the last effective point of the trail. This is used by MultiTrail to implement the skip parameter.

Specified by:
setGhostPoint in interface ElementTrail
Parameters:
_point - the double[3] data with the point. null if there is no such point
_connected - whether this point is connected to the previous one

getExtrema

public void getExtrema(double[] min,
                       double[] max)
Description copied from class: Element
Returns the extreme points of a box that contains the element.

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

setID

public void setID(int id)
Description copied from interface: Data
Sets the ID number of this Data

Specified by:
setID in interface Data
Parameters:
id - the ID number

getID

public int getID()
Description copied from interface: Data
Returns a unique identifier for this Data

Specified by:
getID in interface Data
Returns:
the ID number

getData2D

public double[][] getData2D()
Description copied from interface: Data
Gets a 2D array of data. The first column, double[0][] often contains x-values; Remaining columns often contain y values. May return null if data not yet generated or object does not support 2D data.

Specified by:
getData2D in interface Data
Returns:
double[][]

getData3D

public double[][][] getData3D()
Description copied from interface: Data
Gets a 3D array of data. May return null if data not yet generated or object does not support 3D data.

Specified by:
getData3D in interface Data
Returns:
double[][][]

getColumnNames

public java.lang.String[] getColumnNames()
Description copied from interface: Data
The column names to be used in the data display tool

Specified by:
getColumnNames in interface Data
Returns:
an array of names

getLineColors

public java.awt.Color[] getLineColors()
Description copied from interface: Data
Line color to use for this data

Specified by:
getLineColors in interface Data
Returns:
a color

getFillColors

public java.awt.Color[] getFillColors()
Description copied from interface: Data
Fill color to use for this data

Specified by:
getFillColors in interface Data
Returns:
a color

getDataList

public java.util.List<Data> getDataList()
Description copied from interface: Data
Some Data objects (e.g., a Group) do not contain data, but a list of Data objects which do. This method is used by Data displaying tools to create as many pages as needed.

Specified by:
getDataList in interface Data
Returns:
a list of Data objects, or null if this object contains data

getDatasets

public java.util.ArrayList<Dataset> getDatasets()
Description copied from interface: Data
Gets a list of OSP Datasets. May return null if data not yet generated or object does not support Datasets.

Specified by:
getDatasets in interface Data
Returns:
list of Datasets

getLoader

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

Returns:
the XML.ObjectLoader