Class ParticleModel

All Implemented Interfaces:
PropertyChangeListener, EventListener, Drawable, Interactive, Measurable, Trackable
Direct Known Subclasses:
AnalyticParticle, DynamicParticle, ParticleDataTrack

public abstract class ParticleModel extends PointMass
An abstract class representing a point mass for which positions are determined by a model. Subclassed as AnalyticParticle, DynamicParticle, and ParticleDataTrack.
Author:
Douglas Brown
  • Field Details

    • tracePtsPerStep

      protected static int tracePtsPerStep
    • loading

      protected static boolean loading
    • nan

      protected static Point2D.Double nan
    • xLimit

      protected static double xLimit
    • yLimit

      protected static double yLimit
    • timeFormat

      protected static NumberFormat timeFormat
    • modelBuilder

      protected ModelBuilder modelBuilder
    • functionPanel

      protected ModelFunctionPanel functionPanel
    • functionEditor

      protected UserFunctionEditor functionEditor
    • inspectorX

      protected int inspectorX
    • inspectorY

      protected int inspectorY
    • inspectorH

      protected int inspectorH
    • showModelBuilder

      protected boolean showModelBuilder
    • refreshing

      protected boolean refreshing
    • traceX

      protected double[] traceX
    • traceY

      protected double[] traceY
    • prevX

      protected double[] prevX
    • prevY

      protected double[] prevY
    • tracePt

      protected TPoint tracePt
    • 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
    • useDefaultReferenceFrame

      protected boolean useDefaultReferenceFrame
    • modelBuilderItem

      protected JMenuItem modelBuilderItem
    • useDefaultRefFrameItem

      protected JMenuItem useDefaultRefFrameItem
    • stampItem

      protected JMenuItem stampItem
    • massParamListener

      protected PropertyChangeListener massParamListener
    • timeParamListener

      protected PropertyChangeListener timeParamListener
    • points

      protected Point2D.Double[] points
    • myPoint

      protected int myPoint
    • nCalc

      protected static int nCalc
  • Constructor Details

    • ParticleModel

      public ParticleModel()
      Constructs a ParticleModel.
  • Method Details

    • initializeFunctionPanel

      protected abstract void initializeFunctionPanel()
      Initializes the ModelFunctionPanel.
    • setLastValidFrame

      protected void setLastValidFrame(int i)
    • getLastValidFrame

      protected int getLastValidFrame()
    • draw

      public void draw(DrawingPanel panel, 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, 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
    • setTrackerPanel

      public void setTrackerPanel(TrackerPanel panel)
      Description copied from class: PointMass
      Adds events for TrackerPanel.
      Overrides:
      setTrackerPanel in class PointMass
      Parameters:
      panel - the new TrackerPanel
    • propertyChange

      public void propertyChange(PropertyChangeEvent e)
      Responds to property change events.
      Specified by:
      propertyChange in interface 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(String name)
      Sets the name. Overrides TTrack method.
      Overrides:
      setName in class TTrack
      Parameters:
      name - the name
    • getDisplayName

      public String getDisplayName()
      Gets a display name for this model. The default is the model 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 TTrack
      Parameters:
      n - the frame number
      Returns:
      true always since gets data from model
    • getMenu

      public JMenu getMenu(TrackerPanel trackerPanel, JMenu menu0)
      Returns a menu with items that control this track.
      Overrides:
      getMenu in class PointMass
      Parameters:
      trackerPanel - the tracker panel
      menu0 - the menu. If null, a dynamic menu is returned that adds items only when selected
      Returns:
      a menu
    • doStamp

      protected void doStamp()
    • getToolbarPointComponents

      public ArrayList<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
    • setAnglesInRadians

      protected void setAnglesInRadians(boolean radians)
      Sets the display format for angles.
      Overrides:
      setAnglesInRadians in class PointMass
      Parameters:
      radians - true for radians, false for degrees
    • reset

      protected abstract 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.
      Returns:
      array of particle models associated with this model
    • isModelsVisible

      protected boolean isModelsVisible()
    • refreshInitialTime

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

      protected void refreshSteps(String why)
      Refreshes step positions.
    • holdPainting

      protected void holdPainting(boolean b)
    • fireStepsChanged

      public void fireStepsChanged()
      Overrides:
      fireStepsChanged in class TTrack
    • createPositionStep

      protected PositionStep createPositionStep(PointMass track, int n, double x, double y)
      Creates a position step with image coordinates. Overridden by ParticleDataTrack.
      Parameters:
      track - the PointMass track
      n - the frame number
      x - the x coordinate
      y - the y coordinate
      Returns:
      the PositionStep
    • refreshDerivsIfNeeded

      protected void refreshDerivsIfNeeded()
      Refreshes the derivatives if they have not been refreshed in the refreshSteps() method (ie if the variable "refreshDerivsLater" 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
    • isUseDefaultReferenceFrame

      protected boolean isUseDefaultReferenceFrame()
      Determines if the default reference frame is used to determine step positions.
      Returns:
      true if the default reference frame is used
    • setUseDefaultReferenceFrame

      public void setUseDefaultReferenceFrame(boolean useDefault)
      Sets the useDefaultReferenceFrame flag.
      Parameters:
      useDefault - true to use the default reference frame
    • getModelBuilder

      public ModelBuilder getModelBuilder()
      Gets the model builder.
      Returns:
      the model builder
    • 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
    • dispose

      public void dispose()
      Description copied from class: TTrack
      Disposes of resources when this track is deleted or cleared.
      Overrides:
      dispose in class PointMass
    • newTimeParam

      public static FunctionEditor.FObject newTimeParam()