Package doodlepad

Class Arc


public class Arc extends Shape
A class that implements a graphical arc shape. An Arc is a partial section of an ellipse that is bounded by the rectangle defined by the parameters passed to the Arc constructor. The start angle and angle extent define the section of the ellipse that makes up the Arc.
  • Constructor Details

    • Arc

      public Arc(double x, double y, double width, double height, double startAngle, double arcAngle)
      Creates an arc shape defined by a section of an ellipse bounded by the rectangle with upper left corner at (x, y) and size (width, height). The section starts at angle startAngle (degrees) and extends by arcAngle (degrees).
       // Creates an arc with an upper left corner at (10, 20) and a size of (100, 50) 
       // from an angle of 0° and continuing by an extent of 45°.
       Arc arc = new Arc(10, 20, 100, 50, 0, 45);
       
      Parameters:
      x - The upper x-coordinate of the Arc`s related ellipse bounding box (pixels).
      y - The upper y-coordinate of the Arc`s related ellipse bounding box (pixels).
      width - The width of the Arc`s related ellipse (pixels).
      height - The height of the Arc`s related ellipse bounding box (pixels).
      startAngle - The starting angle at which to begin drawing the Arc (degrees).
      arcAngle - The angular extent of the Arc, which defines its length (degrees).
    • Arc

      public Arc(double x, double y, double width, double height, double startAngle, double arcAngle, Pad pad)
      Creates an arc shape defined by a section of an ellipse bounded by the rectangle with upper left corner at (x, y) and size (width, height). The section starts at angle startAngle (degrees) and extends by arcAngle (degrees).
      Parameters:
      x - The upper x-coordinate of the Arc`s related ellipse bounding box (pixels).
      y - The upper y-coordinate of the Arc`s related ellipse bounding box (pixels).
      width - The width of the Arc`s related ellipse (pixels).
      height - The height of the Arc`s related ellipse bounding box (pixels).
      startAngle - The starting angle at which to begin drawing the Arc (degrees).
      arcAngle - The angular extent of the Arc, which defines its length (degrees).
      pad - The Pad object on which to create the Arc.
    • Arc

      public Arc(double x, double y, double width, double height, double startAngle, double arcAngle, Layer layer)
      Creates an arc shape defined by a section of an ellipse bounded by the rectangle with upper left corner at (x, y) and size (width, height) and the layer on which the arc will be drawn. The section starts at angle startAngle (degrees) and extends by arcAngle (degrees).
      Parameters:
      x - The upper x-coordinate of the Arc`s related ellipse bounding box (pixels).
      y - The upper y-coordinate of the Arc`s related ellipse bounding box (pixels).
      width - The width of the Arc`s related ellipse (pixels).
      height - The height of the Arc`s related ellipse bounding box (pixels).
      startAngle - The starting angle at which to begin drawing the Arc (degrees).
      arcAngle - The angular extent of the Arc, which defines its length (degrees).
      layer - Layer object to add Arc to, or null if not to add Arc to a Layer.
    • Arc

      public Arc()
      Default constructor for the Arc object. Creates an arc shape with the default parameters width=100, height=100, startAngle=0, arcAngle=270. that is draggable shape and positioned randomly.
  • Method Details

    • getStartAngle

      public double getStartAngle()
      Returns the start angle for the Arc Shape.
      Returns:
      start angle (degrees)
    • getArcAngle

      public double getArcAngle()
      Returns the arc angle for the Arc Shape.
      Returns:
      arc angle extent (degrees)
    • setStartAngle

      public void setStartAngle(double angle)
      Sets the start angle for the Arc Shape.
      Parameters:
      angle - start angle (degrees)
    • setArcAngle

      public void setArcAngle(double angle)
      Sets the arc angle extent for the Arc Shape.
      Parameters:
      angle - arc angle extent (degrees)
    • setText

      public void setText(String text)
      A no-op to prevent setting text for this Shape.
      Overrides:
      setText in class Shape
      Parameters:
      text - The internal text as a String
    • toString

      public String toString()
      Builds and returns a string representation of the arc shape that includes position, size and layer.
      Overrides:
      toString in class Shape
      Returns:
      String representation of the arc.
    • draw

      public void draw(Graphics2D g)
      Draw the shape
      Specified by:
      draw in class Shape
      Parameters:
      g - The Graphics2D object on which to draw the arc
    • getArea

      public Area getArea()
      Return the area of an arc. The area will be of the pie section if filled, and an open section if not filled.
      Overrides:
      getArea in class Shape
      Returns:
      A java.awt.geom.Area object.