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

Method attachTo

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

Attaches this TPoint to another so it follows it. @param p the point to attach to @return true if a change has occurred

(TPoint p)

Source from the content-addressed store, hash-verified

324 * @return true if a change has occurred
325 */
326 public boolean attachTo(TPoint p) {
327 if (p == null || p == this)
328 return false;
329 if (p == attachedTo && p.x == x && p.y == y)
330 return false;
331 // detach this from any previous point
332 detach();
333 // attach by adding property change listener
334 attachedTo = p;
335 p.addPropertyChangeListener("location", new Follower()); //$NON-NLS-1$
336 setXY(p.x, p.y);
337 return true;
338 }
339
340 /**
341 * Detaches this TPoint.

Callers

nothing calls this directly

Calls 3

detachMethod · 0.95
setXYMethod · 0.95

Tested by

no test coverage detected