Class VectorStep
java.lang.Object
org.opensourcephysics.cabrillo.tracker.Step
org.opensourcephysics.cabrillo.tracker.VectorStep
- All Implemented Interfaces:
PropertyChangeListener
,Cloneable
,EventListener
This is a Step that represents a vector. It is used when tracking vector
objects (eg Force) or displaying the motion of a PointMass.
- Author:
- Douglas Brown
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TPoint
protected boolean
protected VectorChain
protected int
protected int
protected boolean
protected org.opensourcephysics.cabrillo.tracker.VectorStep.Handle
protected boolean
protected TPoint
protected static boolean
protected boolean
protected static double
protected TPoint
protected TPoint
protected Map<Integer,
OSPRuntime.TextLayout> protected TPoint
protected boolean
protected TPoint
protected boolean
protected static boolean
protected org.opensourcephysics.cabrillo.tracker.VectorStep.VisibleTip
Fields inherited from class org.opensourcephysics.cabrillo.tracker.Step
dataVisible, defaultIndex, footprint, format, hitRect, n, panelMarks, points, screenPoints, selectionShape, selectionStroke, trackID, transform, type, TYPE_ACCELERATION, TYPE_UNKNOWN, TYPE_VELOCITY
-
Constructor Summary
ConstructorsConstructorDescriptionVectorStep
(TTrack track, int n, double x, double y, double xc, double yc) Constructs a VectorStep with specified imagespace tail coordinates and vector components.VectorStep
(TTrack track, int n, double x, double y, double xc, double yc, int type) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Attaches the tail of this vector to the specified point.clone()
Clones this Step.void
draw
(DrawingPanel panel, Graphics _g) Overrides Step draw method.findInteractive
(DrawingPanel panel, int xpix, int ypix) Overrides Step findInteractive method.Gets the attachment point.getChain()
Gets the vector chain containing this vector, if any.Gets the handle.static int
Gets the step length.static XML.ObjectLoader
Returns an ObjectLoader to save and load data for this class.protected Mark
getMark
(TrackerPanel trackerPanel) Overrides Step getMark method.getTail()
Gets the tail.getTip()
Gets the tip.Gets the visible tip point.double
Gets the x component.double
Gets the y component.boolean
Gets the vector label visibility.static boolean
Gets whether snap-to-point is enabled.boolean
Gets the rollover visibility.boolean
Gets whether the tip is enabled.static boolean
Gets whether snap-to-vector is enabled.void
Responds to property change events.void
setFirePropertyChangeEvents
(boolean fireEvents) Sets firePropertyChangeEvents flag.void
setFootprint
(Footprint footprint) Overrides Step setFootprint method.void
setLabelVisible
(boolean visible) Sets the vector label visibility.static void
setPointSnapEnabled
(boolean enabled) Enables and disables snap-to-point.void
setRolloverVisible
(boolean visible) Sets the rollover visibility.void
setTipEnabled
(boolean enabled) Enables and disables the interactivity of the tip.static void
setVectorSnapEnabled
(boolean enabled) Enables and disables snap-to-vector.void
setXComponent
(double x) Sets the x component.void
setXYComponents
(double x, double y) Sets the x and y components.void
setYComponent
(double y) Sets the y component.void
snap
(TrackerPanel trackerPanel) Snaps to point or vector within snapDistance of tail.toString()
Returns a String describing this.Methods inherited from class org.opensourcephysics.cabrillo.tracker.Step
dispose, erase, erase, getDefaultPoint, getFrameNumber, getPointIndex, getPoints, getTrack, remark, remark, repaint, repaint, setDefaultPointIndex, setHitRectCenter
-
Field Details
-
pointSnapEnabled
protected static boolean pointSnapEnabled -
vectorSnapEnabled
protected static boolean vectorSnapEnabled -
snapDistance
protected static double snapDistance -
tipPoint
-
tailPoint
-
tail
-
tip
-
middle
-
handle
protected org.opensourcephysics.cabrillo.tracker.VectorStep.Handle handle -
visibleTip
protected org.opensourcephysics.cabrillo.tracker.VectorStep.VisibleTip visibleTip -
dx
protected int dx -
dy
protected int dy -
tipEnabled
protected boolean tipEnabled -
tipShapes
-
shaftShapes
-
attachmentPoint
-
chain
-
brandNew
protected boolean brandNew -
firePropertyChangeEvents
protected boolean firePropertyChangeEvents -
labelVisible
protected boolean labelVisible -
rolloverVisible
protected boolean rolloverVisible -
valid
protected boolean valid -
textLayouts
-
layoutBounds
-
-
Constructor Details
-
VectorStep
Constructs a VectorStep with specified imagespace tail coordinates and vector components.- Parameters:
track
- the trackn
- the frame numberx
- the x coordinatey
- the y coordinatexc
- the x componentyc
- the y component
-
VectorStep
-
-
Method Details
-
getTip
Gets the tip.- Returns:
- the tip
-
getTail
Gets the tail.- Returns:
- the tail
-
getHandle
Gets the handle.- Returns:
- the handle
-
getVisibleTip
Gets the visible tip point.- Returns:
- the visible tip
-
setXComponent
public void setXComponent(double x) Sets the x component.- Parameters:
x
- the x component
-
setYComponent
public void setYComponent(double y) Sets the y component.- Parameters:
y
- the y component
-
setXYComponents
public void setXYComponents(double x, double y) Sets the x and y components.- Parameters:
x
- the x componenty
- the y component
-
getXComponent
public double getXComponent()Gets the x component.- Returns:
- the x component
-
getYComponent
public double getYComponent()Gets the y component.- Returns:
- the y component
-
isLabelVisible
public boolean isLabelVisible()Gets the vector label visibility.- Returns:
true
if label is visible
-
setLabelVisible
public void setLabelVisible(boolean visible) Sets the vector label visibility.- Parameters:
visible
-true
to make label visible
-
isRolloverVisible
public boolean isRolloverVisible()Gets the rollover visibility.- Returns:
true
if labels are visible on rollover only
-
setRolloverVisible
public void setRolloverVisible(boolean visible) Sets the rollover visibility.- Parameters:
visible
-true
to make labels visible on rollover only
-
setPointSnapEnabled
public static void setPointSnapEnabled(boolean enabled) Enables and disables snap-to-point.- Parameters:
enabled
-true
to enable snap-to-point
-
isPointSnapEnabled
public static boolean isPointSnapEnabled()Gets whether snap-to-point is enabled.- Returns:
true
if snap-to-point is enabled
-
setVectorSnapEnabled
public static void setVectorSnapEnabled(boolean enabled) Enables and disables snap-to-vector.- Parameters:
enabled
-true
to enable snap-to-vector
-
isVectorSnapEnabled
public static boolean isVectorSnapEnabled()Gets whether snap-to-vector is enabled.- Returns:
true
if snap-to-vector is enabled
-
snap
Snaps to point or vector within snapDistance of tail.- Parameters:
trackerPanel
- the tracker panel drawing this
-
getChain
Gets the vector chain containing this vector, if any.- Returns:
- the chain
-
attach
Attaches the tail of this vector to the specified point. Detaches if the point is null.- Parameters:
pt
- the attachment point
-
getAttachmentPoint
Gets the attachment point.- Returns:
- the attachment point
-
setTipEnabled
public void setTipEnabled(boolean enabled) Enables and disables the interactivity of the tip.- Parameters:
enabled
-true
to enable the tip
-
isTipEnabled
public boolean isTipEnabled()Gets whether the tip is enabled.- Returns:
true
if the tip is enabled
-
setFootprint
Overrides Step setFootprint method.- Overrides:
setFootprint
in classStep
- Parameters:
footprint
- the footprint
-
draw
Overrides Step draw method. -
findInteractive
Overrides Step findInteractive method.- Overrides:
findInteractive
in classStep
- Parameters:
panel
- the drawing panelxpix
- the x pixel positionypix
- the y pixel position- Returns:
- the TPoint that is hit, or null
-
getMark
Overrides Step getMark method. -
propertyChange
Responds to property change events. VectorStep receives the following events: "location" from an attached TPoint.- Specified by:
propertyChange
in interfacePropertyChangeListener
- Parameters:
e
- the property change event
-
setFirePropertyChangeEvents
public void setFirePropertyChangeEvents(boolean fireEvents) Sets firePropertyChangeEvents flag.- Parameters:
fireEvents
-true
to request this to fire property change events
-
clone
Clones this Step. -
toString
Returns a String describing this. -
getLength
public static int getLength()Gets the step length.- Returns:
- the length of the points array
-
getLoader
Returns an ObjectLoader to save and load data for this class.- Returns:
- the object loader
-