org.opensourcephysics.cabrillo.tracker
Class Vector

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

public class Vector
extends TTrack

A Vector draws a series of VectorSteps that represent a generic time-dependent vector.

Author:
Douglas Brown

Nested Class Summary
static class Vector.FrameData
          Inner class containing the vector data for a single frame number.
 
Nested classes/interfaces inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
TTrack.StepArray
 
Field Summary
protected  javax.swing.JCheckBoxMenuItem labelsVisibleItem
           
protected  javax.swing.JMenuItem tailsToOriginItem
           
protected  java.util.Map<TrackerPanel,java.lang.Boolean> visMap
           
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
alphabet, angleField, angleLabel, angleSeparator, attachments, autoAdvance, autoAdvanceItem, autoTrackerMarking, circleFootprintListener, clearStepsItem, closeButton, colorItem, constantsLoadedFromXML, data, dataBuilderItem, dataDescriptions, dataFrames, dataProp, dataValid, defaultColors, defaultFootprint, deleteStepItem, deleteTrackItem, 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
Vector()
          Constructs a Vector.
 
Method Summary
 Step createStep(int n, double x, double y)
          Implements createStep.
 Step createStep(int n, double x, double y, double xc, double yc)
          Creates a vector step with specified tail position and vector components.
 void draw(DrawingPanel panel, java.awt.Graphics _g)
          Overrides TTrack draw method.
 Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
          Finds the interactive drawable object located at the specified pixel position.
 int getFootprintLength()
          Gets the length of the footprints required by this track.
static XML.ObjectLoader getLoader()
          Returns an ObjectLoader to save and load data for this class.
 javax.swing.JMenu getMenu(TrackerPanel trackerPanel)
          Overrides TTrack getMenu method.
 int getStepLength()
          Gets the length of the steps created by this track.
 java.util.ArrayList<java.awt.Component> getToolbarPointComponents(TrackerPanel trackerPanel, TPoint point)
          Overrides TTrack getToolbarPointComponents method.
 java.util.ArrayList<java.awt.Component> getToolbarTrackComponents(TrackerPanel trackerPanel)
          Overrides TTrack getToolbarTrackComponents method.
 boolean isLabelsVisible()
          Gets the labels visibility.
 boolean isVectorsVisible(TrackerPanel trackerPanel)
          Gets whether the vectors are visible on the specified panel.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Responds to property change events.
protected  void refreshData(DatasetManager data, TrackerPanel trackerPanel)
          Refreshes the data.
 void setLabelsVisible(boolean visible)
          Sets the visibility of force vector labels.
 void setLocked(boolean locked)
          Overrides TTrack setLocked method.
 void setVectorsVisible(TrackerPanel panel, boolean visible)
          Sets the visibility of the vectors on the specified tracker panel.
 java.lang.String toString()
          Overrides Object toString method.
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
addFootprint, addPropertyChangeListener, addPropertyChangeListener, autoMarkAt, cleanup, createWarningDialog, delete, deleteStep, erase, erase, firePropertyChange, getColor, getData, getDataDescription, getDataName, getDescription, getFootprint, getFootprint, getFootprints, getFootprints, getFrameForData, getMarkedPoint, getMarkingCursor, getMessage, getName, getNextVisibleStep, getPreferredDataOrder, getPreviousVisibleStep, getProperty, getPropertyNames, getSkippedStepWarningDialog, getStep, getStep, getSteps, getStepSizeWarningDialog, getTargetDescription, getTargetIndex, getTrailLength, getWorldBounds, getX, getXMax, getXMax, getXMin, getXMin, getY, getYMax, getYMax, getYMin, getYMin, isAutoAdvance, isAutoTrackable, isAutoTrackable, isDependent, isEmpty, isEnabled, isLocked, isMarkByDefault, isMeasured, isStepComplete, isStepVisible, isTrailVisible, isViewable, isVisible, refreshData, remark, remark, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, setAnglesInRadians, setAutoAdvance, setColor, setColorToDefault, setDefaultNameAndColor, setDescription, setEnabled, setFootprint, setFootprint, setFootprints, setFootprints, setMarkByDefault, setMarking, setName, setProperty, setTargetIndex, setTargetIndex, setTargetIndex, setTrackerPanel, setTrailLength, setTrailVisible, setViewable, setVisible, setX, setXY, setY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tailsToOriginItem

protected javax.swing.JMenuItem tailsToOriginItem

labelsVisibleItem

protected javax.swing.JCheckBoxMenuItem labelsVisibleItem

visMap

protected java.util.Map<TrackerPanel,java.lang.Boolean> visMap
Constructor Detail

Vector

public Vector()
Constructs a Vector.

Method Detail

createStep

public Step createStep(int n,
                       double x,
                       double y)
Implements createStep. When creating a vector the coordinates define both the tail and tip position, but when re-marking an existing vector they define the tip position only.

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 new step

createStep

public Step createStep(int n,
                       double x,
                       double y,
                       double xc,
                       double yc)
Creates a vector step with specified tail position and vector components.

Parameters:
n - the frame number
x - the tail x coordinate in image space
y - the tail y coordinate in image space
xc - the x component in image space
yc - the y component in image space
Returns:
the new 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

getFootprintLength

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

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

draw

public void draw(DrawingPanel panel,
                 java.awt.Graphics _g)
Overrides TTrack draw method.

Specified by:
draw in interface Drawable
Overrides:
draw in class TTrack
Parameters:
panel - the drawing panel requesting the drawing
_g - the graphics context on which to draw

setLocked

public void setLocked(boolean locked)
Overrides TTrack setLocked 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. PointMass listens for the following events: "transform" from TrackerPanel.

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

refreshData

protected void refreshData(DatasetManager data,
                           TrackerPanel trackerPanel)
Refreshes the data.

Overrides:
refreshData in class TTrack
Parameters:
data - the DatasetManager
trackerPanel - the tracker panel

findInteractive

public Interactive findInteractive(DrawingPanel panel,
                                   int xpix,
                                   int ypix)
Finds the interactive drawable object located at the specified pixel position.

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 TPoint that is hit

setLabelsVisible

public void setLabelsVisible(boolean visible)
Sets the visibility of force vector labels.

Parameters:
visible - true to show all labels

isLabelsVisible

public boolean isLabelsVisible()
Gets the labels visibility.

Returns:
true if labels are visible

setVectorsVisible

public void setVectorsVisible(TrackerPanel panel,
                              boolean visible)
Sets the visibility of the vectors on the specified tracker panel.

Parameters:
panel - the tracker panel
visible - true to show vectors

isVectorsVisible

public boolean isVectorsVisible(TrackerPanel trackerPanel)
Gets whether the vectors are visible on the specified panel.

Parameters:
trackerPanel - the tracker panel
Returns:
true if positions are visible

getMenu

public javax.swing.JMenu getMenu(TrackerPanel trackerPanel)
Overrides TTrack getMenu method.

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

getToolbarTrackComponents

public java.util.ArrayList<java.awt.Component> getToolbarTrackComponents(TrackerPanel trackerPanel)
Overrides TTrack getToolbarTrackComponents method.

Overrides:
getToolbarTrackComponents in class TTrack
Parameters:
trackerPanel - the tracker panel
Returns:
the DataSetManager

getToolbarPointComponents

public java.util.ArrayList<java.awt.Component> getToolbarPointComponents(TrackerPanel trackerPanel,
                                                                         TPoint point)
Overrides TTrack getToolbarPointComponents method.

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

toString

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

Overrides:
toString in class TTrack
Returns:
a description of this object

getLoader

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

Returns:
the object loader