Package org.opensourcephysics.display
Class TrailSmart
java.lang.Object
org.opensourcephysics.display.AbstractTrail
org.opensourcephysics.display.TrailBezier
org.opensourcephysics.display.TrailSmart
- All Implemented Interfaces:
Drawable,Measurable
TrailSmart adds points to a Bezier trail only if the new point deviates from a straight line.
The smart trail algorithm minimizes the number of points drawn.
- 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPoint(double x, double y) Adds a point to the trail.protected voiddrawPathEnd(DrawingPanel panel, Graphics2D g2) Draws the points that have not yet been added to the Bezier spline.doublegetXMax()Gets the maximum x value in the trail.doublegetXMin()Gets the minimum x value in the trail.doublegetYMax()Gets the maximum y value in the trail.doublegetYMin()Gets the minimum y value in the trail.voidsetMaxError(double max) Sets the maximum error.Methods inherited from class org.opensourcephysics.display.TrailBezier
clear, closeTrail, draw, getLoader, isMeasured, setSlackMethods inherited from class org.opensourcephysics.display.AbstractTrail
getNumberOfPoints, getStroke, getXMaxLogscale, getXMinLogscale, getYMaxLogscale, getYMinLogscale, setDashedStroke, setMeasured, setStrokeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opensourcephysics.display.Drawable
isInteractive
-
Constructor Details
-
TrailSmart
public TrailSmart()
-
-
Method Details
-
setMaxError
public void setMaxError(double max) Sets the maximum error.- Parameters:
max- double
-
addPoint
public void addPoint(double x, double y) Adds a point to the trail.- Overrides:
addPointin classTrailBezier- Parameters:
x- doubley- double
-
drawPathEnd
Draws the points that have not yet been added to the Bezier spline.- Parameters:
panel- DrawingPanelg2- Graphics2D
-
getXMin
public double getXMin()Gets the minimum x value in the trail.- Specified by:
getXMinin interfaceMeasurable- Overrides:
getXMinin classTrailBezier- Returns:
- double
-
getXMax
public double getXMax()Gets the maximum x value in the trail.- Specified by:
getXMaxin interfaceMeasurable- Overrides:
getXMaxin classTrailBezier- Returns:
- double
-
getYMin
public double getYMin()Gets the minimum y value in the trail.- Specified by:
getYMinin interfaceMeasurable- Overrides:
getYMinin classTrailBezier- Returns:
- double
-
getYMax
public double getYMax()Gets the maximum y value in the trail.- Specified by:
getYMaxin interfaceMeasurable- Overrides:
getYMaxin classTrailBezier- Returns:
- double
-