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

Class TPoint

src/org/opensourcephysics/media/core/TPoint.java:61–752  ·  view source on GitHub ↗

This is a Point2D that implements the Interactive and Trackable interfaces with additional utility methods. Classes that extend TPoint should interpret the stored x and y values as image coordinates. TPoint has an empty draw method. @author Douglas Brown @version 1.0

Source from the content-addressed store, hash-verified

59 * @version 1.0
60 */
61@SuppressWarnings("serial")
62public class TPoint extends Point2D.Double implements Interactive, Trackable {
63 protected static boolean coordsVisibleInMouseBox = true;
64 protected static XYCoordinateStringBuilder xyStringBuilder = new VidCartesianCoordinateStringBuilder();
65
66 // instance fields
67 protected boolean enabled = true;
68 protected boolean trackEditTrigger = false;
69 protected boolean coordsEditTrigger = false;
70 protected boolean stepEditTrigger = false;
71 protected boolean isAdjusting = false;
72 protected Point screenPt;
73 protected Point2D.Double worldPt;
74 protected PropertyChangeSupport support;
75 protected TPoint attachedTo;
76 protected double prevX = java.lang.Double.NaN, prevY = java.lang.Double.NaN;
77
78 /**
79 * Constructs a TPoint with image coordinates (0, 0).
80 */
81 public TPoint() {
82 this(0, 0);
83 }
84
85 /**
86 * Constructs a TPoint with specified image coordinates.
87 *
88 * @param x the x coordinate
89 * @param y the y coordinate
90 */
91 public TPoint(double x, double y) {
92 super(x, y);
93 }
94
95 /**
96 * Constructs a TPoint with image coordinates specified by a Point2D (commonly
97 * another TPoint).
98 *
99 * @param point the Point2D
100 */
101 public TPoint(Point2D.Double point) {
102 this(point.x, point.y);
103 }
104
105 /**
106 * Empty draw method. This method should be overridden by subclasses.
107 *
108 * @param panel the drawing panel requesting the drawing
109 * @param _g the graphics context on which to draw
110 */
111 @Override
112 public void draw(DrawingPanel panel, Graphics _g) {
113
114 /** implemented in subclasses */
115 }
116
117 /**
118 * Returns null. This method should be overridden by subclasses.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected