org.opensourcephysics.cabrillo.tracker
Class TapeMeasure

java.lang.Object
  extended by org.opensourcephysics.cabrillo.tracker.TTrack
      extended by org.opensourcephysics.cabrillo.tracker.TapeMeasure
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener, Drawable, Interactive, Measurable, Trackable

public class TapeMeasure
extends TTrack

A TapeMeasure measures and displays its world length and its angle relative to the positive x-axis. It is used to set the scale and angle of an ImageCoordSystem.

Author:
Douglas Brown

Nested Class Summary
 
Nested classes/interfaces inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
TTrack.StepArray
 
Field Summary
static float[] BROKEN_LINE
           
protected  boolean editing
           
protected  java.awt.event.MouseListener editListener
           
protected  boolean fixedLength
           
protected  javax.swing.JCheckBoxMenuItem fixedLengthItem
           
protected  boolean fixedPosition
           
protected  javax.swing.JCheckBoxMenuItem fixedPositionItem
           
protected  java.text.NumberFormat format
           
protected  javax.swing.JPanel glassPanel
           
protected  NumberField inputField
           
protected  javax.swing.JPanel inputPanel
           
protected  boolean isStepChangingScale
           
protected  java.util.TreeSet<java.lang.Integer> lengthKeyFrames
           
protected static double MIN_LENGTH
           
protected  boolean notYetShown
           
protected  boolean readOnly
           
protected  Footprint[] stickFootprints
           
protected  boolean stickMode
           
protected  Footprint[] tapeFootprints
           
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
alphabet, angleField, angleLabel, angleSeparator, autoAdvance, autoAdvanceItem, autoTrackerMarking, circleFootprintListener, clearStepsItem, closeButton, colorItem, constantsLoadedFromXML, data, dataBuilderItem, dataFrames, dataProp, dataValid, defaultColors, defaultFootprint, deleteItem, description, descriptionItem, enabled, fieldBorder, footprint, footprintListener, footprintMenu, footprints, frc, hint, isMarking, keyFrames, labelFont, locked, lockedItem, magField, magLabel, magSeparator, markByDefault, markByDefaultItem, menu, name, nameAction, nameDialog, nameField, nameItem, panels, partName, point, preferredColumnOrder, properties, refreshDataLater, skippedStepWarningCheckbox, skippedStepWarningDialog, skippedStepWarningOn, skippedStepWarningTextpane, stepLabel, steps, stepSeparator, stepSizeWhenFirstMarked, stepValueLabel, support, targetIndex, tField, tLabel, toolbarPointComponents, toolbarTrackComponents, trackerPanel, trailLength, trailVisible, trailVisibleItem, tSeparator, tValueLabel, viewable, visible, visibleItem, worldBounds, xField, xLabel, xSeparator, xSpinner, yField, yLabel, ySeparator, ySpinner
 
Constructor Summary
TapeMeasure()
          Constructs a TapeMeasure.
 
Method Summary
 Step createStep(int n, double x, double y)
          Implements createStep but only mimics step creation since steps are created automatically by the autofill StepArray.
 Step createStep(int n, double x1, double y1, double x2, double y2)
          Mimics step creation by setting end positions of an existing step.
 Step deleteStep(int n)
          Overrides TTrack deleteStep method to prevent deletion.
 Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
          Implements findInteractive method.
 int getDefaultAutoTrackerIndex()
          Gets the default step point index.
 int getFootprintLength()
          Gets the length of the footprints required by this track.
 java.lang.String getFormattedLength(double length)
          Formats the specified length value.
static XML.ObjectLoader getLoader()
          Returns an ObjectLoader to save and load data for this class.
 javax.swing.JMenu getMenu(TrackerPanel trackerPanel)
          Returns a menu with items that control this track.
 Step getStep(int n)
          Overrides TTrack getStep method to provide fixedTape behavior.
 int getStepLength()
          Gets the length of the steps created by this track.
 java.util.ArrayList<java.awt.Component> getToolbarTrackComponents(TrackerPanel trackerPanel)
          Returns a list of point-related toolbar components.
protected  boolean isFieldsEnabled()
          Determines if the input fields are enabled.
 boolean isFixedLength()
          Gets the fixed length property.
 boolean isFixedPosition()
          Gets the fixed position property.
 boolean isLocked()
          Overrides TTrack isLocked method.
 boolean isReadOnly()
          Gets the ReadOnly property.
 boolean isStepComplete(int n)
          Returns true if the step at the specified frame number is complete.
 boolean isStickMode()
          Gets the stickMode property.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Responds to property change events.
protected  void refreshStep(TapeStep step)
          Refreshes a step by setting it equal to the previous keyframe step.
protected  void refreshWorldLengths()
          Refreshes world lengths at all steps based on current ends and scale.
 void remark(TrackerPanel trackerPanel)
          Remarks all steps on the specified panel.
 void setFixedLength(boolean fixed)
          Sets the fixed length property.
 void setFixedPosition(boolean fixed)
          Sets the fixed position property.
 void setLocked(boolean locked)
          Overrides TTrack method.
 void setReadOnly(boolean readOnly)
          Sets the readOnly property.
 void setStickMode(boolean stick)
          Sets the stickMode property.
protected  void setTrackerPanel(TrackerPanel panel)
          Overrides TTrack setTrackerPanel method.
 void setTrailVisible(boolean visible)
          Overrides TTrack setTrailVisible method to keep trails hidden.
 void setVisible(boolean visible)
          Overrides TTrack setVisible method to change notYetShown flag.
 java.lang.String toString()
          Overrides Object toString method.
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
addFootprint, addPropertyChangeListener, addPropertyChangeListener, autoMarkAt, cleanup, createWarningDialog, delete, draw, erase, erase, firePropertyChange, getColor, getData, getDataDescription, getDataName, getDescription, getFootprint, getFootprint, getFootprints, getFootprints, getFrameForData, getMarkedPoint, getMarkingCursor, getMessage, getName, getNextVisibleStep, getPreferredDataOrder, getPreviousVisibleStep, getProperty, getPropertyNames, getSkippedStepWarningDialog, getStep, getSteps, getStepSizeWarningDialog, getTargetDescription, getTargetIndex, getToolbarPointComponents, getTrailLength, getWorldBounds, getX, getXMax, getXMax, getXMin, getXMin, getY, getYMax, getYMax, getYMin, getYMin, isAutoAdvance, isAutoTrackable, isAutoTrackable, isDependent, isEmpty, isEnabled, isMarkByDefault, isMeasured, isStepVisible, isTrailVisible, isViewable, isVisible, refreshData, refreshData, remark, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, setAnglesInRadians, setAutoAdvance, setColor, setColorToDefault, setDefaultNameAndColor, setDescription, setEnabled, setFootprint, setFootprint, setFootprints, setFootprints, setMarkByDefault, setMarking, setName, setProperty, setTargetIndex, setTargetIndex, setTargetIndex, setTrailLength, setViewable, setX, setXY, setY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_LENGTH

protected static final double MIN_LENGTH
See Also:
Constant Field Values

BROKEN_LINE

public static final float[] BROKEN_LINE

fixedPosition

protected boolean fixedPosition

fixedLength

protected boolean fixedLength

fixedPositionItem

protected javax.swing.JCheckBoxMenuItem fixedPositionItem

fixedLengthItem

protected javax.swing.JCheckBoxMenuItem fixedLengthItem

editing

protected boolean editing

inputField

protected final NumberField inputField

inputPanel

protected javax.swing.JPanel inputPanel

glassPanel

protected javax.swing.JPanel glassPanel

format

protected java.text.NumberFormat format

editListener

protected java.awt.event.MouseListener editListener

readOnly

protected boolean readOnly

stickMode

protected boolean stickMode

isStepChangingScale

protected boolean isStepChangingScale

notYetShown

protected boolean notYetShown

tapeFootprints

protected Footprint[] tapeFootprints

stickFootprints

protected Footprint[] stickFootprints

lengthKeyFrames

protected java.util.TreeSet<java.lang.Integer> lengthKeyFrames
Constructor Detail

TapeMeasure

public TapeMeasure()
Constructs a TapeMeasure.

Method Detail

setFixedPosition

public void setFixedPosition(boolean fixed)
Sets the fixed position property. When it is fixed, it is in the same position at all times.

Parameters:
fixed - true to fix the position

isFixedPosition

public boolean isFixedPosition()
Gets the fixed position property.

Returns:
true if position is fixed

setFixedLength

public void setFixedLength(boolean fixed)
Sets the fixed length property. When it is fixed, it has the same length at all times. Applies to sticks only.

Parameters:
fixed - true to fix the length

isFixedLength

public boolean isFixedLength()
Gets the fixed length property.

Returns:
true if length is fixed

setReadOnly

public void setReadOnly(boolean readOnly)
Sets the readOnly property. When true, the scale and angle are not settable.

Parameters:
readOnly - true to prevent editing

isReadOnly

public boolean isReadOnly()
Gets the ReadOnly property.

Returns:
true if read-only

setStickMode

public void setStickMode(boolean stick)
Sets the stickMode property. When true, the 'stick" has constant world length and the scale changes when you drag the mouse. When false, the "tape" stretches without changing the scale when you drag the mouse.

Parameters:
stick - true for stick mode, false for tape mode

isStickMode

public boolean isStickMode()
Gets the stickMode property.

Returns:
true if in stick mode

isStepComplete

public boolean isStepComplete(int n)
Returns true if the step at the specified frame number is complete. Overrides TTrack isStepComplete method.

Overrides:
isStepComplete in class TTrack
Parameters:
n - the frame number
Returns:
true if the step is complete

setLocked

public void setLocked(boolean locked)
Overrides TTrack method.

Overrides:
setLocked in class TTrack
Parameters:
locked - true to lock this

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Responds to property change events. Overrides TTrack method.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class TTrack
Parameters:
e - the property change event

setVisible

public void setVisible(boolean visible)
Overrides TTrack setVisible method to change notYetShown flag.

Overrides:
setVisible in class TTrack
Parameters:
visible - true to show this track

setTrailVisible

public void setTrailVisible(boolean visible)
Overrides TTrack setTrailVisible method to keep trails hidden.

Overrides:
setTrailVisible in class TTrack
Parameters:
visible - ignored

isLocked

public boolean isLocked()
Overrides TTrack isLocked method.

Overrides:
isLocked in class TTrack
Returns:
true if this is locked

createStep

public Step createStep(int n,
                       double x,
                       double y)
Implements createStep but only mimics step creation since steps are created automatically by the autofill StepArray.

Specified by:
createStep in class TTrack
Parameters:
n - the frame number
x - the x coordinate in image space
y - the y coordinate in image space
Returns:
the step

createStep

public Step createStep(int n,
                       double x1,
                       double y1,
                       double x2,
                       double y2)
Mimics step creation by setting end positions of an existing step.

Parameters:
n - the frame number
x1 - the x coordinate of end1 in image space
y1 - the y coordinate of end1 in image space
x2 - the x coordinate of end2 in image space
y2 - the y coordinate of end2 in image space
Returns:
the step

deleteStep

public Step deleteStep(int n)
Overrides TTrack deleteStep method to prevent deletion.

Overrides:
deleteStep in class TTrack
Parameters:
n - the frame number
Returns:
the deleted step

getStep

public Step getStep(int n)
Overrides TTrack getStep method to provide fixedTape behavior.

Overrides:
getStep in class TTrack
Parameters:
n - the frame number
Returns:
the step

getStepLength

public int getStepLength()
Gets the length of the steps created by this track.

Specified by:
getStepLength in class TTrack
Returns:
the footprint length

getDefaultAutoTrackerIndex

public int getDefaultAutoTrackerIndex()
Gets the default step point index.

Specified by:
getDefaultAutoTrackerIndex in class TTrack
Returns:
the step pint index

getFootprintLength

public int getFootprintLength()
Gets the length of the footprints required by this track.

Specified by:
getFootprintLength in class TTrack
Returns:
the footprint length

getFormattedLength

public java.lang.String getFormattedLength(double length)
Formats the specified length value.

Parameters:
length - the length value to format
Returns:
the formatted length string

getMenu

public javax.swing.JMenu getMenu(TrackerPanel trackerPanel)
Returns a menu with items that control this track.

Overrides:
getMenu in class TTrack
Parameters:
trackerPanel - the tracker panel
Returns:
a menu

getToolbarTrackComponents

public java.util.ArrayList<java.awt.Component> getToolbarTrackComponents(TrackerPanel trackerPanel)
Returns a list of point-related toolbar components.

Overrides:
getToolbarTrackComponents in class TTrack
Parameters:
trackerPanel - the tracker panel
Returns:
a list of components

findInteractive

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

Specified by:
findInteractive in interface Interactive
Overrides:
findInteractive in class TTrack
Parameters:
panel - the drawing panel
xpix - the x pixel position on the panel
ypix - the y pixel position on the panel
Returns:
the first step or motion vector that is hit

remark

public void remark(TrackerPanel trackerPanel)
Remarks all steps on the specified panel. Overrides TTrack method.

Overrides:
remark in class TTrack
Parameters:
trackerPanel - the tracker panel

toString

public java.lang.String toString()
Overrides Object toString method.

Overrides:
toString in class TTrack
Returns:
the name of this track

setTrackerPanel

protected void setTrackerPanel(TrackerPanel panel)
Overrides TTrack setTrackerPanel method.

Overrides:
setTrackerPanel in class TTrack
Parameters:
panel - the TrackerPanel

refreshWorldLengths

protected void refreshWorldLengths()
Refreshes world lengths at all steps based on current ends and scale.


refreshStep

protected void refreshStep(TapeStep step)
Refreshes a step by setting it equal to the previous keyframe step.

Parameters:
step - the step to refresh

isFieldsEnabled

protected boolean isFieldsEnabled()
Determines if the input fields are enabled.

Returns:
true if enabled

getLoader

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

Returns:
the object loader