Class PointMass

All Implemented Interfaces:
PropertyChangeListener, EventListener, Drawable, Interactive, Measurable, Trackable
Direct Known Subclasses:
CenterOfMass, ParticleModel

public class PointMass extends TTrack
A PointMass tracks the position, velocity and acceleration of a point mass.
Author:
Douglas Brown
  • Field Details

    • FINITE_DIFF

      protected static final int FINITE_DIFF
      See Also:
    • BOUNCE_DETECT

      protected static final int BOUNCE_DETECT
      See Also:
    • FINITE_DIFF_VSPILL2

      protected static final int FINITE_DIFF_VSPILL2
      See Also:
    • MINIMUM_MASS

      protected static final double MINIMUM_MASS
      See Also:
    • vDeriv

      protected static final Derivative vDeriv
    • aDeriv

      protected static final Derivative aDeriv
    • bounceDerivs

      protected static final BounceDerivatives bounceDerivs
    • dataVariables

      protected static final String[] dataVariables
    • fieldVariables

      protected static final String[] fieldVariables
    • formatVariables

      protected static final String[] formatVariables
    • formatMap

      protected static final Map<String,String[]> formatMap
    • formatDescriptionMap

      protected static final Map<String,String> formatDescriptionMap
    • footprintNames

      protected static final String[] footprintNames
    • allVariables

      protected static final ArrayList<String> allVariables
    • isAutoKeyDown

      protected static boolean isAutoKeyDown
    • mass

      protected double mass
    • vFootprints

      protected Footprint[] vFootprints
    • vFootprint

      protected Footprint vFootprint
    • aFootprints

      protected Footprint[] aFootprints
    • aFootprint

      protected Footprint aFootprint
    • xVisibleOnAll

      protected boolean xVisibleOnAll
    • vVisibleOnAll

      protected boolean vVisibleOnAll
    • aVisibleOnAll

      protected boolean aVisibleOnAll
    • labelsVisible

      protected boolean labelsVisible
    • algorithm

      protected int algorithm
    • vDerivSpill

      protected int vDerivSpill
    • aDerivSpill

      protected int aDerivSpill
    • bounceDerivsSpill

      protected int bounceDerivsSpill
    • params

      protected int[] params
    • xData

      protected double[] xData
    • yData

      protected double[] yData
    • validData

      protected boolean[] validData
    • derivData

      protected Object[] derivData
    • skippedSteps

      protected TreeSet<Integer> skippedSteps
    • isAutofill

      protected boolean isAutofill
    • showfilledSteps

      protected boolean showfilledSteps
    • vectorFields

      protected NumberField[][] vectorFields
    • massLabel

      protected JLabel massLabel
    • massField

      protected NumberField massField
    • mSeparator

      protected Component mSeparator
    • velocityMenu

      protected JMenu velocityMenu
    • accelerationMenu

      protected JMenu accelerationMenu
    • vColorItem

      protected JMenuItem vColorItem
    • aColorItem

      protected JMenuItem aColorItem
    • vFootprintMenu

      protected JMenu vFootprintMenu
    • aFootprintMenu

      protected JMenu aFootprintMenu
    • vTailsToOriginItem

      protected JMenuItem vTailsToOriginItem
    • vTailsToPositionItem

      protected JMenuItem vTailsToPositionItem
    • aTailsToOriginItem

      protected JMenuItem aTailsToOriginItem
    • aTailsToPositionItem

      protected JMenuItem aTailsToPositionItem
    • autotrackItem

      protected JMenuItem autotrackItem
    • vVisibleItem

      protected JCheckBoxMenuItem vVisibleItem
    • aVisibleItem

      protected JCheckBoxMenuItem aVisibleItem
    • vAtOrigin

      protected boolean vAtOrigin
    • aAtOrigin

      protected boolean aAtOrigin
    • traceVisible

      protected boolean traceVisible
    • trace

      protected GeneralPath trace
    • traceStroke

      protected Stroke traceStroke
    • drawsTrace

      protected boolean drawsTrace
    • loading

      protected boolean loading
  • Constructor Details

    • PointMass

      public PointMass()
      Constructs a PointMass with mass 1.0.
    • PointMass

      public PointMass(double mass)
      Constructs a PointMass with specified mass.
      Parameters:
      mass - the mass
  • Method Details

    • getFormatVariables

      public String[] getFormatVariables()
      Specified by:
      getFormatVariables in class TTrack
    • getFormatMap

      public Map<String,String[]> getFormatMap()
      Specified by:
      getFormatMap in class TTrack
    • getFormatDescMap

      public Map<String,String> getFormatDescMap()
      Specified by:
      getFormatDescMap in class TTrack
    • getBaseType

      public String getBaseType()
      Specified by:
      getBaseType in class TTrack
    • getVarDimsImpl

      public String getVarDimsImpl(String v)
      Specified by:
      getVarDimsImpl in class TTrack
    • setColor

      public void setColor(Color color)
      Overrides TTrack setColor method.
      Overrides:
      setColor in class TTrack
      Parameters:
      color - the desired color
    • setVelocityColor

      public void setVelocityColor(Color color)
      Sets the velocity color.
      Parameters:
      color - the desired color
    • setAccelerationColor

      public void setAccelerationColor(Color color)
      Sets the acceleration color.
      Parameters:
      color - the desired color
    • createStep

      public Step createStep(int n, double x, double y)
      Creates a new position step.
      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
    • deleteStep

      public Step deleteStep(int n)
      Overrides TTrack deleteStep method.
      Overrides:
      deleteStep in class TTrack
      Parameters:
      n - the frame number
      Returns:
      the deleted step
    • deleteAutoTrackerStep

      protected void deleteAutoTrackerStep(int n)
    • getStep

      public Step getStep(TPoint point, TrackerPanel panel)
      Overrides TTrack getStep method.
      Overrides:
      getStep in class TTrack
      Parameters:
      point - a TPoint
      panel - the tracker panel
      Returns:
      the step containing the TPoint
    • getNextVisibleStep

      public Step getNextVisibleStep(Step step, TrackerPanel panel)
      Gets next step after the specified step. May return null.
      Overrides:
      getNextVisibleStep in class TTrack
      Parameters:
      step - the step
      panel - the tracker panel
      Returns:
      the next step
    • getPreviousVisibleStep

      public Step getPreviousVisibleStep(Step step, TrackerPanel panel)
      Gets step before the specified step. May return null.
      Overrides:
      getPreviousVisibleStep in class TTrack
      Parameters:
      step - the step
      panel - the tracker panel
      Returns:
      the previous 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
    • isAutoTrackable

      protected boolean isAutoTrackable()
      Determines if any point in this track is autotrackable.
      Overrides:
      isAutoTrackable in class TTrack
      Returns:
      true if autotrackable
    • autoMarkAt

      public TPoint autoMarkAt(int n, double x, double y)
      Description copied from class: TTrack
      Used by autoTracker to mark a step at a match target position.
      Overrides:
      autoMarkAt in class TTrack
      Parameters:
      n - the frame number
      x - the x target coordinate in image space
      y - the y target coordinate in image space
      Returns:
      the TPoint that was automarked
    • getFootprintLength

      public int getFootprintLength()
      Gets the length of the footprints required by this track.
      Specified by:
      getFootprintLength in class TTrack
      Returns:
      the footprint length
    • getVelocityFootprints

      public Footprint[] getVelocityFootprints()
      Gets the velocity footprint choices.
      Returns:
      the velocity footprint choices
    • setVelocityFootprints

      public void setVelocityFootprints(Footprint[] choices)
      Sets the velocity footprint choices.
      Parameters:
      choices - the velocity footprint choices
    • getVelocityFootprint

      public Footprint getVelocityFootprint()
      Gets the current velocity footprint.
      Returns:
      the velocity footprint
    • setVelocityFootprint

      public void setVelocityFootprint(String name)
      Sets the velocity footprint.
      Parameters:
      name - the name of the desired footprint
    • getAccelerationFootprints

      public Footprint[] getAccelerationFootprints()
      Gets the acceleration footprint choices.
      Returns:
      the acceleration footprint choices
    • setAccelerationFootprints

      public void setAccelerationFootprints(Footprint[] choices)
      Sets the acceleration footprint choices.
      Parameters:
      choices - the acceleration footprint choices
    • getAccelerationFootprint

      public Footprint getAccelerationFootprint()
      Gets the current acceleration footprint.
      Returns:
      the acceleration footprint
    • setAccelerationFootprint

      public void setAccelerationFootprint(String name)
      Sets the acceleration footprint.
      Parameters:
      name - the name of the desired footprint
    • getFootprints

      public Footprint[] getFootprints(Step step)
      Gets the footprint choices. Overrides TTrack.
      Overrides:
      getFootprints in class TTrack
      Parameters:
      step - the step that identifies the step array
      Returns:
      the array of Footprints available
    • setFootprint

      public void setFootprint(String name, Step step)
      Sets the footprint to the specified choice. Overrides TTrack.
      Overrides:
      setFootprint in class TTrack
      Parameters:
      name - the name of the desired footprint
      step - the step that identifies the step array
    • getFootprint

      public Footprint getFootprint(Step step)
      Gets the current footprint of the specified step. Overrides TTrack.
      Overrides:
      getFootprint in class TTrack
      Parameters:
      step - the step that identifies the step array
      Returns:
      the footprint
    • setMarking

      protected void setMarking(boolean marking)
      Sets the marking flag. Flag should be true when ready to be marked by user.
      Overrides:
      setMarking in class TTrack
      Parameters:
      marking - true when marking
    • getMass

      public double getMass()
      Gets the mass.
      Returns:
      the mass
    • setMass

      public void setMass(double mass)
      Sets the mass.
      Parameters:
      mass - the mass
    • setFontLevel

      public void setFontLevel(int level)
      Sets the font level.
      Overrides:
      setFontLevel in class TTrack
      Parameters:
      level - the desired font level
    • getWorldPosition

      public Point2D getWorldPosition(int n, TrackerPanel panel)
      Gets the world position for the specified frame number and panel. May return null;
      Parameters:
      n - the frame number
      panel - the tracker panel
      Returns:
      a Point2D containing the position components
    • getWorldVelocity

      public Point2D getWorldVelocity(int n, TrackerPanel panel)
      Gets the world velocity for the specified frame number and panel. May return null;
      Parameters:
      n - the frame number
      panel - the tracker panel
      Returns:
      a Point2D containing the velocity components
    • getWorldAcceleration

      public Point2D getWorldAcceleration(int n, Integer panelID)
      Gets the world acceleration for the specified frame number and panel. May return null.
      Parameters:
      n - the frame number
      panel - the tracker panel
      Returns:
      a Point2D containing the acceleration components
    • setAlgorithm

      public void setAlgorithm(int type)
      Sets the derivative algorithm type. Defined types: FINITE_DIFF, BOUNCE_DETECT
      Parameters:
      type - one of the defined algorithm types
    • isAutofill

      public boolean isAutofill()
      Gets the autofill flag.
      Returns:
      true if autofill is on
    • setAutoFill

      public void setAutoFill(boolean autofill)
      Sets the autofill flag.
      Parameters:
      autofill - true to turn on autofill
    • hasGaps

      public boolean hasGaps()
      Returns the number of gaps (filled or not) in the keyframes
      Returns:
      the gap count
    • getUnfilledGapCount

      public int getUnfilledGapCount(boolean emptyGapsOnly)
      Returns the number of unfilled gaps in the keyframes
      Returns:
      the unfilled gap count
    • markAllInterpolatedSteps

      public void markAllInterpolatedSteps()
      Marks all missing steps by linear interpolation.
    • markInterpolatedSteps

      public void markInterpolatedSteps(PositionStep step, boolean refreshData)
      Marks steps by linear interpolation on both sides of a given step.
      Parameters:
      step - the step
      refreshData - true to update derivatives
    • markInterpolatedSteps

      public boolean markInterpolatedSteps(PositionStep startStep, PositionStep endStep)
      Marks steps by linear interpolation between two existing steps. Removes steps if isAutofill is false.
      Parameters:
      startStep - the start step
      endStep - the end step
      Returns:
      true if changed (step added or removed)
    • dispose

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

      protected String getTargetDescription(int pointIndex)
      Returns a description of the point at a given index. Used by AutoTracker.
      Overrides:
      getTargetDescription in class TTrack
      Parameters:
      pointIndex - the points[] index
      Returns:
      the description
    • refreshData

      protected void refreshData(DatasetManager data, TrackerPanel panel)
      Refreshes the data.
      Overrides:
      refreshData in class TTrack
      Parameters:
      data - the DatasetManager
      panel - the tracker panel
    • draw

      public void draw(DrawingPanel dp, Graphics _g)
      Overrides TTrack draw method.
      Specified by:
      draw in interface Drawable
      Overrides:
      draw in class TTrack
      Parameters:
      dp - the drawing panel requesting the drawing
      _g - the graphics context on which to draw
    • findInteractive

      public Interactive findInteractive(DrawingPanel dp, int xpix, int ypix)
      Overrides TTrack findInteractive method.
      Specified by:
      findInteractive in interface Interactive
      Overrides:
      findInteractive in class TTrack
      Parameters:
      dp - 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
    • setVisible

      public void setVisible(boolean visible)
      Shows and hides this track.
      Overrides:
      setVisible in class TTrack
      Parameters:
      visible - true to show this track
    • isStepVisible

      public boolean isStepVisible(Step step, TrackerPanel panel)
      Reports whether or not the specified step is visible.
      Overrides:
      isStepVisible in class TTrack
      Parameters:
      step - the step
      panel - the tracker panel
      Returns:
      true if the step is visible
    • setVVisibleOnAll

      public void setVVisibleOnAll(boolean visible)
      Sets whether velocities are visible on all tracker panels.
      Parameters:
      visible - true to show velocities
    • setVVisible

      public void setVVisible(TrackerPanel panel, boolean visible)
      Shows and hides velocities on the specified panel.
      Parameters:
      panel - the tracker panel
      visible - true to show velocities
    • isVVisible

      public boolean isVVisible()
      Gets whether the velocities are visible on the specified panel.
      Parameters:
      panel - the tracker panel
      Returns:
      true if velocities are visible
    • setPositionVisibleOnAll

      public void setPositionVisibleOnAll(boolean visible)
      Sets whether positions are visible on all tracker panels.
      Parameters:
      visible - true to show positions
    • setTraceVisible

      public void setTraceVisible(boolean visible)
      Sets whether traces are visible.
      Parameters:
      visible - true to show traces
    • isTraceVisible

      public boolean isTraceVisible()
      Gets trace visibility.
      Returns:
      true if traces are visible
    • isPosition

      public boolean isPosition(Step step)
      Determines whether the specified step is a position step.
      Parameters:
      step - the step
      Returns:
      true if the step is a position
    • setPositionVisible

      public void setPositionVisible(TrackerPanel panel, boolean visible)
      Shows and hides positions on the specified panel.
      Parameters:
      panel - the tracker panel
      visible - true to show positions
    • isPositionVisible

      public boolean isPositionVisible()
      Gets whether the positions are visible on the specified panel.
      Parameters:
      panel - the tracker panel
      Returns:
      true if positions are visible
    • getVelocity

      public VectorStep getVelocity(int n, Integer panelID)
      Gets the velocity for the specified frame number and panel.
      Parameters:
      n - the frame number
      panel - the tracker panel
      Returns:
      the velocity
    • getVelocities

      public Step[] getVelocities(Integer panelID)
      Gets the velocity step array for the specified panel.
      Parameters:
      panel - the tracker panel
      Returns:
      the velocity step array
    • isVelocity

      public boolean isVelocity(Step step)
      Determines whether the specified step is a velocity step for this point mass.
      Parameters:
      step - the step
      Returns:
      true if the step is a velocity VectorStep
    • setAVisibleOnAll

      public void setAVisibleOnAll(boolean visible)
      Sets whether accelerations are visible on all tracker panels.
      Parameters:
      visible - true to show accelerations
    • setAVisible

      public void setAVisible(TrackerPanel panel, boolean visible)
      Shows and hides accelerations on the specified panel.
      Parameters:
      panel - the tracker panel
      visible - true to show accelerations
    • isAVisible

      public boolean isAVisible()
      Gets whether the accelerations are visible on the specified panel.
      Parameters:
      panel - the tracker panel
      Returns:
      true if accelerations are visible
    • getAcceleration

      public VectorStep getAcceleration(int n, Integer panelID)
      Gets the acceleration for the specified frame number and panel.
      Parameters:
      n - the frame number
      panel - the tracker panel
      Returns:
      the acceleration vector
    • getAccelerations

      public Step[] getAccelerations(Integer panelID)
      Gets the acceleration step array for the specified panel.
      Parameters:
      panel - the tracker panel
      Returns:
      the acceleration step array
    • isAcceleration

      public boolean isAcceleration(Step step)
      Determines whether the specified step is an acceleration step for this point mass.
      Parameters:
      step - the step
      Returns:
      true if the step is an acceleration VectorStep
    • setLabelsVisible

      public void setLabelsVisible(TrackerPanel panel, boolean visible)
      Sets the visibility of labels.
      Parameters:
      panel - a tracker panel
      visible - true to show all labels
    • isLabelsVisible

      public boolean isLabelsVisible(TrackerPanel panel)
      Gets the labels visibility.
      Parameters:
      panel - the tracker panel
      Returns:
      true if labels are visible
    • getNumberFieldsForStep

      protected NumberField[] getNumberFieldsForStep(Step step)
      Description copied from class: TTrack
      Returns an array of NumberFields {x, y, magnitude, angle} for a given step.
      Overrides:
      getNumberFieldsForStep in class TTrack
      Parameters:
      step - the step
      Returns:
      the number fields
    • setAnglesInRadians

      protected void setAnglesInRadians(boolean radians)
      Description copied from class: TTrack
      Sets the display format for angles.
      Overrides:
      setAnglesInRadians in class TTrack
      Parameters:
      radians - true for radians, false for degrees
    • updateDerivatives

      protected void updateDerivatives()
      Updates all velocity and acceleration steps on all TrackerPanels.
    • updateDerivatives

      protected void updateDerivatives(int startFrame, int stepCount)
      Updates velocity and acceleration steps for a specified start frame and step count.
      Parameters:
      startFrame - the start frame
      stepCount - the step count
    • updateDerivatives

      protected void updateDerivatives(int frameNumber)
      Updates velocity and acceleration steps around a give frame number.
      Parameters:
      frameNumber - the frame number
    • updateDerivatives

      protected void updateDerivatives(TrackerPanel panel, int frameNumber)
      Updates velocity and acceleration steps around a give frame number on a TrackerPanel.
      Parameters:
      panel - the TrackerPanel
      frameNumber - the frame number
    • updateDerivatives

      protected void updateDerivatives(TrackerPanel panel, int startFrame, int stepCount)
      Updates velocity and acceleration steps for a specified start frame and step count.
      Parameters:
      panel - the TrackerPanel
      startFrame - the start frame
      stepCount - the step count
    • getRotationData

      protected Object[] getRotationData()
      Gets the rotational data.
      Returns:
      Object[] {theta, omega, alpha}
    • getRotationData

      protected Object[] getRotationData(int startFrame, int stepCount)
      Gets the rotational data for a range of frame numbers.
      Parameters:
      startFrame - the start frame
      stepCount - the number of steps
      Returns:
      Object[] {theta, omega, alpha}
    • erase

      public void erase()
      Overrides TTrack erase method to include v and a.
      Overrides:
      erase in class TTrack
    • remark

      public void remark()
      Overrides TTrack remark method.
      Overrides:
      remark in class TTrack
    • erase

      public void erase(Integer panelID)
      Overrides TTrack erase method.
      Overrides:
      erase in class TTrack
      Parameters:
      panel - the tracker panel
    • remark

      public void remark(Integer panelID)
      Overrides TTrack remark method.
      Overrides:
      remark in class TTrack
      Parameters:
      panel - the tracker panel
    • setTrackerPanel

      public void setTrackerPanel(TrackerPanel panel)
      Adds events for TrackerPanel.
      Overrides:
      setTrackerPanel in class TTrack
      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 TTrack
      Parameters:
      e - the property change event
    • getMenu

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

      public ArrayList<Component> getToolbarTrackComponents(TrackerPanel panel)
      Overrides TTrack getToolbarTrackComponents method.
      Overrides:
      getToolbarTrackComponents in class TTrack
      Parameters:
      panel - the tracker panel
      Returns:
      a list of components
    • getToolbarPointComponents

      public ArrayList<Component> getToolbarPointComponents(TrackerPanel panel, TPoint point)
      Overrides TTrack getToolbarPointComponents method.
      Overrides:
      getToolbarPointComponents in class TTrack
      Parameters:
      panel - the tracker panel
      point - the TPoint
      Returns:
      a list of components
    • getNumberFields

      public Map<String,NumberField[]> getNumberFields()
      Description copied from class: TTrack
      Gets a map of number fields by name.
      Overrides:
      getNumberFields in class TTrack
      Returns:
      a map of name to NumberField.
    • getLoader

      public static XML.ObjectLoader getLoader()
      Returns an ObjectLoader to save and load data for this class.
      Returns:
      the object loader
    • createGUI

      protected void createGUI()
      Creates the GUI.
    • createMenuIfNecessary

      protected void createMenuIfNecessary()
    • getVArray

      protected TTrack.StepArray getVArray(Integer panelID)
      Gets the velocity StepArray for the specified panel.
      Parameters:
      panel - the tracker panel
      Returns:
      the velocity StepArray
    • getAArray

      protected TTrack.StepArray getAArray(Integer panelID)
      Gets the acceleration StepArray for the specified panel.
      Parameters:
      panel - the tracker panel
      Returns:
      the acceleration StepArray