org.opensourcephysics.cabrillo.tracker
Class ParticleModel

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

public abstract class ParticleModel
extends PointMass

A ParticleModel is a point mass whose positions are determined by a model.

Author:
Douglas Brown

Nested Class Summary
 
Nested classes/interfaces inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
TTrack.StepArray
 
Field Summary
protected  double dt
           
protected  int endFrame
           
protected  UserFunctionEditor functionEditor
           
protected  ModelFunctionPanel functionPanel
           
protected  FunctionTool inspector
           
protected  int inspectorH
           
protected  int inspectorX
           
protected  int inspectorY
           
protected  boolean invalidWarningShown
           
protected  int lastValidFrame
           
protected static boolean loading
           
protected static java.awt.geom.Point2D nan
           
protected  double[] prevX
           
protected  double[] prevY
           
protected  boolean refreshDerivsLater
           
protected  boolean refreshing
           
protected  boolean refreshStepsLater
           
protected  boolean showInspector
           
protected  int startFrame
           
protected  boolean startFrameUndefined
           
protected  double t0
           
protected  double time
           
protected static java.text.NumberFormat timeFormat
           
protected  TPoint tracePt
           
protected static int tracePtsPerStep
           
protected  double[] traceX
           
protected  double[] traceY
           
protected static double xLimit
           
protected static double yLimit
           
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.PointMass
aAtOrigin, accelerationMenu, accelFootprintMenu, aDeriv, aDerivSpill, aFootprint, aFootprints, aMap, aTailsToOriginItem, aTailsToPositionItem, autotrackItem, aVisibleItem, aVisibleOnAll, aVisMap, dataDescriptions, derivData, mass, massField, massLabel, mSeparator, params, positionFootprintMenu, trace, traceStroke, traceVisible, validData, vAtOrigin, vDeriv, vDerivSpill, velocFootprintMenu, velocityMenu, vFootprint, vFootprints, vMap, vTailsToOriginItem, vTailsToPositionItem, vVisibleItem, vVisibleOnAll, vVisMap, xData, xVisibleOnAll, xVisMap, yData
 
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
ParticleModel()
          Constructs a ParticleModel.
 
Method Summary
protected  void cleanup()
          Cleans up associated resources when this track is deleted or cleared.
protected  void createMassAndTimeParameters()
          This adds the mass and initial time parameters to the function panel.
 void delete()
          Removes this particle from all panels that draw it.
 void draw(DrawingPanel panel, java.awt.Graphics _g)
          Overrides PointMass draw method.
 void drawMe(DrawingPanel panel, java.awt.Graphics _g)
          Draws this without refreshing steps.
 Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
          Overrides PointMass findInteractive method.
 java.lang.String getDisplayName()
          Gets a display name for this model.
 int getEndFrame()
          Gets the end frame for this model.
 UserFunctionEditor getFunctionEditor()
          Gets the function editor.
 InitialValueEditor getInitEditor()
          Gets the initial value editor.
 double[] getInitialValues()
          Gets the initial values.
 FunctionTool getInspector()
          Gets the particle inspector.
static XML.ObjectLoader getLoader()
          Returns an ObjectLoader to save and load data for this class.
 double getMass()
          Gets the mass.
 javax.swing.JMenu getMenu(TrackerPanel trackerPanel)
          Returns a menu with items that control this track.
protected  ParticleModel[] getModels()
          Gets the particle models associated with this model.
 ParamEditor getParamEditor()
          Gets the parameter editor.
 int getStartFrame()
          Gets the start frame for this model.
 java.util.ArrayList<java.awt.Component> getToolbarPointComponents(TrackerPanel trackerPanel, TPoint point)
          Overrides TTrack getToolbarPointComponents method.
protected  void initializeFunctionPanel()
          Initializes the ModelFunctionPanel.
protected  boolean isAutoTrackable()
          Determines if any point in this track is autotrackable.
 boolean isDependent()
          Overrides TTrack method to report that this is a dependent track.
protected  boolean isModelsVisible()
           
 boolean isStepComplete(int n)
          Overrides TTrack isStepComplete method.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Responds to property change events.
protected  void refreshDerivsIfNeeded()
          Refreshes the derivatives if they have not been refreshed in the refreshSteps() method (ie if the variable "refreshDerivs" is false).
protected  void refreshInitialTime()
          Refreshes initial time parameter for this model.
protected  void refreshSteps()
          Refreshes step positions.
protected  void reset()
          Resets model parameters and sets position(s) for start frame.
protected  boolean restoreState(int frameNumber)
          Restores the state to a previously saved state, if any.
protected  void saveState(int frameNumber)
          Saves the current state.
protected  void setAnglesInRadians(boolean radians)
          Sets the display format for angles.
 void setEndFrame(int n)
          Sets the end frame for this model.
 void setLocked(boolean locked)
          Overrides TTrack setLocked method.
 void setMass(double mass)
          Sets the mass.
 void setName(java.lang.String name)
          Sets the name.
 void setStartFrame(int n)
          Sets the start frame for this model.
protected  void setTrackerPanel(TrackerPanel panel)
          Identifies the controlling TrackerPanel for this track (by default, the first TrackerPanel that adds this track to its drawables).
protected  void trimSteps()
          Trims all steps after endFrame.
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.PointMass
createGUI, createStep, deleteStep, erase, erase, getAArray, getAcceleration, getAccelerationFootprint, getAccelerationFootprints, getAccelerations, getDataDescription, getDefaultAutoTrackerIndex, getFootprint, getFootprintLength, getFootprints, getNextVisibleStep, getPreviousVisibleStep, getRotationData, getRotationData, getStep, getStepLength, getTargetDescription, getToolbarTrackComponents, getVArray, getVelocities, getVelocity, getVelocityFootprint, getVelocityFootprints, getWorldAcceleration, getWorldPosition, getWorldVelocity, isAcceleration, isAVisible, isLabelsVisible, isPosition, isPositionVisible, isStepVisible, isTraceVisible, isVelocity, isVVisible, refreshData, remark, remark, setAccelerationFootprint, setAccelerationFootprints, setAVisible, setAVisibleOnAll, setColor, setFootprint, setLabelsVisible, setPositionVisible, setPositionVisibleOnAll, setTraceVisible, setVelocityFootprint, setVelocityFootprints, setVVisible, setVVisibleOnAll, updateDerivatives, updateDerivatives, updateDerivatives, updateDerivatives, updateDerivatives, updateDerivatives
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
addFootprint, addPropertyChangeListener, addPropertyChangeListener, autoMarkAt, createWarningDialog, firePropertyChange, getColor, getData, getDataName, getDescription, getFootprint, getFootprints, getFrameForData, getMarkedPoint, getMarkingCursor, getMessage, getName, getPreferredDataOrder, getProperty, getPropertyNames, getSkippedStepWarningDialog, getStep, getSteps, getStepSizeWarningDialog, getTargetIndex, getTrailLength, getWorldBounds, getX, getXMax, getXMax, getXMin, getXMin, getY, getYMax, getYMax, getYMin, getYMin, isAutoAdvance, isAutoTrackable, isEmpty, isEnabled, isLocked, isMarkByDefault, isMeasured, isTrailVisible, isViewable, isVisible, refreshData, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, setAutoAdvance, setColorToDefault, setDefaultNameAndColor, setDescription, setEnabled, setFootprint, setFootprints, setFootprints, setMarkByDefault, setMarking, setProperty, setTargetIndex, setTargetIndex, setTargetIndex, setTrailLength, setTrailVisible, setViewable, setVisible, setX, setXY, setY, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tracePtsPerStep

protected static int tracePtsPerStep

loading

protected static boolean loading

nan

protected static java.awt.geom.Point2D nan

xLimit

protected static double xLimit

yLimit

protected static double yLimit

timeFormat

protected static java.text.NumberFormat timeFormat

inspector

protected FunctionTool inspector

functionPanel

protected ModelFunctionPanel functionPanel

functionEditor

protected UserFunctionEditor functionEditor

inspectorX

protected int inspectorX

inspectorY

protected int inspectorY

inspectorH

protected int inspectorH

showInspector

protected boolean showInspector

refreshing

protected boolean refreshing

traceX

protected double[] traceX

traceY

protected double[] traceY

prevX

protected double[] prevX

prevY

protected double[] prevY

tracePt

protected TPoint tracePt

lastValidFrame

protected int lastValidFrame

t0

protected double t0

dt

protected double dt

time

protected double time

refreshDerivsLater

protected boolean refreshDerivsLater

refreshStepsLater

protected boolean refreshStepsLater

invalidWarningShown

protected boolean invalidWarningShown

startFrameUndefined

protected boolean startFrameUndefined

startFrame

protected int startFrame

endFrame

protected int endFrame
Constructor Detail

ParticleModel

public ParticleModel()
Constructs a ParticleModel.

Method Detail

draw

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

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

drawMe

public void drawMe(DrawingPanel panel,
                   java.awt.Graphics _g)
Draws this without refreshing steps.

Parameters:
panel - the drawing panel requesting the drawing
_g - the graphics context on which to draw

delete

public void delete()
Removes this particle from all panels that draw it. Overrides TTrack method.

Overrides:
delete in class TTrack

propertyChange

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

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

getMass

public double getMass()
Gets the mass. Overrides PointMass method.

Overrides:
getMass in class PointMass
Returns:
the mass

setMass

public void setMass(double mass)
Sets the mass. Overrides PointMass method.

Overrides:
setMass in class PointMass
Parameters:
mass - the mass

setName

public void setName(java.lang.String name)
Sets the name. Overrides TTrack method.

Overrides:
setName in class TTrack
Parameters:
name - the name

getDisplayName

public java.lang.String getDisplayName()
Gets a display name for this model. The default is the track name.

Returns:
the display name

isAutoTrackable

protected boolean isAutoTrackable()
Determines if any point in this track is autotrackable.

Overrides:
isAutoTrackable in class PointMass
Returns:
true if autotrackable

findInteractive

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

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

setLocked

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

Overrides:
setLocked in class TTrack
Parameters:
locked - ignored

isDependent

public boolean isDependent()
Overrides TTrack method to report that this is a dependent track.

Overrides:
isDependent in class TTrack
Returns:
true if this track is dependent

isStepComplete

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

Overrides:
isStepComplete in class PointMass
Parameters:
n - the frame number
Returns:
true always since gets data from model

getMenu

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

Overrides:
getMenu in class PointMass
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 PointMass
Parameters:
trackerPanel - the tracker panel
point - the TPoint
Returns:
a list of components

setStartFrame

public void setStartFrame(int n)
Sets the start frame for this model. Also sets the initial time to the video clip time at the start frame.

Parameters:
n - the desired start frame

getStartFrame

public int getStartFrame()
Gets the start frame for this model.

Returns:
the start frame

setEndFrame

public void setEndFrame(int n)
Sets the end frame for this model.

Parameters:
n - the desired end frame

getEndFrame

public int getEndFrame()
Gets the end frame for this model.

Returns:
the end frame

setTrackerPanel

protected void setTrackerPanel(TrackerPanel panel)
Identifies the controlling TrackerPanel for this track (by default, the first TrackerPanel that adds this track to its drawables).

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

setAnglesInRadians

protected void setAnglesInRadians(boolean radians)
Sets the display format for angles.

Overrides:
setAnglesInRadians in class TTrack
Parameters:
radians - true for radians, false for degrees

cleanup

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

Overrides:
cleanup in class PointMass

reset

protected void reset()
Resets model parameters and sets position(s) for start frame. Most of the work in this method must be done by subclasses.


getModels

protected ParticleModel[] getModels()
Gets the particle models associated with this model. By default this model is returned.


isModelsVisible

protected boolean isModelsVisible()

refreshInitialTime

protected void refreshInitialTime()
Refreshes initial time parameter for this model.


refreshSteps

protected void refreshSteps()
Refreshes step positions.


refreshDerivsIfNeeded

protected void refreshDerivsIfNeeded()
Refreshes the derivatives if they have not been refreshed in the refreshSteps() method (ie if the variable "refreshDerivs" is false).


trimSteps

protected void trimSteps()
Trims all steps after endFrame.


saveState

protected void saveState(int frameNumber)
Saves the current state. Does nothing by default, but DynamicParticle overrides.

Parameters:
frameNumber - the frame number

restoreState

protected boolean restoreState(int frameNumber)
Restores the state to a previously saved state, if any. Does nothing by default, but DynamicParticle overrides.

Parameters:
frameNumber - the frame number
Returns:
true if state successfully restored

getInspector

public FunctionTool getInspector()
Gets the particle inspector.

Returns:
the inspector

initializeFunctionPanel

protected void initializeFunctionPanel()
Initializes the ModelFunctionPanel. The panel must created by subclasses before calling this method.


createMassAndTimeParameters

protected void createMassAndTimeParameters()
This adds the mass and initial time parameters to the function panel.


getInitialValues

public double[] getInitialValues()
Gets the initial values.

Returns:
initial values

getParamEditor

public ParamEditor getParamEditor()
Gets the parameter editor.

Returns:
ParamEditor

getInitEditor

public InitialValueEditor getInitEditor()
Gets the initial value editor.

Returns:
the editor

getFunctionEditor

public UserFunctionEditor getFunctionEditor()
Gets the function editor.

Returns:
UserFunctionEditor

getLoader

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

Returns:
the object loader