Class TapeStep

java.lang.Object
org.opensourcephysics.cabrillo.tracker.Step
org.opensourcephysics.cabrillo.tracker.TapeStep
All Implemented Interfaces:
Cloneable

public class TapeStep extends Step
This is a Step for a TapeMeasure. It is used for measuring distances and angles and for setting the scale and angle of an ImageCoordSystem.
Author:
Douglas Brown
  • Field Details

    • endPoint1

      protected static TPoint endPoint1
    • endPoint2

      protected static TPoint endPoint2
    • tape

      protected TapeMeasure tape
    • end1

      protected TPoint end1
    • end2

      protected TPoint end2
    • middle

      protected TPoint middle
    • handle

      protected org.opensourcephysics.cabrillo.tracker.TapeStep.Handle handle
    • rotator1

      protected org.opensourcephysics.cabrillo.tracker.TapeStep.Rotator rotator1
    • rotator2

      protected org.opensourcephysics.cabrillo.tracker.TapeStep.Rotator rotator2
    • worldLength

      protected double worldLength
    • xAxisToTapeAngle

      protected double xAxisToTapeAngle
    • tapeAngle

      protected double tapeAngle
    • endsEnabled

      protected boolean endsEnabled
    • drawLayout

      protected boolean drawLayout
    • drawLayoutBounds

      protected boolean drawLayoutBounds
    • adjustingTips

      protected boolean adjustingTips
    • panelEnd1Shapes

      protected Map<Integer,Shape> panelEnd1Shapes
    • panelEnd2Shapes

      protected Map<Integer,Shape> panelEnd2Shapes
    • panelShaftShapes

      protected Map<Integer,Shape> panelShaftShapes
    • panelRotatorShapes

      protected Map<Integer,Shape[]> panelRotatorShapes
    • panelTextLayouts

      protected Map<Integer,OSPRuntime.TextLayout> panelTextLayouts
    • panelLayoutBounds

      protected Map<Integer,Rectangle> panelLayoutBounds
    • rotatorDrawShapes

      protected org.opensourcephysics.cabrillo.tracker.MultiShape[] rotatorDrawShapes
    • selectedShape

      protected Shape selectedShape
  • Constructor Details

    • TapeStep

      public TapeStep(TapeMeasure track, int n, double x1, double y1, double x2, double y2)
      Constructs a TapeStep with specified end point coordinates in image space.
      Parameters:
      track - the track
      n - the frame number
      x1 - the x coordinate of end 1
      y1 - the y coordinate of end 1
      x2 - the x coordinate of end 2
      y2 - the y coordinate of end 2
  • Method Details

    • getEnd1

      public TPoint getEnd1()
      Gets end 1.
      Returns:
      end 1
    • getEnd2

      public TPoint getEnd2()
      Gets end 2.
      Returns:
      end 2
    • getHandle

      public TPoint getHandle()
      Gets the handle.
      Returns:
      the handle
    • setEndsEnabled

      public void setEndsEnabled(boolean enabled)
      Enables and disables the interactivity of the ends.
      Parameters:
      enabled - true to enable the ends
    • isEndsEnabled

      public boolean isEndsEnabled()
      Gets whether the ends are enabled.
      Returns:
      true if the ends are enabled
    • setFootprint

      public void setFootprint(Footprint footprint)
      Overrides Step setFootprint method.
      Overrides:
      setFootprint in class Step
      Parameters:
      footprint - the footprint
    • 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 Interactive that is hit, or null
    • 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
    • getDefaultPoint

      public TPoint getDefaultPoint()
      Gets the default point. The default point is the point initially selected when the step is created. Overrides step getDefaultPoint method.
      Overrides:
      getDefaultPoint in class Step
      Returns:
      the default TPoint
    • getMark

      protected Mark getMark(TrackerPanel trackerPanel)
      Overrides Step getMark method.
      Overrides:
      getMark in class Step
      Parameters:
      trackerPanel - the tracker panel
      Returns:
      the mark
    • getTapeLength

      public double getTapeLength(boolean fromEnds)
      Gets the scaled world length of this tape, with side effect of updating angle and length fields.
      Parameters:
      fromEnds - true if calculated from the current tip positions
      Returns:
      the length in world units
    • getTapeAngle

      public double getTapeAngle()
      Gets the world angle of this tape. Call this method only after getTapeLength(), which does the real work.
      Returns:
      the angle relative to the positive x-axis
    • setTapeLength

      public void setTapeLength(double length)
      Sets the world length of this tape and posts an undoable edit.
      Parameters:
      length - the length in world units
    • setTapeAngle

      public void setTapeAngle(double theta)
      Sets the world angle of this tape.
      Parameters:
      theta - the angle in radians
    • clone

      public Object 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
    • adjustTipsToLength

      protected void adjustTipsToLength()
      Moves the tips of the tape to display current worldLength.
    • adjustTipsToAngle

      protected void adjustTipsToAngle(TPoint p)
      Rotates the tips about a TPoint axis to display current xAxisToTapeAngle. If the TPoint is null the axis is determined from selection and attachment status.
      Parameters:
      p - the TPoint, may be null
    • getLoader

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