Class Arc2D
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.
- Since:
- 1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe 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.doubleThe angular extent of the arc in degrees.doubleThe overall height of the full ellipse of which this arc is a partial section (not considering the angular extents).static final intThe closure type for an open arc with no path segments connecting the two ends of the arc segment.static final intThe 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.doubleThe starting angle of the arc in degrees.doubleThe overall width of the full ellipse of which this arc is a partial section (not considering the angular extents).doubleThe X coordinate of the upper-left corner of the framing rectangle of the arc.doubleThe Y coordinate of the upper-left corner of the framing rectangle of the arc. -
Constructor Summary
ConstructorsModifierConstructorDescriptionArc2D(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.protectedArc2D(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 TypeMethodDescriptionbooleancontains(double x, double y) Determines whether or not the specified point is inside the boundary of the arc.booleancontainsAngle(double angle) Determines whether or not the specified angle is within the angular extents of the arc.booleanDetermines whether or not the specifiedObjectis equal to thisArc2D.doubledoubleintReturns the high-precision framing rectangle of the arc.Returns the ending point of the arc.doubleNote that the arc partially inscribes the framing rectangle of thisRectangularShape.Returns an iteration object that defines the boundary of the arc.Returns the starting point of the arc.doublegetWidth()Note that the arc partially inscribes the framing rectangle of thisRectangularShape.doublegetX()Note that the arc partially inscribes the framing rectangle of thisRectangularShape.doublegetY()Note that the arc partially inscribes the framing rectangle of thisRectangularShape.inthashCode()Returns the hashcode for thisArc2D.booleanisEmpty()protected Rectangle2DmakeBounds(double x, double y, double w, double h) voidsetAngleExtent(double angExt) voidsetAngleStart(double angSt) voidsetArc(double x, double y, double w, double h, double angSt, double angExt, int closure) voidsetArc2(Rectangle2D rect, double angSt, double angExt, int closure) Sets the location, size, angular extents, and closure type of this arc to the specified values.voidSets this arc to be the same as the specified arc.voidsetArcByCenter(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.voidsetArcByTangent(Point2D p1, Point2D p2, Point2D p3, double radius) Sets the position, bounds, and angular extents of this arc to the specified value.voidsetArcType(int type) Sets the closure type of this arc to the specified value:OPEN,CHORD, orPIE.voidsetFrame(double x, double y, double w, double h) Note that the arc partially inscribes the framing rectangle of thisRectangularShape.
-
Field Details
-
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
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
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
The X coordinate of the upper-left corner of the framing rectangle of the arc.- Since:
- 1.2
-
y
The Y coordinate of the upper-left corner of the framing rectangle of the arc.- Since:
- 1.2
-
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
The overall height of the full ellipse of which this arc is a partial section (not considering the angular extents).- Since:
- 1.2
-
start
The starting angle of the arc in degrees.- Since:
- 1.2
-
extent
The angular extent of the arc in degrees.- Since:
- 1.2
-
-
Constructor Details
-
Arc2D
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, orPIE.- Since:
- 1.2
-
Arc2D
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, orPIE.- Since:
- 1.2
-
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.
-
-
Method Details
-
getX
Note that the arc partially inscribes the framing rectangle of thisRectangularShape.- Since:
- 1.2
-
getY
Note that the arc partially inscribes the framing rectangle of thisRectangularShape.- Since:
- 1.2
-
getWidth
Note that the arc partially inscribes the framing rectangle of thisRectangularShape.- Since:
- 1.2
-
getHeight
Note that the arc partially inscribes the framing rectangle of thisRectangularShape.- Since:
- 1.2
-
getAngleStart
- Since:
- 1.2
-
getAngleExtent
- Since:
- 1.2
-
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
- Since:
- 1.2
-
setAngleExtent
- Since:
- 1.2
-
getArcType
- 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
Point2Dobject representing the x,y coordinates of the starting point of the arc. - Since:
- 1.2
-
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
Point2Dobject representing the x,y coordinates of the ending point of the arc. - Since:
- 1.2
-
setArc2
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, orPIE.- Since:
- 1.2
-
setArc3
Sets this arc to be the same as the specified arc.- Parameters:
a- TheArc2Dto 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, orPIE.- Since:
- 1.2
-
setArcByTangent
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
Sets the closure type of this arc to the specified value:OPEN,CHORD, orPIE.- Parameters:
type- The integer constant that represents the closure type of this arc:OPEN,CHORD, orPIE.- Throws:
IllegalArgumentException- iftypeis not 0, 1, or 2.+- Since:
- 1.2
- See Also:
-
setFrame
Note that the arc partially inscribes the framing rectangle of thisRectangularShape.- Since:
- 1.2
-
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
getBoundsin that thegetBoundsmethod only returns the bounds of the enclosing ellipse of thisArc2Dwithout considering the starting and ending angles of thisArc2D.- Returns:
- the
Rectangle2Dthat represents the arc's framing rectangle. - Since:
- 1.2
-
makeBounds
-
containsAngle
Determines whether or not the specified angle is within the angular extents of the arc.- Parameters:
angle- The angle to test.- Returns:
trueif the arc contains the angle,falseif the arc doesn't contain the angle.- Since:
- 1.2
-
contains
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:
trueif the point lies within the bound of the arc,falseif 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.Arc2Dguarantees that modifications to the geometry of the arc do not affect any iterations of that geometry that are already in process.- Parameters:
at- an optionalAffineTransformto be applied to the coordinates as they are returned in the iteration, or null if the untransformed coordinates are desired.- Returns:
- A
PathIteratorthat defines the arc's boundary. - Since:
- 1.2
-
hashCode
Returns the hashcode for thisArc2D. -
equals
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.
-