Class ParticleDataTrack

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

public class ParticleDataTrack extends ParticleModel implements DataTrack
This is a particle model with steps based on world positions defined in a Data object. The Data object is an "external model" associated with a source (eg path, URL, Tool, null) The Data must define one or more data arrays in matched x-y pairs and may include a time array "t"
Author:
Douglas Brown
  • Field Details

    • PROPERTY_PARTICLEDATATRACK_DATACLIP

      public static final String PROPERTY_PARTICLEDATATRACK_DATACLIP
      no listeners?
      See Also:
    • pointName

      protected String pointName
    • modelName

      protected String modelName
    • morePoints

      protected ArrayList<ParticleDataTrack> morePoints
    • pendingDataString

      protected String pendingDataString
    • prevDataString

      protected String prevDataString
    • modelFootprint

      protected Footprint modelFootprint
    • modelFootprints

      protected Footprint[] modelFootprints
    • modelFootprintVisible

      protected boolean modelFootprintVisible
  • Constructor Details

    • ParticleDataTrack

      public ParticleDataTrack(DatasetManager data, Object source) throws Exception
      Public constructor.
      Parameters:
      data - the Data object
      source - the data source object (null if data is pasted)
      Throws:
      Exception - if the data does not define x and y-datasets
  • Method Details

    • setMoreData

      protected void setMoreData(ArrayList<Object[]> pointData)
    • doAllColor

      protected void doAllColor()
    • doAllCircle

      protected void doAllCircle(String footprintName)
    • doAllFoot

      protected void doAllFoot(String footprintName)
    • delete

      protected void delete(boolean postEdit)
      Description copied from class: TTrack
      Removes this track from all panels that draw it. If no other objects have a reference to it, this should then be garbage-collected.
      Overrides:
      delete in class TTrack
      Parameters:
      postEdit - true to post an undoable edit
    • setModelFootprint

      protected void setModelFootprint(String name)
    • getModelFootprint

      protected Footprint getModelFootprint()
    • getModelFootprintName

      protected String getModelFootprintName()
    • 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
    • getPointMenu

      protected JMenu getPointMenu(TrackerPanel trackerPanel)
      Returns a menu with items associated with this track's point properties.
      Parameters:
      trackerPanel - the tracker panel
      Returns:
      a menu
    • getIcon

      public ResizableIcon getIcon(int w, int h, String context)
      Description copied from class: TTrack
      Gets this track's current icon.
      Overrides:
      getIcon in class TTrack
      Parameters:
      w - the icon width
      h - the icon height
      Returns:
      the icon
    • getToolbarTrackComponents

      public ArrayList<Component> getToolbarTrackComponents(TrackerPanel trackerPanel)
      Description copied from class: PointMass
      Overrides TTrack getToolbarTrackComponents method.
      Overrides:
      getToolbarTrackComponents in class PointMass
      Parameters:
      trackerPanel - the tracker panel
      Returns:
      a list of components
    • doAutoPaste

      protected void doAutoPaste(boolean tf)
    • isAutoPasteEnabled

      public boolean isAutoPasteEnabled()
      Description copied from interface: DataTrack
      Determines if autopaste is enabled for this DataTrack.
      Specified by:
      isAutoPasteEnabled in interface DataTrack
      Returns:
      true if autopaste is enabled
    • setAutoPasteEnabled

      protected void setAutoPasteEnabled(boolean enable)
      Sets the autoPasteEnabled flag for this track.
      Parameters:
      enable - true to enable autopasting
    • getPointName

      protected String getPointName()
      Gets the point name. The point name is appended to the lead track name for most buttons and dropdowns.
      Returns:
      the point name
    • setPointName

      protected void setPointName(String newName)
      Sets the point name. The point name is appended to the leader's track name to name the point.
      Parameters:
      newName - the point name
    • setAllColors

      protected void setAllColors(Color[] colors)
      Sets the colors of all points and line in this track. Used for undo/redo.
      Parameters:
      colors - array of colors
    • setAllFootprints

      protected void setAllFootprints(String[] footprints)
      Sets the footprints of all points in this track. Used for undo/redo.
      Parameters:
      footprints - array of footprints
    • getFullName

      public String getFullName()
      Gets the full name (model & point) for this track.
      Returns:
      the full name
    • getName

      public String getName(String context)
      Description copied from class: TTrack
      Gets the name of this track.
      Overrides:
      getName in class TTrack
      Parameters:
      context - ignored by default
      Returns:
      the name
    • setName

      public void setName(String newName)
      Description copied from class: ParticleModel
      Sets the name. Overrides TTrack method.
      Overrides:
      setName in class ParticleModel
      Parameters:
      newName - the name
    • setColor

      public void setColor(Color color)
      Description copied from class: PointMass
      Overrides TTrack setColor method.
      Overrides:
      setColor in class PointMass
      Parameters:
      color - the desired color
    • setLineColor

      public void setLineColor(Color color)
      Sets the line color for the modelFootprint.
      Parameters:
      color - the color
    • setFootprint

      public void setFootprint(String name)
      Description copied from class: TTrack
      Sets the footprint to the specified choice.
      Overrides:
      setFootprint in class TTrack
      Parameters:
      name - the name of the desired footprint
    • getLeader

      public ParticleDataTrack getLeader()
      Returns the lead track (index=0)
      Returns:
      the leader (may be this track)
    • setData

      public void setData(DatasetManager manager) throws Exception
      Sets the Data. Data must define columns "x" and "y". If time data is included, it is assumed to be in seconds.
      Parameters:
      manager - the Data object
      Throws:
      Exception - if the data does not define x and y-columns
    • getData

      public Data getData()
      Gets the model data. This can return null if loaded from XMLControl.
      Specified by:
      getData in interface DataTrack
      Returns:
      the data (may return null)
    • getSource

      public Object getSource()
      Gets the data source.
      Specified by:
      getSource in interface DataTrack
      Returns:
      the source (may return null)
    • setSource

      public void setSource(Object source)
      Sets the data source.
    • getDataClip

      public DataClip getDataClip()
      Gets the data clip.
      Specified by:
      getDataClip in interface DataTrack
      Returns:
      the data clip
    • invalidateData

      public void invalidateData(Object newValue)
      Overrides:
      invalidateData in class TTrack
    • getVideoClip

      public VideoClip getVideoClip()
      Gets the trackerPanel video clip.
      Returns:
      the video clip (null if not yet added to TrackerPanel)
    • isVisible

      public boolean isVisible()
      Description copied from class: TTrack
      Reports whether or not this is visible.
      Overrides:
      isVisible in class TTrack
      Returns:
      true if this track is visible
    • setVisible

      public void setVisible(boolean vis)
      Description copied from class: PointMass
      Shows and hides this track.
      Overrides:
      setVisible in class PointMass
      Parameters:
      vis - true to show this track
    • getEndIndex

      public int getEndIndex()
      Gets the end data index.
      Returns:
      the end index
    • getStepTime

      public double getStepTime(int step)
      Gets the (start) time for a given step.
      Returns:
      the time
    • isTimeDataAvailable

      public boolean isTimeDataAvailable()
      Determines if time is defined by the Data.
      Specified by:
      isTimeDataAvailable in interface DataTrack
      Returns:
      true if time data is available
    • getVideoStartTime

      public double getVideoStartTime()
      Gets the data-based video start time in seconds if available
      Specified by:
      getVideoStartTime in interface DataTrack
      Returns:
      the start time (assumed in seconds), or Double.NaN if unavailable
    • getFrameDuration

      public double getFrameDuration()
      Gets the data-based frame duration in seconds if available
      Specified by:
      getFrameDuration in interface DataTrack
      Returns:
      the frame duration (assumed in seconds), or Double.NaN if unavailable
    • setStartFrame

      public void setStartFrame(int n)
      Description copied from class: ParticleModel
      Sets the start frame for this model. Also sets the initial time to the video clip time at the start frame.
      Specified by:
      setStartFrame in interface DataTrack
      Overrides:
      setStartFrame in class ParticleModel
      Parameters:
      n - the desired start frame
    • setStartStep

      public void setStartStep(int start)
      Description copied from interface: DataTrack
      Sets the step in the videoclip at which the first data point is displayed.
      Specified by:
      setStartStep in interface DataTrack
      Parameters:
      start - the start step number
    • getStartStep

      public int getStartStep()
      Description copied from interface: DataTrack
      Gets the step in the videoclip at which the first data point is displayed.
      Specified by:
      getStartStep in interface DataTrack
      Returns:
      the start step number
    • setEndFrame

      public void setEndFrame(int n)
      Description copied from class: ParticleModel
      Sets the end frame for this model.
      Overrides:
      setEndFrame in class ParticleModel
      Parameters:
      n - the desired end frame
    • refreshInitialTime

      protected void refreshInitialTime()
      Description copied from class: ParticleModel
      Refreshes initial time parameter for this model.
      Overrides:
      refreshInitialTime in class ParticleModel
    • getStartFrame

      public int getStartFrame()
      Description copied from class: ParticleModel
      Gets the start frame for this model.
      Specified by:
      getStartFrame in interface DataTrack
      Overrides:
      getStartFrame in class ParticleModel
      Returns:
      the start frame
    • getEndFrame

      public int getEndFrame()
      Description copied from class: ParticleModel
      Gets the end frame for this model.
      Overrides:
      getEndFrame in class ParticleModel
      Returns:
      the end frame
    • getDataIndexAtVideoStepNumber

      protected int getDataIndexAtVideoStepNumber(int videoStepNumber)
      Converts video step number to data index.
      Parameters:
      videoStepNumber -
      Returns:
      the data index, or -1 if none
    • setColorToDefault

      public void setColorToDefault(int index)
      Description copied from class: TTrack
      Sets the color to one of the default colors[].
      Overrides:
      setColorToDefault in class TTrack
      Parameters:
      index - the color index
    • setTrackerPanel

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

      public void propertyChange(PropertyChangeEvent e)
      Description copied from class: ParticleModel
      Responds to property change events.
      Specified by:
      propertyChange in interface PropertyChangeListener
      Overrides:
      propertyChange in class ParticleModel
      Parameters:
      e - the property change event
    • initializeFunctionPanel

      protected void initializeFunctionPanel()
      Description copied from class: ParticleModel
      Initializes the ModelFunctionPanel.
      Specified by:
      initializeFunctionPanel in class ParticleModel
    • reset

      protected void reset()
      Description copied from class: ParticleModel
      Resets model parameters and sets position(s) for start frame. Most of the work in this method must be done by subclasses.
      Specified by:
      reset in class ParticleModel
    • setData

      public void setData(Data data, Object source) throws Exception
      Description copied from interface: DataTrack
      Sets the Data for the track. Data must define "x" and "y" positions, and may define "t". Optional source may be a JPanel control panel.
      Specified by:
      setData in interface DataTrack
      Parameters:
      data - the Data
      source - a source object (may be null)
      Throws:
      Exception
    • getVideoPanel

      public VideoPanel getVideoPanel()
      Description copied from interface: DataTrack
      Gets the VideoPanel on which this DataTrack is drawn.
      Specified by:
      getVideoPanel in interface DataTrack
      Returns:
      the VideoPanel
    • createPositionStep

      protected PositionStep createPositionStep(PointMass track, int n, double x, double y)
      Description copied from class: ParticleModel
      Creates a position step with image coordinates. Overridden by ParticleDataTrack.
      Overrides:
      createPositionStep in class ParticleModel
      Parameters:
      track - the PointMass track
      n - the frame number
      x - the x coordinate
      y - the y coordinate
      Returns:
      the PositionStep
    • getDataArray

      public double[][] getDataArray()
      Gets the data array.
      Returns:
      double[][] {x, y, t}
    • appendData

      public void appendData(DatasetManager manager) throws Exception
      Informs this track that values have been appended to the Data. not referenced
      Parameters:
      manager - Data containing newly appended values
      Throws:
      Exception - if (x, y) data not found
    • getImportableDataName

      protected static String getImportableDataName(String s)
    • getTrackForDataString

      protected static ParticleDataTrack getTrackForDataString(String dataString, TrackerPanel trackerPanel)
    • getTrackForData

      protected static ParticleDataTrack getTrackForData(DatasetManager data, TrackerPanel trackerPanel)
    • getNextName

      protected static String getNextName(String original, int increment)
    • 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 ParticleModel