org.opensourcephysics.cabrillo.tracker
Class TapeStep

java.lang.Object
  extended by org.opensourcephysics.cabrillo.tracker.Step
      extended by org.opensourcephysics.cabrillo.tracker.TapeStep
All Implemented Interfaces:
java.lang.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 Summary
protected  boolean drawLayoutBounds
           
protected  TPoint end1
           
protected  java.util.Map<TrackerPanel,java.awt.Shape> end1Shapes
           
protected  TPoint end2
           
protected  java.util.Map<TrackerPanel,java.awt.Shape> end2Shapes
           
protected static TPoint endPoint1
           
protected static TPoint endPoint2
           
protected  boolean endsEnabled
           
protected  org.opensourcephysics.cabrillo.tracker.TapeStep.Handle handle
           
protected  java.util.Map<TrackerPanel,java.awt.Rectangle> layoutBounds
           
protected  TPoint middle
           
protected  java.util.Map<TrackerPanel,java.awt.Shape> shaftShapes
           
protected  TapeMeasure tape
           
protected  double tapeAngle
           
protected  java.util.Map<TrackerPanel,java.awt.font.TextLayout> textLayouts
           
protected  double worldLength
           
protected  double xAxisToTapeAngle
           
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.Step
dataVisible, defaultIndex, footprint, format, frc, hitRect, marks, n, points, screenPoints, selectionShape, textLayoutFont, track, transform, valid
 
Constructor Summary
TapeStep(TapeMeasure track, int n, double x1, double y1, double x2, double y2)
          Constructs a TapeStep with specified end point coordinates in image space.
 
Method Summary
protected  void adjustTipsToAngle()
          Moves the tips of the tape to display current xAxisToTapeAngle.
protected  void adjustTipsToLength()
          Moves the tips of the tape to display current worldLength.
 java.lang.Object 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.
 java.awt.Rectangle getBounds(TrackerPanel trackerPanel)
          Overrides Step getBounds method.
 TPoint getDefaultPoint()
          Gets the default point.
 TPoint getEnd1()
          Gets end 1.
 TPoint getEnd2()
          Gets end 2.
 TPoint getHandle()
          Gets the handle.
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.
 double getTapeAngle()
          Gets the world angle of this tape.
 double getTapeLength(boolean fromEnds)
          Gets the scaled world length of this tape, with side effect of updating angle and length fields.
 boolean isEndsEnabled()
          Gets whether the ends are enabled.
 void setEndsEnabled(boolean enabled)
          Enables and disables the interactivity of the ends.
 void setFootprint(Footprint footprint)
          Overrides Step setFootprint method.
 void setTapeAngle(double theta)
          Sets the world angle of this tape.
 void setTapeLength(double length)
          Sets the world length of this tape and posts an undoable edit.
 java.lang.String toString()
          Returns a String describing this.
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.Step
erase, erase, 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

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

worldLength

protected double worldLength

xAxisToTapeAngle

protected double xAxisToTapeAngle

tapeAngle

protected double tapeAngle

endsEnabled

protected boolean endsEnabled

drawLayoutBounds

protected boolean drawLayoutBounds

end1Shapes

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

end2Shapes

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

shaftShapes

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

textLayouts

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

layoutBounds

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

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 Detail

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,
                 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

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

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

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 java.lang.Object 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

adjustTipsToLength

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


adjustTipsToAngle

protected void adjustTipsToAngle()
Moves the tips of the tape to display current xAxisToTapeAngle.


getLoader

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

Returns:
the object loader