MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / AbstractTrail

Class AbstractTrail

src/org/opensourcephysics/display/AbstractTrail.java:20–183  ·  view source on GitHub ↗

AbstractTrail defines a trail of pixels on the screen. This object is often used to show the path of a moving object. @author Wolfgang Christian @version 1.0

Source from the content-addressed store, hash-verified

18 * @version 1.0
19 */
20public abstract class AbstractTrail implements Drawable, Measurable {
21 public Color color = Color.black; // changing the color is harmless so this can be public
22 protected boolean enableMeasure = false;
23 protected double xmin = Double.MAX_VALUE, xmax = -Double.MAX_VALUE, ymin = Double.MAX_VALUE, ymax = -Double.MAX_VALUE;
24 protected double xmaxLogscale = -Double.MAX_VALUE;
25 // the maximum x value in the trail when using a log scale
26
27 protected double ymaxLogscale = -Double.MAX_VALUE;
28 // the maximum y value in the trail when using a log scale
29
30 protected double xminLogscale = Double.MAX_VALUE;
31 // the minimum x value in the trail when using a log scale
32
33 protected double yminLogscale = Double.MAX_VALUE;
34 // the minimum y value in the trail when using a log scale
35
36 protected int numpts = 0; // the number of points in the trail
37 protected boolean closed = false;
38 protected Stroke drawingStroke;
39
40 /**
41 * Adds a point to the trail.
42 * @param x double
43 * @param y double
44 */
45 public abstract void addPoint(double x, double y);
46
47 /**
48 * Closes the path by connecting the first point to the last point.
49 * Points cannot be added to a closed path;
50 */
51 public abstract void closeTrail();
52
53 /**
54 * Clears all points from the trail.
55 */
56 public abstract void clear();
57
58 /**
59 * Sets the drawing stroke.
60 * @param stroke Stroke
61 */
62 public void setStroke(Stroke stroke) {
63 drawingStroke = stroke;
64 }
65
66 /**
67 * Sets the the dash line stroke.
68 *
69 * @param int dashPoint
70 * @param int dashLength
71 */
72 public void setDashedStroke(int dashPoint, int dashLength) {
73 if(dashLength==0) {
74 drawingStroke = new BasicStroke(dashPoint, 0, 1, 0, null, 0); //regular line
75 } else {
76 drawingStroke = new BasicStroke(dashPoint, 0, 1, 0, new float[] {dashLength}, 0); //dashes
77 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected