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 TPointprotected booleanprotected VectorChainprotected intprotected intprotected booleanprotected org.opensourcephysics.cabrillo.tracker.VectorStep.Handleprotected booleanprotected TPointprotected static booleanprotected booleanprotected static doubleprotected TPointprotected TPointprotected Map<Integer,OSPRuntime.TextLayout> protected TPointprotected booleanprotected TPointprotected booleanprotected static booleanprotected org.opensourcephysics.cabrillo.tracker.VectorStep.VisibleTipFields 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 TypeMethodDescriptionvoidAttaches the tail of this vector to the specified point.clone()Clones this Step.voiddraw(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 intGets the step length.static XML.ObjectLoaderReturns an ObjectLoader to save and load data for this class.protected MarkgetMark(TrackerPanel trackerPanel) Overrides Step getMark method.getTail()Gets the tail.getTip()Gets the tip.Gets the visible tip point.doubleGets the x component.doubleGets the y component.booleanGets the vector label visibility.static booleanGets whether snap-to-point is enabled.booleanGets the rollover visibility.booleanGets whether the tip is enabled.static booleanGets whether snap-to-vector is enabled.voidResponds to property change events.voidsetFirePropertyChangeEvents(boolean fireEvents) Sets firePropertyChangeEvents flag.voidsetFootprint(Footprint footprint) Overrides Step setFootprint method.voidsetLabelVisible(boolean visible) Sets the vector label visibility.static voidsetPointSnapEnabled(boolean enabled) Enables and disables snap-to-point.voidsetRolloverVisible(boolean visible) Sets the rollover visibility.voidsetTipEnabled(boolean enabled) Enables and disables the interactivity of the tip.static voidsetVectorSnapEnabled(boolean enabled) Enables and disables snap-to-vector.voidsetXComponent(double x) Sets the x component.voidsetXYComponents(double x, double y) Sets the x and y components.voidsetYComponent(double y) Sets the y component.voidsnap(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:
trueif label is visible
-
setLabelVisible
public void setLabelVisible(boolean visible) Sets the vector label visibility.- Parameters:
visible-trueto make label visible
-
isRolloverVisible
public boolean isRolloverVisible()Gets the rollover visibility.- Returns:
trueif labels are visible on rollover only
-
setRolloverVisible
public void setRolloverVisible(boolean visible) Sets the rollover visibility.- Parameters:
visible-trueto make labels visible on rollover only
-
setPointSnapEnabled
public static void setPointSnapEnabled(boolean enabled) Enables and disables snap-to-point.- Parameters:
enabled-trueto enable snap-to-point
-
isPointSnapEnabled
public static boolean isPointSnapEnabled()Gets whether snap-to-point is enabled.- Returns:
trueif snap-to-point is enabled
-
setVectorSnapEnabled
public static void setVectorSnapEnabled(boolean enabled) Enables and disables snap-to-vector.- Parameters:
enabled-trueto enable snap-to-vector
-
isVectorSnapEnabled
public static boolean isVectorSnapEnabled()Gets whether snap-to-vector is enabled.- Returns:
trueif 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-trueto enable the tip
-
isTipEnabled
public boolean isTipEnabled()Gets whether the tip is enabled.- Returns:
trueif the tip is enabled
-
setFootprint
Overrides Step setFootprint method.- Overrides:
setFootprintin classStep- Parameters:
footprint- the footprint
-
draw
Overrides Step draw method. -
findInteractive
Overrides Step findInteractive method.- Overrides:
findInteractivein 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:
propertyChangein interfacePropertyChangeListener- Parameters:
e- the property change event
-
setFirePropertyChangeEvents
public void setFirePropertyChangeEvents(boolean fireEvents) Sets firePropertyChangeEvents flag.- Parameters:
fireEvents-trueto 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
-