Class DynamicSystem

All Implemented Interfaces:
PropertyChangeListener, EventListener, Drawable, Interactive, Measurable, Trackable, ODE

public class DynamicSystem extends DynamicParticlePolar
This models a system of 2 particles that interact via internal forces.
Version:
1.0
Author:
D. Brown
  • Field Details

    • particles

      protected DynamicParticle[] particles
    • models

      protected ParticleModel[] models
    • particleState

      protected double[] particleState
    • systemInspector

      protected DynamicSystemInspector systemInspector
    • systemInspectorItem

      protected JMenuItem systemInspectorItem
    • particleNames

      protected String[] particleNames
    • realSteps

      protected TTrack.StepArray realSteps
    • noSteps

      protected TTrack.StepArray noSteps
    • systemInspectorX

      protected int systemInspectorX
    • systemInspectorY

      protected int systemInspectorY
    • frameRelativeStates

      protected TreeMap<Integer,double[]> frameRelativeStates
    • refreshing

      protected boolean refreshing
    • dataVariables

      protected static final String[] dataVariables
  • Constructor Details

    • DynamicSystem

      public DynamicSystem()
      No-arg constructor.
    • DynamicSystem

      public DynamicSystem(DynamicParticle[] parts)
      Constructor with particles.
      Parameters:
      parts - an array of up to two dynamic particles
  • Method Details

    • draw

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

      public void initialize(TrackerPanel trackerPanel)
      Description copied from class: TTrack
      Finish up any unfinished loading business that for whatever reason was not finished upon loading a track. For example, adding masses to a center-of-mass system, or adding particles to a DynamicSystem.
      Overrides:
      initialize in class TTrack
    • getDisplayName

      public String getDisplayName()
      Gets a display name for this model.
      Overrides:
      getDisplayName in class DynamicParticle
      Returns:
      the display name
    • getMenu

      public JMenu getMenu(TrackerPanel trackerPanel, JMenu menu0)
      Returns a menu with items that control this track.
      Overrides:
      getMenu in class ParticleModel
      Parameters:
      trackerPanel - 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 trackerPanel)
      Overrides TTrack getToolbarTrackComponents method.
      Overrides:
      getToolbarTrackComponents in class PointMass
      Parameters:
      trackerPanel - the tracker panel
      Returns:
      a list of components
    • getMass

      public double getMass()
      Gets the mass. Overrides PointMass method.
      Overrides:
      getMass in class ParticleModel
      Returns:
      the mass
    • isDependent

      public boolean isDependent()
      Overrides TTrack isDependent method to return true.
      Overrides:
      isDependent in class ParticleModel
      Returns:
      true if this track is dependent
    • addParticle

      public boolean addParticle(DynamicParticle particle)
      Adds a particle to this system.
      Parameters:
      particle - the particle to add
      Returns:
      true if particle added
    • removeParticle

      public boolean removeParticle(DynamicParticle particle)
      Removes a particle from this system.
      Parameters:
      particle - the particle to remove
      Returns:
      true if particle removed
    • setParticles

      public boolean setParticles(DynamicParticle[] newParticles)
      Sets the particles in this system.
      Parameters:
      newParticles - an array of zero to two dynamic particles
      Returns:
      true if particles accepted
    • delete

      public void delete()
      Deletes this system. Overrides DynamicParticle method to clean up particles after deleting.
      Overrides:
      delete in class DynamicParticle
    • getRate

      public void getRate(double[] state, double[] rate)
      Gets the rate based on a specified state.
      Specified by:
      getRate in interface ODE
      Overrides:
      getRate in class DynamicParticle
      Parameters:
      state - the state
      rate - the rate of change of the state
    • getInitialValues

      public double[] getInitialValues()
      Gets the initial values.
      Overrides:
      getInitialValues in class ParticleModel
      Returns:
      initial values {x1, vx1, y1, vy1, x2, vx2, y2, vy2, t}
    • propertyChange

      public void propertyChange(PropertyChangeEvent e)
      Responds to property change events.
      Specified by:
      propertyChange in interface PropertyChangeListener
      Overrides:
      propertyChange in class DynamicParticle
      Parameters:
      e - the property change event
    • setFontLevel

      public void setFontLevel(int level)
      Description copied from class: PointMass
      Sets the font level.
      Overrides:
      setFontLevel in class PointMass
      Parameters:
      level - the desired font level
    • getSystemInspector

      public DynamicSystemInspector getSystemInspector()
      Gets the system inspector.
      Returns:
      the system inspector
    • getInitialState

      public double[] getInitialState()
      Gets the initial state. Overrides DynamicParticle method.
      Overrides:
      getInitialState in class DynamicParticlePolar
      Returns:
      the initial state
    • refreshData

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

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

      protected void refreshInitialTime()
      Refreshes initial time parameter for this model. Overrides ParticleModel.
      Overrides:
      refreshInitialTime in class ParticleModel
    • refreshSystemParameters

      protected void refreshSystemParameters()
      Refreshes the initial positions, velocities and particle masses based on the values for the particles in this system.
    • setTracePositions

      protected void setTracePositions(double[] state)
      Sets the positions of the trace points based on a specified state.
      Overrides:
      setTracePositions in class DynamicParticle
      Parameters:
      state - the state
    • initializeFunctionPanel

      protected void initializeFunctionPanel()
      Creates and initializes the ModelFunctionPanel.
      Overrides:
      initializeFunctionPanel in class DynamicParticlePolar
    • getSystemState

      protected double[] getSystemState(double[] state)
      Gets the state of this system based on the states of its particles.
      Parameters:
      state - the particle state {x1, vx1, y1, vy1, x2, vx2, y2, vy2, t}
      Returns:
      the system state {x_cm, vx_cm, y_cm, vy_cm, t}
    • getState

      protected double[] getState(DynamicParticle particle)
      Gets the current state of the specified particle.
      Parameters:
      particle - the particle
      Returns:
      the state of the particle {x, vx, y, vy, t}
    • getModels

      protected ParticleModel[] getModels()
      Gets the particle models associated with this model.
      Overrides:
      getModels in class ParticleModel
      Returns:
      an array of particle models
    • getRelativePolarState

      protected double[] getRelativePolarState(double[] state)
      Converts a two-body cartesian state {x1, vx1, y1, vy1, x2, vx2, y2, vy2, t} to a relative polar state {r, vr, theta, omega, t}.
      Parameters:
      state - the cartesian state of both particles
      Returns:
      the polar state of particle 1 relative to particle 2
    • getLoader

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