Class PencilDrawing

java.lang.Object
org.opensourcephysics.cabrillo.tracker.PencilDrawing
All Implemented Interfaces:
Drawable, Measurable

public class PencilDrawing extends Object implements Drawable, Measurable
A PencilDrawing is a freeform line, arrow or ellipse.
Author:
Douglas Brown
  • Field Details

  • Method Details

    • draw

      public void draw(DrawingPanel panel, Graphics g)
      Description copied from interface: Drawable
      Draws a representation of an object in a drawing panel.
      Specified by:
      draw in interface Drawable
    • setStyle

      public void setStyle(int newStyle)
      Sets the style. Defined styles are STYLE_TRAIL, STYLE_ARROW, STYLE_ELLIPSE
      Parameters:
      newStyle - one of the defined styles
    • setArrowheadLength

      public void setArrowheadLength(int length)
      Sets the arrowhead length
      Parameters:
      length - a length
    • getPointCount

      public int getPointCount()
      Gets the number of points stored in the trail.
      Returns:
      int
    • getStroke

      public Stroke getStroke()
      Gets the drawing stroke.
      Returns:
      Stroke
    • setStroke

      public void setStroke(Stroke stroke)
      Sets the drawing stroke.
      Parameters:
      stroke - Stroke
    • clear

      public void clear()
      Clears all points from the trail.
    • markPoint

      public void markPoint(double x, double y)
      Marks a new point and draws a shape of the current style.
      Parameters:
      x - double
      y - double
    • getXMin

      public double getXMin()
      Description copied from interface: Measurable
      Gets the minimum x needed to draw this object.
      Specified by:
      getXMin in interface Measurable
      Returns:
      minimum
    • getXMax

      public double getXMax()
      Description copied from interface: Measurable
      Gets the maximum x needed to draw this object.
      Specified by:
      getXMax in interface Measurable
      Returns:
      maximum
    • getYMin

      public double getYMin()
      Description copied from interface: Measurable
      Gets the minimum y needed to draw this object.
      Specified by:
      getYMin in interface Measurable
      Returns:
      minimum
    • getYMax

      public double getYMax()
      Description copied from interface: Measurable
      Gets the maximum y needed to draw this object.
      Specified by:
      getYMax in interface Measurable
      Returns:
      minimum
    • isMeasured

      public boolean isMeasured()
      Description copied from interface: Measurable
      Determines if information is available to set min/max values. Objects that store data should return false if data is null.
      Specified by:
      isMeasured in interface Measurable
      Returns:
      true if min/max values are valid
    • getLoader

      public static XML.ObjectLoader getLoader()
      Returns the XML.ObjectLoader for this class.
      Returns:
      the object loader