Class VectorStep

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

public class VectorStep extends Step implements 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 Details

    • pointSnapEnabled

      protected static boolean pointSnapEnabled
    • vectorSnapEnabled

      protected static boolean vectorSnapEnabled
    • snapDistance

      protected static double snapDistance
    • tipPoint

      protected TPoint tipPoint
    • tailPoint

      protected TPoint tailPoint
    • tail

      protected TPoint tail
    • tip

      protected TPoint tip
    • middle

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

      protected Map<Integer,Shape> tipShapes
    • shaftShapes

      protected Map<Integer,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 Map<Integer,OSPRuntime.TextLayout> textLayouts
    • layoutBounds

      protected Map<Integer,Rectangle> layoutBounds
  • Constructor Details

    • 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
    • VectorStep

      public VectorStep(TTrack track, int n, double x, double y, double xc, double yc, int type)
  • Method Details

    • 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
    • getVisibleTip

      public TPoint 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 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, 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
    • propertyChange

      public void propertyChange(PropertyChangeEvent e)
      Responds to property change events. VectorStep receives the following events: "location" from an attached TPoint.
      Specified by:
      propertyChange in interface 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 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