org.opensourcephysics.cabrillo.tracker
Class Step

java.lang.Object
  extended by org.opensourcephysics.cabrillo.tracker.Step
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
CalibrationStep, CoordAxesStep, LineProfileStep, OffsetOriginStep, PerspectiveStep, PositionStep, ProtractorStep, RGBStep, TapeStep, VectorStep

public abstract class Step
extends java.lang.Object
implements java.lang.Cloneable

A Step is associated with a single frame of a TTrack. It contains an array of TPoints that define its image data and a Footprint that determines its screen appearance. This is an abstract class and cannot be instantiated directly.

Author:
Douglas Brown

Field Summary
protected  boolean dataVisible
           
protected  int defaultIndex
           
protected  Footprint footprint
           
protected static java.text.NumberFormat format
           
protected static java.awt.font.FontRenderContext frc
           
protected static java.awt.Rectangle hitRect
           
protected  java.util.Map<TrackerPanel,Mark> marks
           
protected  int n
           
protected  TPoint[] points
           
protected  java.awt.Point[] screenPoints
           
protected static java.awt.Shape selectionShape
           
protected  TTrack track
           
protected static java.awt.geom.AffineTransform transform
           
protected  boolean valid
           
 
Constructor Summary
protected Step(TTrack track, int n)
          Constructs a Step with the specified frame number.
 
Method Summary
 java.lang.Object clone()
          Clones this Step.
 void draw(DrawingPanel panel, java.awt.Graphics g)
          Draws this step.
 void erase()
          Erases this on all tracker panels.
 void erase(TrackerPanel trackerPanel)
          Erases this on the specified tracker panel.
 Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
          Finds the Interactive located at the specified pixel position.
 java.awt.Rectangle getBounds(TrackerPanel trackerPanel)
          Gets the screen bounds of this step on the specified tracker panel.
 TPoint getDefaultPoint()
          Gets the default point.
 int getFrameNumber()
          Gets the frame number.
static int getLength()
          Gets the step length.
protected  Mark getMark(TrackerPanel trackerPanel)
          Gets the mark for the specified panel.
 int getPointIndex(TPoint p)
          Gets the index of a point in the points[] array.
 TPoint[] getPoints()
          Gets the array of TPoints contained in this step.
 TTrack getTrack()
          Gets the track.
 void remark()
          Remarks this on all tracker panels.
 void remark(TrackerPanel trackerPanel)
          Erases and remarks this on the specified tracker panel.
 void repaint()
          Repaints this on all tracker panels.
 void repaint(TrackerPanel trackerPanel)
          Repaints this on the specified tracker panel.
 void setDefaultPointIndex(int index)
          Sets the default point index.
 void setFootprint(Footprint footprint)
          Sets the footprint.
protected  void setHitRectCenter(int xpix, int ypix)
          Centers the hit testing rectangle on the specified screen point.
 java.lang.String toString()
          Returns a String describing this step.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hitRect

protected static java.awt.Rectangle hitRect

selectionShape

protected static java.awt.Shape selectionShape

transform

protected static java.awt.geom.AffineTransform transform

format

protected static java.text.NumberFormat format

frc

protected static java.awt.font.FontRenderContext frc

track

protected TTrack track

n

protected int n

footprint

protected Footprint footprint

points

protected TPoint[] points

screenPoints

protected java.awt.Point[] screenPoints

valid

protected boolean valid

marks

protected java.util.Map<TrackerPanel,Mark> marks

defaultIndex

protected int defaultIndex

dataVisible

protected boolean dataVisible
Constructor Detail

Step

protected Step(TTrack track,
               int n)
Constructs a Step with the specified frame number.

Parameters:
track - the track
n - the frame number
Method Detail

getFrameNumber

public int getFrameNumber()
Gets the frame number.

Returns:
the frame number

setFootprint

public void setFootprint(Footprint footprint)
Sets the footprint.

Parameters:
footprint - the footprint

getTrack

public TTrack getTrack()
Gets the track.

Returns:
the track

getPoints

public TPoint[] getPoints()
Gets the array of TPoints contained in this step.

Returns:
the TPoints array

getPointIndex

public int getPointIndex(TPoint p)
Gets the index of a point in the points[] array.

Parameters:
p - the point
Returns:
the index, or -1 if not found

getDefaultPoint

public TPoint getDefaultPoint()
Gets the default point. The default point is the point initially selected when the step is created.

Returns:
the default TPoint

setDefaultPointIndex

public void setDefaultPointIndex(int index)
Sets the default point index. This defines the index of the points array used to get the point initially selected when the step is created.

Parameters:
index - the index

erase

public void erase(TrackerPanel trackerPanel)
Erases this on the specified tracker panel. Erasing adds the current bounds to the dirty region and nulls the step's mark to trigger creation of a new one.

Parameters:
trackerPanel - the tracker panel

remark

public void remark(TrackerPanel trackerPanel)
Erases and remarks this on the specified tracker panel. Remarking creates a new mark for the step and adds both the old and new bounds to the tracker panel's dirty region.

Parameters:
trackerPanel - the tracker panel

repaint

public void repaint(TrackerPanel trackerPanel)
Repaints this on the specified tracker panel. Repainting a step first remarks it and then requests a repaint of the panel's dirty region.

Parameters:
trackerPanel - the tracker panel

erase

public void erase()
Erases this on all tracker panels.


remark

public void remark()
Remarks this on all tracker panels.


repaint

public void repaint()
Repaints this on all tracker panels.


draw

public void draw(DrawingPanel panel,
                 java.awt.Graphics g)
Draws this 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)
Finds the Interactive located at the specified pixel position.

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

getBounds

public java.awt.Rectangle getBounds(TrackerPanel trackerPanel)
Gets the screen bounds of this step on the specified tracker panel.

Parameters:
trackerPanel - the tracker panel drawing the step
Returns:
the bounding rectangle

getMark

protected Mark getMark(TrackerPanel trackerPanel)
Gets the mark for the specified panel.

Parameters:
trackerPanel - the tracker panel
Returns:
the mark

toString

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

Overrides:
toString in class java.lang.Object
Returns:
a descriptive string

clone

public java.lang.Object clone()
Clones this Step.

Overrides:
clone in class java.lang.Object
Returns:
a clone of this step

setHitRectCenter

protected void setHitRectCenter(int xpix,
                                int ypix)
Centers the hit testing rectangle on the specified screen point.

Parameters:
xpix - the x pixel position
ypix - the y pixel position

getLength

public static int getLength()
Gets the step length. Default length is 1.

Returns:
the length of the points array