Class VectorSum

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

public class VectorSum extends Vector
A VectorSum draws a series of VectorSteps that represent a vector sum of its set of vectors.
Author:
Douglas Brown
  • Field Details

  • Constructor Details

    • VectorSum

      public VectorSum()
      Constructs an empty VectorSum.
    • VectorSum

      public VectorSum(Vector[] vectors)
      Constructs a VectorSum with specified vectors.
      Parameters:
      vectors - an array of vectors
  • Method Details

    • draw

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

      public void initialize(TrackerPanel panel)
      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
    • findInteractive

      public Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
      Finds the interactive drawable object located at the specified pixel position.
      Specified by:
      findInteractive in interface Interactive
      Overrides:
      findInteractive in class Vector
      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 TPoint that is hit
    • addVector

      public void addVector(Vector vec)
      Adds a vector to this sum.
      Parameters:
      vec - the vector
    • removeVector

      public void removeVector(Vector vec)
      Removes a vector from this sum.
      Parameters:
      vec - the vector
    • getVectors

      public Vector[] getVectors()
      Gets the array of vectors in this sum.
      Returns:
      a shallow clone of the vectors array
    • contains

      public boolean contains(Vector vec)
      Determines if the specified vector is in this sum.
      Parameters:
      vec - the vector
      Returns:
      true if vector is in this sum
    • createStep

      public Step createStep(int n, double x, double y, double xc, double yc)
      Overrides vector method. Saves the specified tail position, then updates the step.
      Overrides:
      createStep in class Vector
      Parameters:
      n - the frame number
      x - the tail x coordinate in image space
      y - the tail y coordinate in image space
      xc - ignored
      yc - ignored
      Returns:
      the new step
    • setFontLevel

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

      public void setLocked(boolean locked)
      Overrides TTrack setLocked method. VectorSum is always locked.
      Overrides:
      setLocked in class Vector
      Parameters:
      locked - ignored
    • 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 sum gets data from vectors
    • isDependent

      public boolean isDependent()
      Overrides TTrack isDependent method to return true.
      Overrides:
      isDependent in class TTrack
      Returns:
      true since sum is dependent on its vectors
    • 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 Vector
      Parameters:
      e - the property change event
    • dispose

      public void dispose()
      Cleans up associated resources when this track is deleted or cleared.
      Overrides:
      dispose in class TTrack
    • getMenu

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

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

      public String toString()
      Overrides Object toString method.
      Overrides:
      toString in class Vector
      Returns:
      a description of this object
    • getLoader

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

      public VectorSumInspector getInspector()
      Gets the vector sum inspector.
      Returns:
      the vector sum inspector