APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.awt.geom

public abstract Class Arc2D

extends RectangularShape
Class Inheritance
Known Direct Subclasses
java.awt.geom.Arc2D.Float, java.awt.geom.Arc2D.Double
Imports
java.awt.Rectangle, java.io.IOException, .Serial, .Serializable

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 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.

Author
Jim Graham
Since
1.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Arc2D.Double

This class defines an arc specified in double precision.

public static class
Arc2D.Float

This class defines an arc specified in float precision.

Field Summary

Modifier and TypeField and Description
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.

public static final int
OPEN

The closure type for an open arc with no path segments connecting the two ends of the arc segment.

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.

private int

Constructor Summary

AccessConstructor and Description
protected
Arc2D()

This is an abstract class that cannot be instantiated directly.

protected
Arc2D(int
The closure type of this arc: OPEN, CHORD, or PIE.
type
)

This is an abstract class that cannot be instantiated directly.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the point lies within the bound of the arc, false if the point lies outside of the arc's bounds.
contains
(double
The X coordinate of the point to test.
x
,
double
The Y coordinate of the point to test.
y
)

Implements java.awt.Shape.contains.

Determines whether or not the specified point is inside the boundary of the arc.

public boolean

Returns:

true if the arc contains the rectangle, false if the arc doesn't contain the rectangle.
contains
(double
The X coordinate of the rectangle's upper-left corner.
x
,
double
The Y coordinate of the rectangle's upper-left corner.
y
,
double
The width of the rectangle.
w
,
double
The height of the rectangle.
h
)

Implements java.awt.Shape.contains.

Determines whether or not the interior of the arc entirely contains the specified rectangle.

public boolean

Returns:

true if the arc contains the rectangle, false if the arc doesn't contain the rectangle.
contains
(Rectangle2D
The Rectangle2D to test.
r
)

Overrides java.awt.geom.RectangularShape.contains.

Implements java.awt.Shape.contains.

Determines whether or not the interior of the arc entirely contains the specified rectangle.

private boolean
contains(double x, double y, double w, double h, Rectangle2D origrect)

public boolean

Returns:

true if the arc contains the angle, false if the arc doesn't contain the angle.
containsAngle
(double
The angle to test.
angle
)

Determines whether or not the specified angle is within the angular extents of the arc.

public boolean

Returns:

true if obj is an instance of Arc2D and has the same values; false otherwise.
equals
(Object
an Object to be compared with this Arc2D.
obj
)

Overrides java.lang.Object.equals.

Determines whether or not the specified Object is equal to this Arc2D.

public abstract double

Returns:

A double value that represents the angular extent of the arc in degrees.
getAngleExtent
()

Returns the angular extent of the arc.

public abstract double

Returns:

A double value that represents the starting angle of the arc in degrees.
getAngleStart
()

Returns the starting angle of the arc.

public int

Returns:

One of the integer constant closure types defined in this class.
getArcType
()

Returns the arc closure type of the arc: OPEN, CHORD, or PIE.

public Rectangle
getBounds()

Overrides java.awt.geom.RectangularShape.getBounds.

Implements java.awt.Shape.getBounds.

Returns an integer Rectangle that completely encloses the Shape.

public Rectangle2D
getBounds2D()

Implements java.awt.Shape.getBounds2D.

Returns a high precision and more accurate bounding box of the Shape than the getBounds method.

public Point2D

Returns:

A Point2D object representing the x,y coordinates of the ending point of the arc.
getEndPoint
()

Returns the ending point of the arc.

public PathIterator

Returns:

A PathIterator that defines the arc's boundary.
getPathIterator
(AffineTransform
an optional AffineTransform to be applied to the coordinates as they are returned in the iteration, or null if the untransformed coordinates are desired.
at
)

Implements java.awt.Shape.getPathIterator.

Returns an iteration object that defines the boundary of the arc.

public Point2D

Returns:

A Point2D object representing the x,y coordinates of the starting point of the arc.
getStartPoint
()

Returns the starting point of the arc.

public int

Returns:

the hashcode for this Arc2D.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns the hashcode for this Arc2D.

public boolean

Returns:

true if the arc intersects the rectangle, false if the arc doesn't intersect the rectangle.
intersects
(double
The X coordinate of the rectangle's upper-left corner.
x
,
double
The Y coordinate of the rectangle's upper-left corner.
y
,
double
The width of the rectangle.
w
,
double
The height of the rectangle.
h
)

Implements java.awt.Shape.intersects.

Determines whether or not the interior of the arc intersects the interior of the specified rectangle.

protected abstract Rectangle2D

Returns:

a Rectangle2D that is the framing rectangle of this arc.
makeBounds
(double
The X coordinate of the upper-left corner of the framing rectangle.
x
,
double
The Y coordinate of the upper-left corner of the framing rectangle.
y
,
double
The width of the framing rectangle.
w
,
double
The height of the framing rectangle.
h
)

Constructs a Rectangle2D of the appropriate precision to hold the parameters calculated to be the framing rectangle of this arc.

pack-priv static double
normalizeDegrees(double angle)

public abstract void
setAngleExtent(double
The angular extent of the arc in degrees.
angExt
)

Sets the angular extent of this arc to the specified double value.

public void
setAngles(double
The X coordinate of the arc's starting point.
x1
,
double
The Y coordinate of the arc's starting point.
y1
,
double
The X coordinate of the arc's ending point.
x2
,
double
The Y coordinate of the arc's ending point.
y2
)

Sets the starting angle and angular extent of this arc using two sets of coordinates.

public void
setAngles(Point2D
The Point2D that defines the arc's starting point.
p1
,
Point2D
The Point2D that defines the arc's ending point.
p2
)

Sets the starting angle and angular extent of this arc using two points.

public abstract void
setAngleStart(double
The starting angle of the arc in degrees.
angSt
)

Sets the starting angle of this arc to the specified double value.

public void
setAngleStart(Point2D
The Point2D that defines the starting angle.
p
)

Sets the starting angle of this arc to the angle that the specified point defines relative to the center of this arc.

public abstract void
setArc(double
The X coordinate of the upper-left corner of the arc.
x
,
double
The Y coordinate of the upper-left corner of the arc.
y
,
double
The overall width of the full ellipse of which this arc is a partial section.
w
,
double
The overall height of the full ellipse of which this arc is a partial section.
h
,
double
The starting angle of the arc in degrees.
angSt
,
double
The angular extent of the arc in degrees.
angExt
,
int
The closure type for the arc: OPEN, CHORD, or PIE.
closure
)

Sets the location, size, angular extents, and closure type of this arc to the specified double values.

public void
setArc(Point2D
The Point2D representing the coordinates of the upper-left corner of the arc.
loc
,
Dimension2D
The Dimension2D representing the width and height of the full ellipse of which this arc is a partial section.
size
,
double
The starting angle of the arc in degrees.
angSt
,
double
The angular extent of the arc in degrees.
angExt
,
int
The closure type for the arc: OPEN, CHORD, or PIE.
closure
)

Sets the location, size, angular extents, and closure type of this arc to the specified values.

public void
setArc(Rectangle2D
The framing rectangle that defines the outer boundary of the full ellipse of which this arc is a partial section.
rect
,
double
The starting angle of the arc in degrees.
angSt
,
double
The angular extent of the arc in degrees.
angExt
,
int
The closure type for the arc: OPEN, CHORD, or PIE.
closure
)

Sets the location, size, angular extents, and closure type of this arc to the specified values.

public void
setArc(Arc2D
The Arc2D to use to set the arc's values.
a
)

Sets this arc to be the same as the specified arc.

public void
setArcByCenter(double
The X coordinate of the center of the arc.
x
,
double
The Y coordinate of the center of the arc.
y
,
double
The radius of the arc.
radius
,
double
The starting angle of the arc in degrees.
angSt
,
double
The angular extent of the arc in degrees.
angExt
,
int
The closure type for the arc: OPEN, CHORD, or PIE.
closure
)

Sets the position, bounds, angular extents, and closure type of this arc to the specified values.

public void
setArcByTangent(Point2D
The first point that defines the arc. The starting angle of the arc is tangent to the line specified by points (p1, p2).
p1
,
Point2D
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).
p2
,
Point2D
The third point that defines the arc. The ending angle of the arc is tangent to the line specified by points (p2, p3).
p3
,
double
The radius of the arc.
radius
)

Sets the position, bounds, and angular extents of this arc to the specified value.

public void
setArcType(int
The integer constant that represents the closure type of this arc: OPEN, CHORD, or PIE.
type
)

Sets the closure type of this arc to the specified value: OPEN, CHORD, or PIE.

public void
setFrame(double x, double y, double w, double h)

Implements abstract java.awt.geom.RectangularShape.setFrame.

Sets the location and size of the framing rectangle of this Shape to the specified rectangular values.

Inherited from java.awt.geom.RectangularShape:
clonecontainsgetCenterXgetCenterYgetFramegetHeightgetMaxXgetMaxYgetMinXgetMinYgetPathIteratorgetWidthgetXgetYintersectsisEmptysetFramesetFramesetFrameFromCentersetFrameFromCentersetFrameFromDiagonalsetFrameFromDiagonal