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, DynamicTwoBody.Body2

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  UserFunctionEditor functionEditor
           
protected  ModelFunctionPanel functionPanel
           
protected  FunctionTool inspector
           
protected  int inspectorH
           
protected  int inspectorX
           
protected  int inspectorY
           
protected  boolean isInspectorVisible
           
protected  int lastValidFrame
           
protected  double[] prevX
           
protected  double[] prevY
           
protected  boolean refreshing
           
protected  boolean showInspector
           
protected  double t0
           
protected  double time
           
protected  java.awt.geom.GeneralPath trace
           
protected static int[] traceButtonChoices
           
protected static java.lang.String[] traceButtonText
           
protected  TPoint tracePt
           
protected  int tracePtsPerStep
           
protected  java.awt.Stroke traceStroke
           
protected  double[] traceX
           
protected  double[] traceY
           
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.PointMass
aAtOrigin, accelerationMenu, aDeriv, aFootprint, aFootprints, aMap, aTailsToOriginItem, aTailsToPositionItem, aVisibleItem, aVisibleOnAll, aVisMap, colorIndex, colors, dataDescriptions, derivData, labelsVisibleItem, mass, massField, massLabel, mSeparator, names, namesIndex, params, validData, vAtOrigin, vDeriv, velocityMenu, vFootprint, vFootprints, vMap, vTailsToOriginItem, vTailsToPositionItem, vVisibleItem, vVisibleOnAll, vVisMap, xData, xVisibleOnAll, xVisMap, yData
 
Fields inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
angleField, angleLabel, angleSeparator, autoAdvance, autoAdvanceItem, colorItem, data, dataColumnsItem, dataFrames, dataProp, dataValid, defaultColor, defaultFootprint, deleteItem, description, descriptionItem, enabled, fieldBorder, footprint, footprintListener, footprintMenu, footprints, hint, labelFont, locked, lockedItem, magField, magLabel, magSeparator, markByDefault, markByDefaultItem, menu, name, nameAction, nameDialog, nameField, nameItem, panels, partName, point, properties, stepField, stepLabel, steps, stepSeparator, support, tField, tLabel, toolbarPointComponents, toolbarTrackComponents, trackerPanel, trailLength, trailVisible, trailVisibleItem, tSeparator, 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 draw(DrawingPanel panel, java.awt.Graphics _g)
          Overrides PointMass draw method.
 Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
          Overrides PointMass findInteractive method.
 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.
 ParamEditor getParamEditor()
          Gets the parameter editor.
protected  ParticleModel[] getParticles()
          Gets the next trace positions.
 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.
protected  void initializeFunctionPanel()
          Initializes the ModelFunctionPanel.
 boolean isDependent()
          Overrides TTrack method to report that this is a dependent track.
 boolean isStepComplete(int n)
          Overrides TTrack isStepComplete method.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Responds to property change events.
protected  void refreshSteps()
          Refreshes step positions.
 void setLocked(boolean locked)
          Overrides TTrack setLocked method.
 void setMass(double mass)
          Sets the mass.
 void setName(java.lang.String name)
          Sets the name.
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.PointMass
createStep, deleteStep, erase, erase, getAArray, getAcceleration, getAccelerationFootprint, getAccelerationFootprints, getAccelerations, getDataDescription, getFootprint, getFootprintLength, getFootprints, getNextVisibleStep, getPreviousVisibleStep, getRotationData, getStep, getVArray, getVelocities, getVelocity, getVelocityFootprint, getVelocityFootprints, getWorldAcceleration, getWorldPosition, getWorldVelocity, isAcceleration, isAVisible, isLabelsVisible, isPosition, isPositionVisible, isStepVisible, isVelocity, isVVisible, refreshData, remark, remark, setAccelerationFootprint, setAccelerationFootprints, setAVisible, setAVisibleOnAll, setColor, setFootprint, setLabelsVisible, setPositionVisible, setPositionVisibleOnAll, setVelocityFootprint, setVelocityFootprints, setVVisible, setVVisibleOnAll, toString, updateDerivatives, updateDerivatives
 
Methods inherited from class org.opensourcephysics.cabrillo.tracker.TTrack
addFootprint, addPropertyChangeListener, addPropertyChangeListener, delete, firePropertyChange, getColor, getData, getDataName, getDescription, getFootprint, getFootprints, getFrameForData, getMessage, getName, getProperty, getPropertyNames, getStep, getSteps, getTrailLength, getWorldBounds, getX, getXMax, getXMax, getXMin, getXMin, getY, getYMax, getYMax, getYMin, getYMin, isAutoAdvance, isEmpty, isEnabled, isLocked, isMarkByDefault, isMeasured, isTrailVisible, isViewable, isVisible, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, setAutoAdvance, setDescription, setEnabled, setFootprint, setFootprints, setFootprints, setMarkByDefault, setProperty, 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

traceButtonChoices

protected static int[] traceButtonChoices

traceButtonText

protected static java.lang.String[] traceButtonText

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

isInspectorVisible

protected boolean isInspectorVisible

refreshing

protected boolean refreshing

traceX

protected double[] traceX

traceY

protected double[] traceY

prevX

protected double[] prevX

prevY

protected double[] prevY

tracePt

protected TPoint tracePt

trace

protected java.awt.geom.GeneralPath trace

traceStroke

protected java.awt.Stroke traceStroke

tracePtsPerStep

protected int tracePtsPerStep

lastValidFrame

protected int lastValidFrame

t0

protected double t0

dt

protected double dt

time

protected double time
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

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

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 TTrack
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

getToolbarTrackComponents

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

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

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

cleanup

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

Overrides:
cleanup in class TTrack

getParticles

protected ParticleModel[] getParticles()
Gets the next trace positions. Subclasses override to get positions based on model.


refreshSteps

protected void refreshSteps()
Refreshes step positions.


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