org.opensourcephysics.display
Class TrailBezier

java.lang.Object
  extended by org.opensourcephysics.display.AbstractTrail
      extended by org.opensourcephysics.display.TrailBezier
All Implemented Interfaces:
Drawable, Measurable
Direct Known Subclasses:
TrailSmart

public class TrailBezier
extends AbstractTrail

TrailBezier defines a trail of points connected by a Bezier spline. This object is often used to show the path of a moving object.

Version:
1.0
Author:
Wolfgang Christian

Field Summary
 
Fields inherited from class org.opensourcephysics.display.AbstractTrail
closed, color, drawingStroke, enableMeasure, numpts, xmax, xmaxLogscale, xmin, xminLogscale, ymax, ymaxLogscale, ymin, yminLogscale
 
Constructor Summary
TrailBezier()
           
 
Method Summary
 void addPoint(double x, double y)
          Adds a point to the trail.
 void clear()
          Clears all points from the trail.
 void closeTrail()
          Closes the trail by connecting the first point to the last point.
 void draw(DrawingPanel panel, java.awt.Graphics g)
          Draw the trail on the panel.
protected  void drawPathEnd(DrawingPanel panel, java.awt.Graphics2D g2)
          Draws the points that have not yet been added to the spline.
static XML.ObjectLoader getLoader()
          Returns the XML.ObjectLoader for this class.
 double getXMax()
          Gets the maximum x value in the trail.
 double getXMin()
          Gets the minimum x value in the trail.
 double getYMax()
          Gets the maximum y value in the trail.
 double getYMin()
          Gets the minimum y value in the trail.
 boolean isMeasured()
          Determines if this trail scales the drawing panel.
 void setSlack(double slack)
          Sets the slack which determines the position of the control points.
 
Methods inherited from class org.opensourcephysics.display.AbstractTrail
getNumberOfPoints, getStroke, getXMaxLogscale, getXMinLogscale, getYMaxLogscale, getYMinLogscale, setDashedStroke, setMeasured, setStroke
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrailBezier

public TrailBezier()
Method Detail

addPoint

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

Specified by:
addPoint in class AbstractTrail
Parameters:
x - double
y - double

setSlack

public void setSlack(double slack)
Sets the slack which determines the position of the control points.

Parameters:
slack - double

closeTrail

public void closeTrail()
Closes the trail by connecting the first point to the last point.

Specified by:
closeTrail in class AbstractTrail

clear

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

Specified by:
clear in class AbstractTrail

draw

public void draw(DrawingPanel panel,
                 java.awt.Graphics g)
Draw the trail on the panel.

Parameters:
g -

drawPathEnd

protected void drawPathEnd(DrawingPanel panel,
                           java.awt.Graphics2D g2)
Draws the points that have not yet been added to the spline.

Parameters:
panel - DrawingPanel
g2 - Graphics2D

getLoader

public static XML.ObjectLoader getLoader()
Returns the XML.ObjectLoader for this class.

Returns:
the object loader

isMeasured

public boolean isMeasured()
Determines if this trail scales the drawing panel.

Specified by:
isMeasured in interface Measurable
Overrides:
isMeasured in class AbstractTrail
Returns:
boolean

getXMin

public double getXMin()
Gets the minimum x value in the trail.

Specified by:
getXMin in interface Measurable
Overrides:
getXMin in class AbstractTrail
Returns:
double

getXMax

public double getXMax()
Gets the maximum x value in the trail.

Specified by:
getXMax in interface Measurable
Overrides:
getXMax in class AbstractTrail
Returns:
double

getYMin

public double getYMin()
Gets the minimum y value in the trail.

Specified by:
getYMin in interface Measurable
Overrides:
getYMin in class AbstractTrail
Returns:
double

getYMax

public double getYMax()
Gets the maximum y value in the trail.

Specified by:
getYMax in interface Measurable
Overrides:
getYMax in class AbstractTrail
Returns:
double