org.opensourcephysics.cabrillo.tracker
Class VectorSum

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

public class VectorSum
extends Vector

A VectorSum draws a series of VectorSteps that represent a vector sum of its set of vectors.

Author:
Douglas Brown

Nested Class Summary
 
Nested classes/interfaces inherited from class org.opensourcephysics.cabrillo.tracker.Vector
Vector.FrameData
 
Nested classes/interfaces inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
TTrack.StepArray
 
Field Summary
protected  VectorSumInspector inspector
           
protected  javax.swing.JMenuItem inspectorItem
           
protected  java.util.Map<java.lang.Integer,TPoint> tails
           
protected  java.util.ArrayList<java.lang.String> vectorNames
           
protected  Vector[] vectors
           
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.Vector
labelsVisibleItem, tailsToOriginItem, 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, textColumnEntries, textColumnNames, tField, tLabel, toolbarPointComponents, toolbarTrackComponents, trackerPanel, trailLength, trailVisible, trailVisibleItem, tSeparator, tValueLabel, viewable, visible, visibleItem, worldBounds, xField, xLabel, xSeparator, xSpinner, yField, yLabel, ySeparator, ySpinner
 
Constructor Summary
VectorSum()
          Constructs an empty VectorSum.
VectorSum(Vector[] vectors)
          Constructs a VectorSum with specified vectors.
 
Method Summary
 void addVector(Vector vec)
          Adds a vector to this sum.
protected  void cleanup()
          Cleans up associated resources when this track is deleted or cleared.
 boolean contains(Vector vec)
          Determines if the specified vector is in this sum.
 Step createStep(int n, double x, double y, double xc, double yc)
          Overrides vector method.
 void draw(DrawingPanel panel, java.awt.Graphics _g)
          Overrides Vector draw method.
 Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
          Finds the interactive drawable object located at the specified pixel position.
 VectorSumInspector getInspector()
          Gets the vector sum inspector.
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.
 java.util.ArrayList<java.awt.Component> getToolbarPointComponents(TrackerPanel trackerPanel, TPoint point)
          Overrides TTrack getToolbarPointComponents method.
 Vector[] getVectors()
          Gets the array of vectors in this sum.
 boolean isDependent()
          Overrides TTrack isDependent method to return true.
 boolean isStepComplete(int n)
          Overrides TTrack isStepComplete method.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Responds to property change events.
 void removeVector(Vector vec)
          Removes a vector from this sum.
 void setFontLevel(int level)
          Sets the font level.
 void setLocked(boolean locked)
          Overrides TTrack setLocked method.
 java.lang.String toString()
          Overrides Object toString method.
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.Vector
createStep, getFootprintLength, getStepLength, getToolbarTrackComponents, isLabelsVisible, isVectorsVisible, refreshData, setLabelsVisible, setVectorsVisible
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
addFootprint, addPropertyChangeListener, addPropertyChangeListener, addTextColumn, autoMarkAt, chooseColor, convertTextToDataColumn, 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, getTextColumnEntry, getTextColumnNames, getTrailLength, getWorldBounds, getX, getXMax, getXMax, getXMin, getXMin, getY, getYMax, getYMax, getYMin, getYMin, isAutoAdvance, isAutoTrackable, isAutoTrackable, isEmpty, isEnabled, isLocked, isMarkByDefault, isMeasured, isStepVisible, isTrailVisible, isViewable, isVisible, refreshData, remark, remark, removePropertyChangeListener, removePropertyChangeListener, removeTextColumn, renameTextColumn, repaint, repaint, repaint, setAnglesInRadians, setAutoAdvance, setColor, setColorToDefault, setDefaultNameAndColor, setDescription, setEnabled, setFootprint, setFootprint, setFootprints, setFootprints, setMarkByDefault, setMarking, setName, setProperty, setTargetIndex, setTargetIndex, setTargetIndex, setTextColumnEntry, 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

vectors

protected Vector[] vectors

vectorNames

protected java.util.ArrayList<java.lang.String> vectorNames

inspectorItem

protected javax.swing.JMenuItem inspectorItem

tails

protected java.util.Map<java.lang.Integer,TPoint> tails

inspector

protected VectorSumInspector inspector
Constructor Detail

VectorSum

public VectorSum()
Constructs an empty VectorSum.


VectorSum

public VectorSum(Vector[] vectors)
Constructs a VectorSum with specified vectors.

Parameters:
vectors - an array of vectors
Method Detail

draw

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

Specified by:
draw in interface Drawable
Overrides:
draw in class Vector
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 drawable object located at the specified pixel position.

Specified by:
findInteractive in interface Interactive
Overrides:
findInteractive in class Vector
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

addVector

public void addVector(Vector vec)
Adds a vector to this sum.

Parameters:
vec - the vector

removeVector

public void removeVector(Vector vec)
Removes a vector from this sum.

Parameters:
vec - the vector

getVectors

public Vector[] getVectors()
Gets the array of vectors in this sum.

Returns:
a shallow clone of the vectors array

contains

public boolean contains(Vector vec)
Determines if the specified vector is in this sum.

Parameters:
vec - the vector
Returns:
true if vector is in this sum

createStep

public Step createStep(int n,
                       double x,
                       double y,
                       double xc,
                       double yc)
Overrides vector method. Saves the specified tail position, then updates the step.

Overrides:
createStep in class Vector
Parameters:
n - the frame number
x - the tail x coordinate in image space
y - the tail y coordinate in image space
xc - ignored
yc - ignored
Returns:
the new step

setFontLevel

public void setFontLevel(int level)
Description copied from class: TTrack
Sets the font level.

Overrides:
setFontLevel in class TTrack
Parameters:
level - the desired font level

setLocked

public void setLocked(boolean locked)
Overrides TTrack setLocked method. VectorSum is always locked.

Overrides:
setLocked in class Vector
Parameters:
locked - ignored

isStepComplete

public boolean isStepComplete(int n)
Overrides TTrack isStepComplete method. Always returns true.

Overrides:
isStepComplete in class TTrack
Parameters:
n - the frame number
Returns:
true always since sum gets data from vectors

isDependent

public boolean isDependent()
Overrides TTrack isDependent method to return true.

Overrides:
isDependent in class TTrack
Returns:
true since sum is dependent on its vectors

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Responds to property change events. VectorSum listens for the following events: "track" from tracker panel, "color", "footprint" and "step" from Vector.

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

cleanup

protected void cleanup()
Cleans up associated resources when this track is deleted or cleared.

Overrides:
cleanup in class TTrack

getMenu

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

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

getToolbarPointComponents

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

Overrides:
getToolbarPointComponents in class Vector
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 Vector
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

getInspector

public VectorSumInspector getInspector()
Gets the vector sum inspector.

Returns:
the vector sum inspector