Class: java.awt.geom.Arc2D
- public abstract class Arc2D
- extends RectangularShape
Arc2D is the abstract superclass for all objects that
store a 2D arc defined by a framing rectangle,
start angle, angular extent (length of the arc), and a closure type
(OPEN, CHORD, or PIE).
The arc is a partial section of a full ellipse which inscribes the framing rectangle of its parent java.awt.geom.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.
The actual storage representation of the coordinates is left to the subclass.
Inheritance
Superclass tree:- java.lang.Object
- java.awt.geom.RectangularShape
- java.awt.geom.Arc2D
Methods
-
Arc2Dtop
Arc2D()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.This constructor creates an object with a default closure type of java.awt.geom.Arc2D.OPEN. It is provided only to enable serialization of subclasses.
-
Arc2Dtop
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. -
containstop
public boolean contains(double x, double y)Determines whether or not the specified point is inside the boundary of the arc. -
containstop
public boolean contains(double x, double y, double w, double h)Determines whether or not the interior of the arc entirely contains the specified rectangle. -
containstop
private boolean contains(double x, double y, double w, double h, Rectangle2D origrect) -
containstop
public boolean contains(Rectangle2D r)Determines whether or not the interior of the arc entirely contains the specified rectangle.- Override hierarchy:
- contains from RectangularShape
-
containsAngletop
public boolean containsAngle(double angle)Determines whether or not the specified angle is within the angular extents of the arc. -
equalstop
public boolean equals(Object obj)Determines whether or not the specifiedObjectis equal to thisArc2D. The specifiedObjectis equal to thisArc2Dif it is an instance ofArc2Dand if its location, size, arc extents and type are the same as thisArc2D. -
getAngleExtenttop
public abstract double getAngleExtent()Returns the angular extent of the arc. -
getAngleStarttop
public abstract double getAngleStart()Returns the starting angle of the arc. -
getArcTypetop
public int getArcType()Returns the arc closure type of the arc: java.awt.geom.Arc2D.OPEN, java.awt.geom.Arc2D.CHORD, or java.awt.geom.Arc2D.PIE. -
getBounds2Dtop
public Rectangle2D getBounds2D()Returns the high-precision framing rectangle of the arc. The framing rectangle contains only the part of thisArc2Dthat is in between the starting and ending angles and contains the pie wedge, if thisArc2Dhas aPIEclosure type.This method differs from the getBounds in that the
getBoundsmethod only returns the bounds of the enclosing ellipse of thisArc2Dwithout considering the starting and ending angles of thisArc2D.- Specified by:
- getBounds2D from Shape
-
getEndPointtop
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. -
getPathIteratortop
public PathIterator getPathIterator(AffineTransform at)Returns an iteration object that defines the boundary of the arc. This iterator is multithread safe.Arc2Dguarantees that modifications to the geometry of the arc do not affect any iterations of that geometry that are already in process.- Specified by:
- getPathIterator from Shape
-
getStartPointtop
public Point2D 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. -
hashCodetop
public int hashCode()Returns the hashcode for thisArc2D. -
intersectstop
public boolean intersects(double x, double y, double w, double h)Determines whether or not the interior of the arc intersects the interior of the specified rectangle.- Specified by:
- intersects from Shape
-
makeBoundstop
abstract protected Rectangle2D makeBounds(double x, double y, double w, double h)Constructs aRectangle2Dof the appropriate precision to hold the parameters calculated to be the framing rectangle of this arc. -
normalizeDegreestop
static double normalizeDegrees(double angle) -
setAngleExtenttop
public abstract void setAngleExtent(double angExt)Sets the angular extent of this arc to the specified double value. -
setAngleStarttop
public abstract void setAngleStart(double angSt)Sets the starting angle of this arc to the specified double value. -
setAngleStarttop
public void setAngleStart(Point2D p)Sets the starting angle of this arc to the angle that the specified point defines relative to the center of this arc. The angular extent of the arc will remain the same. -
setAnglestop
public void setAngles(double x1, double y1, double x2, double y2)Sets the starting angle and angular extent of this arc using two sets of coordinates. The first set of coordinates is used to determine the angle of the starting point relative to the arc's center. The second set of coordinates is used to determine the angle of the end point relative to the arc's center. The arc will always be non-empty and extend counterclockwise from the first point around to the second point. -
setAnglestop
Sets the starting angle and angular extent of this arc using two points. The first point is used to determine the angle of the starting point relative to the arc's center. The second point is used to determine the angle of the end point relative to the arc's center. The arc will always be non-empty and extend counterclockwise from the first point around to the second point. -
setArctop
public abstract void setArc(double x, double y, double w, double h, double angSt, double angExt, int closure)Sets the location, size, angular extents, and closure type of this arc to the specified double values. -
setArctop
public void setArc(Arc2D a)Sets this arc to be the same as the specified arc. -
setArctop
public void setArc(Point2D loc, Dimension2D size, double angSt, double angExt, int closure)Sets the location, size, angular extents, and closure type of this arc to the specified values. -
setArctop
public void setArc(Rectangle2D rect, double angSt, double angExt, int closure)Sets the location, size, angular extents, and closure type of this arc to the specified values. -
setArcByCentertop
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. -
setArcByTangenttop
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. -
setArcTypetop
public void setArcType(int type)Sets the closure type of this arc to the specified value:OPEN,CHORD, orPIE. -
setFrametop
public void setFrame(double x, double y, double w, double h)Sets the location and size of the framing rectangle of thisShapeto the specified rectangular values. Note that the arc partially inscribes the framing rectangle of this RectangularShape.- Override hierarchy:
- setFrame from RectangularShape
Fields
-
CHORD
public static final int CHORD = 1The 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. -
OPEN
public static final int OPEN = 0The closure type for an open arc with no path segments connecting the two ends of the arc segment. -
PIE
public static final int PIE = 2The 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. -
type
private int type
