Class Arc2D

java.lang.Object
armyc2.c2sd.graphics2d.Arc2D

public class Arc2D extends Object
Since:
1.2
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The closure type for an arc closed by drawing a straight line segment from the start of the arc segment to the end of the arc segment.
    double
    The angular extent of the arc in degrees.
    double
    The overall height of the full ellipse of which this arc is a partial section (not considering the angular extents).
    static final int
    The closure type for an open arc with no path segments connecting the two ends of the arc segment.
    static final int
    The closure type for an arc closed by drawing straight line segments from the start of the arc segment to the center of the full ellipse and from that point to the end of the arc segment.
    double
    The starting angle of the arc in degrees.
    double
    The overall width of the full ellipse of which this arc is a partial section (not considering the angular extents).
    double
    The X coordinate of the upper-left corner of the framing rectangle of the arc.
    double
    The Y coordinate of the upper-left corner of the framing rectangle of the arc.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    Arc2D(double x, double y, double w, double h, double start, double extent, int type)
    Constructs a new arc, initialized to the specified location, size, angular extents, and closure type.
    protected
    Arc2D(int type)
    This is an abstract class that cannot be instantiated directly.
     
    Arc2D(Rectangle2D ellipseBounds, double start, double extent, int type)
    Constructs a new arc, initialized to the specified location, size, angular extents, and closure type.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(double x, double y)
    Determines whether or not the specified point is inside the boundary of the arc.
    boolean
    containsAngle(double angle)
    Determines whether or not the specified angle is within the angular extents of the arc.
    boolean
    Determines whether or not the specified Object is equal to this Arc2D.
    double
    double
    int
    Returns the arc closure type of the arc: OPEN, CHORD, or PIE.
    Returns the high-precision framing rectangle of the arc.
    Returns the ending point of the arc.
    double
    Note that the arc partially inscribes the framing rectangle of this RectangularShape.
    Returns an iteration object that defines the boundary of the arc.
    Returns the starting point of the arc.
    double
    Note that the arc partially inscribes the framing rectangle of this RectangularShape.
    double
    Note that the arc partially inscribes the framing rectangle of this RectangularShape.
    double
    Note that the arc partially inscribes the framing rectangle of this RectangularShape.
    int
    Returns the hashcode for this Arc2D.
    boolean
    protected Rectangle2D
    makeBounds(double x, double y, double w, double h)
     
    void
    setAngleExtent(double angExt)
    void
    setAngleStart(double angSt)
    void
    setArc(double x, double y, double w, double h, double angSt, double angExt, int closure)
    void
    setArc2(Rectangle2D rect, double angSt, double angExt, int closure)
    Sets the location, size, angular extents, and closure type of this arc to the specified values.
    void
    Sets this arc to be the same as the specified arc.
    void
    setArcByCenter(double x, double y, double radius, double angSt, double angExt, int closure)
    Sets the position, bounds, angular extents, and closure type of this arc to the specified values.
    void
    setArcByTangent(Point2D p1, Point2D p2, Point2D p3, double radius)
    Sets the position, bounds, and angular extents of this arc to the specified value.
    void
    setArcType(int type)
    Sets the closure type of this arc to the specified value: OPEN, CHORD, or PIE.
    void
    setFrame(double x, double y, double w, double h)
    Note that the arc partially inscribes the framing rectangle of this RectangularShape.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • OPEN

      public static final int OPEN
      The closure type for an open arc with no path segments connecting the two ends of the arc segment.
      Since:
      1.2
      See Also:
    • CHORD

      public static final int CHORD
      The closure type for an arc closed by drawing a straight line segment from the start of the arc segment to the end of the arc segment.
      Since:
      1.2
      See Also:
    • PIE

      public static final int PIE
      The closure type for an arc closed by drawing straight line segments from the start of the arc segment to the center of the full ellipse and from that point to the end of the arc segment.
      Since:
      1.2
      See Also:
    • x

      public double x
      The X coordinate of the upper-left corner of the framing rectangle of the arc.
      Since:
      1.2
    • y

      public double y
      The Y coordinate of the upper-left corner of the framing rectangle of the arc.
      Since:
      1.2
    • width

      public double width
      The overall width of the full ellipse of which this arc is a partial section (not considering the angular extents).
      Since:
      1.2
    • height

      public double height
      The overall height of the full ellipse of which this arc is a partial section (not considering the angular extents).
      Since:
      1.2
    • start

      public double start
      The starting angle of the arc in degrees.
      Since:
      1.2
    • extent

      public double extent
      The angular extent of the arc in degrees.
      Since:
      1.2
  • Constructor Details

    • Arc2D

      public Arc2D(double x, double y, double w, double h, double start, double extent, int type)
      Constructs a new arc, initialized to the specified location, size, angular extents, and closure type.
      Parameters:
      x - The X coordinate of the upper-left corner of the arc's framing rectangle.
      y - The Y coordinate of the upper-left corner of the arc's framing rectangle.
      w - The overall width of the full ellipse of which this arc is a partial section.
      h - The overall height of the full ellipse of which this arc is a partial section.
      start - The starting angle of the arc in degrees.
      extent - The angular extent of the arc in degrees.
      type - The closure type for the arc: OPEN, CHORD, or PIE.
      Since:
      1.2
    • Arc2D

      public Arc2D(Rectangle2D ellipseBounds, double start, double extent, int type)
      Constructs a new arc, initialized to the specified location, size, angular extents, and closure type.
      Parameters:
      ellipseBounds - The framing rectangle that defines the outer boundary of the full ellipse of which this arc is a partial section.
      start - The starting angle of the arc in degrees.
      extent - The angular extent of the arc in degrees.
      type - The closure type for the arc: OPEN, CHORD, or PIE.
      Since:
      1.2
    • Arc2D

      protected Arc2D(int type)
      This is an abstract class that cannot be instantiated directly. Type-specific implementation subclasses are available for instantiation and provide a number of formats for storing the information necessary to satisfy the various accessor methods below.
      Parameters:
      type - The closure type of this arc: OPEN, CHORD, or PIE.
      Since:
      1.2
      See Also:
      • Arc2D.Float
      • Arc2D.Double
  • Method Details

    • getX

      public double getX()
      Note that the arc partially inscribes the framing rectangle of this RectangularShape.
      Since:
      1.2
    • getY

      public double getY()
      Note that the arc partially inscribes the framing rectangle of this RectangularShape.
      Since:
      1.2
    • getWidth

      public double getWidth()
      Note that the arc partially inscribes the framing rectangle of this RectangularShape.
      Since:
      1.2
    • getHeight

      public double getHeight()
      Note that the arc partially inscribes the framing rectangle of this RectangularShape.
      Since:
      1.2
    • getAngleStart

      public double getAngleStart()
      Since:
      1.2
    • getAngleExtent

      public double getAngleExtent()
      Since:
      1.2
    • isEmpty

      public boolean isEmpty()
      Since:
      1.2
    • setArc

      public void setArc(double x, double y, double w, double h, double angSt, double angExt, int closure)
      Since:
      1.2
    • setAngleStart

      public void setAngleStart(double angSt)
      Since:
      1.2
    • setAngleExtent

      public void setAngleExtent(double angExt)
      Since:
      1.2
    • getArcType

      public int getArcType()
      Returns the arc closure type of the arc: OPEN, CHORD, or PIE.
      Returns:
      One of the integer constant closure types defined in this class.
      Since:
      1.2
      See Also:
    • getStartPoint

      Returns the starting point of the arc. This point is the intersection of the ray from the center defined by the starting angle and the elliptical boundary of the arc.
      Returns:
      A Point2D object representing the x,y coordinates of the starting point of the arc.
      Since:
      1.2
    • getEndPoint

      public Point2D getEndPoint()
      Returns the ending point of the arc. This point is the intersection of the ray from the center defined by the starting angle plus the angular extent of the arc and the elliptical boundary of the arc.
      Returns:
      A Point2D object representing the x,y coordinates of the ending point of the arc.
      Since:
      1.2
    • setArc2

      public void setArc2(Rectangle2D rect, double angSt, double angExt, int closure)
      Sets the location, size, angular extents, and closure type of this arc to the specified values.
      Parameters:
      rect - The framing rectangle that defines the outer boundary of the full ellipse of which this arc is a partial section.
      angSt - The starting angle of the arc in degrees.
      angExt - The angular extent of the arc in degrees.
      closure - The closure type for the arc: OPEN, CHORD, or PIE.
      Since:
      1.2
    • setArc3

      public void setArc3(Arc2D a)
      Sets this arc to be the same as the specified arc.
      Parameters:
      a - The Arc2D to use to set the arc's values.
      Since:
      1.2
    • setArcByCenter

      public void setArcByCenter(double x, double y, double radius, double angSt, double angExt, int closure)
      Sets the position, bounds, angular extents, and closure type of this arc to the specified values. The arc is defined by a center point and a radius rather than a framing rectangle for the full ellipse.
      Parameters:
      x - The X coordinate of the center of the arc.
      y - The Y coordinate of the center of the arc.
      radius - The radius of the arc.
      angSt - The starting angle of the arc in degrees.
      angExt - The angular extent of the arc in degrees.
      closure - The closure type for the arc: OPEN, CHORD, or PIE.
      Since:
      1.2
    • setArcByTangent

      public void setArcByTangent(Point2D p1, Point2D p2, Point2D p3, double radius)
      Sets the position, bounds, and angular extents of this arc to the specified value. The starting angle of the arc is tangent to the line specified by points (p1, p2), the ending angle is tangent to the line specified by points (p2, p3), and the arc has the specified radius.
      Parameters:
      p1 - The first point that defines the arc. The starting angle of the arc is tangent to the line specified by points (p1, p2).
      p2 - The second point that defines the arc. The starting angle of the arc is tangent to the line specified by points (p1, p2). The ending angle of the arc is tangent to the line specified by points (p2, p3).
      p3 - The third point that defines the arc. The ending angle of the arc is tangent to the line specified by points (p2, p3).
      radius - The radius of the arc.
      Since:
      1.2
    • setArcType

      public void setArcType(int type)
      Sets the closure type of this arc to the specified value: OPEN, CHORD, or PIE.
      Parameters:
      type - The integer constant that represents the closure type of this arc: OPEN, CHORD, or PIE.
      Throws:
      IllegalArgumentException - if type is not 0, 1, or 2.+
      Since:
      1.2
      See Also:
    • setFrame

      public void setFrame(double x, double y, double w, double h)
      Note that the arc partially inscribes the framing rectangle of this RectangularShape.
      Since:
      1.2
    • getBounds2D

      Returns the high-precision framing rectangle of the arc. The framing rectangle contains only the part of this Arc2D that is in between the starting and ending angles and contains the pie wedge, if this Arc2D has a PIE closure type.

      This method differs from the getBounds in that the getBounds method only returns the bounds of the enclosing ellipse of this Arc2D without considering the starting and ending angles of this Arc2D.

      Returns:
      the Rectangle2D that represents the arc's framing rectangle.
      Since:
      1.2
    • makeBounds

      protected Rectangle2D makeBounds(double x, double y, double w, double h)
    • containsAngle

      public boolean containsAngle(double angle)
      Determines whether or not the specified angle is within the angular extents of the arc.
      Parameters:
      angle - The angle to test.
      Returns:
      true if the arc contains the angle, false if the arc doesn't contain the angle.
      Since:
      1.2
    • contains

      public boolean contains(double x, double y)
      Determines whether or not the specified point is inside the boundary of the arc.
      Parameters:
      x - The X coordinate of the point to test.
      y - The Y coordinate of the point to test.
      Returns:
      true if the point lies within the bound of the arc, false if the point lies outside of the arc's bounds.
      Since:
      1.2
    • getPathIterator

      Returns an iteration object that defines the boundary of the arc. This iterator is multithread safe. Arc2D guarantees that modifications to the geometry of the arc do not affect any iterations of that geometry that are already in process.
      Parameters:
      at - an optional AffineTransform to be applied to the coordinates as they are returned in the iteration, or null if the untransformed coordinates are desired.
      Returns:
      A PathIterator that defines the arc's boundary.
      Since:
      1.2
    • hashCode

      public int hashCode()
      Returns the hashcode for this Arc2D.
      Overrides:
      hashCode in class Object
      Returns:
      the hashcode for this Arc2D.
      Since:
      1.6
    • equals

      public boolean equals(Object obj)
      Determines whether or not the specified Object is equal to this Arc2D. The specified Object is equal to this Arc2D if it is an instance of Arc2D and if its location, size, arc extents and type are the same as this Arc2D.
      Overrides:
      equals in class Object
      Parameters:
      obj - an Object to be compared with this Arc2D.
      Returns:
      true if obj is an instance of Arc2D and has the same values; false otherwise.
      Since:
      1.6