org.opensourcephysics.cabrillo.tracker
Class VectorStep

java.lang.Object
  extended by org.opensourcephysics.cabrillo.tracker.Step
      extended by org.opensourcephysics.cabrillo.tracker.VectorStep
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.lang.Cloneable, java.util.EventListener

public class VectorStep
extends Step
implements java.beans.PropertyChangeListener

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
protected  TPoint attachmentPoint
           
protected  boolean brandNew
           
protected  VectorChain chain
           
protected  int dx
           
protected  int dy
           
protected  boolean firePropertyChangeEvents
           
protected  java.awt.Font font
           
protected  org.opensourcephysics.cabrillo.tracker.VectorStep.Handle handle
           
protected  org.opensourcephysics.cabrillo.tracker.VectorStep.Hinge hinge
           
protected  boolean labelVisible
           
protected  java.util.Map<TrackerPanel,java.awt.Rectangle> layoutBounds
           
protected  TPoint middle
           
protected static boolean pointSnapEnabled
           
protected  boolean rolloverVisible
           
protected  java.util.Map<TrackerPanel,java.awt.Shape> shaftShapes
           
protected static double snapDistance
           
protected  TPoint tail
           
protected static TPoint tailPoint
           
protected  java.util.Map<TrackerPanel,java.awt.font.TextLayout> textLayouts
           
protected  TPoint tip
           
protected  boolean tipEnabled
           
protected static TPoint tipPoint
           
protected  java.util.Map<TrackerPanel,java.awt.Shape> tipShapes
           
protected  boolean valid
           
protected static java.util.Map<TrackerPanel,java.util.Set<VectorStep>> vectors
           
protected static boolean vectorSnapEnabled
           
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.Step
dataVisible, defaultIndex, footprint, format, frc, hitRect, marks, n, points, screenPoints, selectionShape, track, transform
 
Constructor Summary
VectorStep(TTrack track, int n, double x, double y, double xc, double yc)
          Constructs a VectorStep with specified imagespace tail coordinates and vector components.
 
Method Summary
 void attach(TPoint pt)
          Attaches the tail of this vector to the specified point.
 VectorStep clone()
          Clones this Step.
 void draw(DrawingPanel panel, java.awt.Graphics _g)
          Overrides Step draw method.
 Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
          Overrides Step findInteractive method.
 TPoint getAttachmentPoint()
          Gets the attachment point.
 java.awt.Rectangle getBounds(TrackerPanel trackerPanel)
          Overrides Step getBounds method.
 VectorChain getChain()
          Gets the vector chain containing this vector, if any.
 TPoint getHandle()
          Gets the handle.
 TPoint getHinge()
          Gets the hinge point.
static int getLength()
          Gets the step length.
static XML.ObjectLoader getLoader()
          Returns an ObjectLoader to save and load data for this class.
protected  Mark getMark(TrackerPanel trackerPanel)
          Overrides Step getMark method.
 TPoint getTail()
          Gets the tail.
 TPoint getTip()
          Gets the tip.
 double getXComponent()
          Gets the x component.
 double getYComponent()
          Gets the y component.
 boolean isLabelVisible()
          Gets the vector label visibility.
static boolean isPointSnapEnabled()
          Gets whether snap-to-point is enabled.
 boolean isRolloverVisible()
          Gets the rollover visibility.
 boolean isTipEnabled()
          Gets whether the tip is enabled.
static boolean isVectorSnapEnabled()
          Gets whether snap-to-vector is enabled.
 void propertyChange(java.beans.PropertyChangeEvent e)
          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.
 java.lang.String toString()
          Returns a String describing this.
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.Step
erase, erase, getDefaultAutotrackIndex, getDefaultPoint, getFrameNumber, getPointIndex, getPoints, getTrack, remark, remark, repaint, repaint, setDefaultPointIndex, setHitRectCenter
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pointSnapEnabled

protected static boolean pointSnapEnabled

vectorSnapEnabled

protected static boolean vectorSnapEnabled

snapDistance

protected static double snapDistance

vectors

protected static java.util.Map<TrackerPanel,java.util.Set<VectorStep>> vectors

tipPoint

protected static TPoint tipPoint

tailPoint

protected static TPoint tailPoint

tail

protected TPoint tail

tip

protected TPoint tip

middle

protected TPoint middle

handle

protected org.opensourcephysics.cabrillo.tracker.VectorStep.Handle handle

hinge

protected org.opensourcephysics.cabrillo.tracker.VectorStep.Hinge hinge

dx

protected int dx

dy

protected int dy

tipEnabled

protected boolean tipEnabled

tipShapes

protected java.util.Map<TrackerPanel,java.awt.Shape> tipShapes

shaftShapes

protected java.util.Map<TrackerPanel,java.awt.Shape> shaftShapes

attachmentPoint

protected TPoint attachmentPoint

chain

protected VectorChain chain

brandNew

protected boolean brandNew

firePropertyChangeEvents

protected boolean firePropertyChangeEvents

labelVisible

protected boolean labelVisible

rolloverVisible

protected boolean rolloverVisible

valid

protected boolean valid

textLayouts

protected java.util.Map<TrackerPanel,java.awt.font.TextLayout> textLayouts

layoutBounds

protected java.util.Map<TrackerPanel,java.awt.Rectangle> layoutBounds

font

protected java.awt.Font font
Constructor Detail

VectorStep

public VectorStep(TTrack track,
                  int n,
                  double x,
                  double y,
                  double xc,
                  double yc)
Constructs a VectorStep with specified imagespace tail coordinates and vector components.

Parameters:
track - the track
n - the frame number
x - the x coordinate
y - the y coordinate
xc - the x component
yc - the y component
Method Detail

getTip

public TPoint getTip()
Gets the tip.

Returns:
the tip

getTail

public TPoint getTail()
Gets the tail.

Returns:
the tail

getHandle

public TPoint getHandle()
Gets the handle.

Returns:
the handle

getHinge

public TPoint getHinge()
Gets the hinge point.

Returns:
the hinge

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 component
y - 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

public void snap(TrackerPanel trackerPanel)
Snaps to point or vector within snapDistance of tail.

Parameters:
trackerPanel - the tracker panel drawing this

getChain

public VectorChain getChain()
Gets the vector chain containing this vector, if any.

Returns:
the chain

attach

public void attach(TPoint pt)
Attaches the tail of this vector to the specified point. Detaches if the point is null.

Parameters:
pt - the attachment point

getAttachmentPoint

public TPoint 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

public void setFootprint(Footprint footprint)
Overrides Step setFootprint method.

Overrides:
setFootprint in class Step
Parameters:
footprint - the footprint

draw

public void draw(DrawingPanel panel,
                 java.awt.Graphics _g)
Overrides Step draw method.

Overrides:
draw in class Step
Parameters:
panel - the drawing panel requesting the drawing
_g - the graphics context on which to draw

findInteractive

public Interactive findInteractive(DrawingPanel panel,
                                   int xpix,
                                   int ypix)
Overrides Step findInteractive method.

Overrides:
findInteractive in class Step
Parameters:
panel - the drawing panel
xpix - the x pixel position
ypix - the y pixel position
Returns:
the TPoint that is hit, or null

getMark

protected Mark getMark(TrackerPanel trackerPanel)
Overrides Step getMark method.

Overrides:
getMark in class Step
Parameters:
trackerPanel - the tracker panel
Returns:
the mark

getBounds

public java.awt.Rectangle getBounds(TrackerPanel trackerPanel)
Overrides Step getBounds method.

Overrides:
getBounds in class Step
Parameters:
trackerPanel - the tracker panel drawing the step
Returns:
the bounding rectangle

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Responds to property change events. VectorStep receives the following events: "location" from an attached TPoint.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
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

public VectorStep clone()
Clones this Step.

Overrides:
clone in class Step
Returns:
a clone of this step

toString

public java.lang.String toString()
Returns a String describing this.

Overrides:
toString in class Step
Returns:
a descriptive string

getLength

public static int getLength()
Gets the step length.

Returns:
the length of the points array

getLoader

public static XML.ObjectLoader getLoader()
Returns an ObjectLoader to save and load data for this class.

Returns:
the object loader