Class CircleFitterStep

java.lang.Object
org.opensourcephysics.cabrillo.tracker.Step
org.opensourcephysics.cabrillo.tracker.CircleFitterStep
All Implemented Interfaces:
Cloneable

public class CircleFitterStep extends Step
This is a Step for a CircleFitter. It is used for measuring and finding centers of circles.
Author:
Douglas Brown
  • Field Details

    • transform

      protected static AffineTransform transform
    • endPoint1

      protected static TPoint endPoint1
    • endPoint2

      protected static TPoint endPoint2
    • doRefresh

      protected static boolean doRefresh
    • circleFitter

      protected CircleFitter circleFitter
    • dataPoints

      protected org.opensourcephysics.cabrillo.tracker.CircleFitterStep.DataPoint[][] dataPoints
    • center

      protected org.opensourcephysics.cabrillo.tracker.CircleFitterStep.CenterPoint center
    • edge

      protected TPoint edge
    • radius

      protected double radius
    • panelCircleHitShapes

      protected Map<Integer,Shape> panelCircleHitShapes
    • panelCenterHitShapes

      protected Map<Integer,Shape> panelCenterHitShapes
    • panelPointHitShapes

      protected ArrayList<Map<Integer,Shape>> panelPointHitShapes
    • selectedShape

      protected org.opensourcephysics.cabrillo.tracker.MultiShape selectedShape
  • Constructor Details

    • CircleFitterStep

      public CircleFitterStep(CircleFitter track, int n)
      Constructs an empty CircleFitterStep.
      Parameters:
      track - the track
      n - the frame number
  • Method Details

    • setDataPoint

      public void setDataPoint(org.opensourcephysics.cabrillo.tracker.CircleFitterStep.DataPoint p, int column, int row, boolean refreshAndPostEdit, boolean reduceArrayLengthIfNull)
      Sets the data point at a specified column and row. Replaces existing element, adds null elements if needed. Data is stored in array element DataPoints[col][row]
      Parameters:
      p - the data point (may be null)
      column - the column index
      row - the row index
      refreshAndPostEdit - true to refresh circle, fire event and post undo edit
      reduceArrayLengthIfNull - true to eliminate null elements
    • addDataPoint

      public void addDataPoint(org.opensourcephysics.cabrillo.tracker.CircleFitterStep.DataPoint p, boolean refreshAndPostEdit)
      Adds a data point at the end of the array.
      Parameters:
      p - the data point
      refreshAndPostEdit - true to refresh circle, fire event and post undo edit
    • removeDataPoint

      public void removeDataPoint(org.opensourcephysics.cabrillo.tracker.CircleFitterStep.DataPoint p, boolean postUndoableEdit, boolean fireEvents)
      Removes a data point from the user-marked array.
      Parameters:
      p - the point to remove
      postUndoableEdit - true to post an undoable edit
      fireEvents - true to fire property change events
    • getDataPoint

      public org.opensourcephysics.cabrillo.tracker.CircleFitterStep.DataPoint getDataPoint(int column, int row)
      Gets a data point.
      Parameters:
      column - the column: 0=marked points, 1=attached points
      row - the row
      Returns:
      the DataPoint, or null if not found
    • getValidDataPoints

      public ArrayList<org.opensourcephysics.cabrillo.tracker.CircleFitterStep.DataPoint> getValidDataPoints()
      Gets the valid data points. A point is valid if non-null. This return points from all columns, with user-marked points (column 0) first.
    • trimAttachedPointsToLength

      public boolean trimAttachedPointsToLength(int len)
      Trims the attached points array to a specified length.
      Parameters:
      len - the trimmed length
      Returns:
      true if any non-null points were trimmed
    • getDefaultPoint

      public TPoint getDefaultPoint()
      Description copied from class: Step
      Gets the default point. The default point is the point initially selected when the step is created.
      Overrides:
      getDefaultPoint in class Step
      Returns:
      the default TPoint
    • findInteractive

      public Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
      Description copied from class: Step
      Finds the Interactive located at the specified pixel position.
      Overrides:
      findInteractive in class Step
      Parameters:
      panel - the drawing panel
      xpix - the x pixel position
      ypix - the y pixel position
      Returns:
      the TPoint that is hit, or null
    • draw

      public void draw(DrawingPanel panel, Graphics _g)
      Description copied from class: Step
      Draws this step.
      Overrides:
      draw in class Step
      Parameters:
      panel - the drawing panel requesting the drawing
      _g - the graphics context on which to draw
    • getMark

      protected Mark getMark(TrackerPanel trackerPanel)
      Description copied from class: Step
      Gets the mark for the specified panel.
      Overrides:
      getMark in class Step
      Parameters:
      trackerPanel - the tracker panel
      Returns:
      the mark
    • getWorldRadius

      public double getWorldRadius()
      Returns the circle radius in world units.
      Returns:
      the radius in world units
    • getWorldCenter

      public Point2D getWorldCenter()
      Returns the circle center coordinates in world units.
      Returns:
      the center point in world units
    • isValidCircle

      public boolean isValidCircle()
      Returns true if the circle is valid (ie if at least 3 data points have been successfuly fit).
      Returns:
      true if valid
    • refreshCircle

      public void refreshCircle()
      Refreshes the circle based on the current data points.
    • clone

      public Object clone()
      Clones this Step.
      Overrides:
      clone in class Step
      Returns:
      a clone of this step
    • copy

      public void copy(CircleFitterStep step)
      Copies data points from another step, then refreshes the circle.
      Parameters:
      step - the step to copy
    • toString

      public String toString()
      Returns a String describing this.
      Overrides:
      toString in class Step
      Returns:
      a descriptive string
    • getLength

      public static int getLength()
      Gets the step length.
      Returns:
      the length of the points array
    • dispose

      protected void dispose()
      Description copied from class: Step
      Disposes of this step.
      Overrides:
      dispose in class Step
    • getLoader

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