Class Arc

All Implemented Interfaces:
Strokable

public class Arc extends GraphicsObject implements Strokable
A partial section of an ellipse.
  • Constructor Details

    • Arc

      public Arc(double x, double y, double width, double height, double startAngle, double sweepAngle)
      This is an arc, based on Java's Arc2D.Double, which Java describes as follows:
      The arc is a partial section of a full ellipse which inscribes the framing rectangle of its parent RectangularShape. The angles are specified relative to the non-square framing rectangle such that 45 degrees always falls on the line from the center of the ellipse to the upper right corner of the framing rectangle. As a result, if the framing rectangle is noticeably longer along one axis than the other, the angles to the start and end of the arc segment will be skewed farther along the longer axis of the frame. Note that 0 degrees is the positive x axis along the center of the ellipse, making the 90 degree point on a line from the center of the ellipse to the top center point of the upper arc of the ellipse.
      Parameters:
      sweepAngle - angle to sweep around from the starting angle, e.g. 180 would create a 1/2 ellipse
  • Method Details

    • drawInLocalCoordinates

      protected void drawInLocalCoordinates(Graphics2D gc)
      Description copied from class: GraphicsObject
      For internal use. Draws this graphics object on the screen in its local coordinates, without rotation or scaling.
      Specified by:
      drawInLocalCoordinates in class GraphicsObject
    • getStrokeColor

      public Paint getStrokeColor()
      Description copied from interface: Strokable
      Returns the color to strokeColor that will be used to stroke this shape if it is stroked. Note that there will still be no stroke if isStroked() is false or the stroke width is zero.
      Specified by:
      getStrokeColor in interface Strokable
    • setStrokeColor

      public void setStrokeColor(Paint strokeColor)
      Description copied from interface: Strokable
      Sets the stroke color to the given color. Automatically calls setStroked(true).
      Specified by:
      setStrokeColor in interface Strokable
    • getStrokeWidth

      public double getStrokeWidth()
      Description copied from interface: Strokable
      Returns the thickness of the stroke in pixels.
      Specified by:
      getStrokeWidth in interface Strokable
    • setStrokeWidth

      public void setStrokeWidth(double width)
      Description copied from interface: Strokable
      Sets how thick the stroke is. Automatically calls setStroked(true).
      Specified by:
      setStrokeWidth in interface Strokable
    • isStroked

      public boolean isStroked()
      Description copied from interface: Strokable
      Returns true if the interior of this shape will be stroked with the stroke color.
      Specified by:
      isStroked in interface Strokable
    • setStroked

      public void setStroked(boolean stroked)
      Description copied from interface: Strokable
      Causes the shape to be stroked with the stroke color when it is drawn.
      Specified by:
      setStroked in interface Strokable
    • testHitInLocalCoordinates

      public boolean testHitInLocalCoordinates(double x, double y)
      Description copied from class: GraphicsObject
      Tests whether the given point is inside the boundary or interior of this object’s shape. The point is in this object’s local coordinates.
      Specified by:
      testHitInLocalCoordinates in class GraphicsObject
    • getBounds

      public Rectangle2D getBounds()
      Description copied from class: GraphicsObject
      Returns the bounding box of this graphics object in its local coordinates.
      Specified by:
      getBounds in class GraphicsObject
    • getEqualityAttributes

      protected Object getEqualityAttributes()
      Description copied from class: GraphicsObject
      For internal use only. Used to compute equals() and hashCode(). Returns an object whose equals() and hashCode() methods encompass the subclass-specific values that should be used to compute equality for the whole GraphicsObject.
      Specified by:
      getEqualityAttributes in class GraphicsObject