|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.geom.RectangularShape
java.awt.geom.Arc2D
public abstract class Arc2D
This class represents all arcs (segments of an ellipse in 2-D space). The arcs are defined by starting angle and extent (arc length) in degrees, as opposed to radians (like the rest of Java), and can be open, chorded, or wedge shaped. The angles are skewed according to the ellipse, so that 45 degrees always points to the upper right corner (positive x, negative y) of the bounding rectangle. A positive extent draws a counterclockwise arc, and while the angle can be any value, the path iterator only traverses the first 360 degrees. Storage is up to the subclasses.
Nested Class Summary | |
---|---|
static class |
Arc2D.Double
This class implements an arc in double precision. |
static class |
Arc2D.Float
This class implements an arc in float precision. |
Field Summary | |
---|---|
static int |
CHORD
A closed arc with a single segment connecting the endpoints (a chord). |
static int |
OPEN
An open arc, with no segment connecting the endpoints. |
static int |
PIE
A closed arc with two segments, one from each endpoint, meeting at the center of the ellipse. |
Constructor Summary | |
---|---|
protected |
Arc2D(int type)
Create a new arc, with the specified closure type. |
Method Summary | |
---|---|
boolean |
contains(double x,
double y)
Determines if the arc contains the given point. |
boolean |
contains(double x,
double y,
double w,
double h)
Tests if a given rectangle is contained in the area of the arc. |
boolean |
contains(Rectangle2D r)
Tests if a given rectangle is contained in the area of the arc. |
boolean |
containsAngle(double a)
Tests if the given angle, in degrees, is included in the arc. |
abstract double |
getAngleExtent()
Get the extent angle of the arc in degrees. |
abstract double |
getAngleStart()
Get the starting angle of the arc in degrees. |
int |
getArcType()
Return the closure type of the arc. |
Rectangle2D |
getBounds2D()
Gets the bounds of the arc. |
Point2D |
getEndPoint()
Returns the ending point of the arc. |
PathIterator |
getPathIterator(AffineTransform at)
Returns an iterator over this arc, with an optional transformation. |
Point2D |
getStartPoint()
Returns the starting point of the arc. |
boolean |
intersects(double x,
double y,
double w,
double h)
Tests if a given rectangle intersects the area of the arc. |
protected abstract Rectangle2D |
makeBounds(double x,
double y,
double w,
double h)
Construct a bounding box in a precision appropriate for the subclass. |
abstract void |
setAngleExtent(double extent)
Set the extent, in degrees. |
void |
setAngles(double x1,
double y1,
double x2,
double y2)
Sets the starting and extent angles to those of the given points relative to the center of the arc. |
void |
setAngles(Point2D p1,
Point2D p2)
Sets the starting and extent angles to those of the given points relative to the center of the arc. |
abstract void |
setAngleStart(double start)
Set the start, in degrees. |
void |
setAngleStart(Point2D p)
Sets the starting angle to the angle of the given point relative to the center of the arc. |
void |
setArc(Arc2D a)
Set the parameters of the arc from the given one. |
abstract void |
setArc(double x,
double y,
double w,
double h,
double start,
double extent,
int type)
Set the parameters of the arc. |
void |
setArc(Point2D p,
Dimension2D d,
double start,
double extent,
int type)
Set the parameters of the arc. |
void |
setArc(Rectangle2D r,
double start,
double extent,
int type)
Set the parameters of the arc. |
void |
setArcByCenter(double x,
double y,
double r,
double start,
double extent,
int type)
Set the parameters of the arc. |
void |
setArcByTangent(Point2D p1,
Point2D p2,
Point2D p3,
double r)
Sets the parameters of the arc by finding the tangents of two lines, and using the specified radius. |
void |
setArcType(int type)
Set the closure type of this arc. |
void |
setFrame(double x,
double y,
double w,
double h)
Sets the location and bounds of the ellipse of which this arc is a part. |
Methods inherited from class java.awt.geom.RectangularShape |
---|
clone, contains, getBounds, getCenterX, getCenterY, getFrame, getHeight, getMaxX, getMaxY, getMinX, getMinY, getPathIterator, getWidth, getX, getY, intersects, isEmpty, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int OPEN
public static final int CHORD
public static final int PIE
Constructor Detail |
---|
protected Arc2D(int type)
type
- one of OPEN
, CHORD
, or PIE
.
IllegalArgumentException
- if type is invalidMethod Detail |
---|
public abstract double getAngleStart()
setAngleStart(double)
public abstract double getAngleExtent()
setAngleExtent(double)
public int getArcType()
OPEN
,
CHORD
,
PIE
,
setArcType(int)
public Point2D getStartPoint()
public Point2D getEndPoint()
public abstract void setArc(double x, double y, double w, double h, double start, double extent, int type)
x
- the new x coordinate of the upper left of the bounding boxy
- the new y coordinate of the upper left of the bounding boxw
- the new width of the bounding boxh
- the new height of the bounding boxstart
- the start angle, in degreesextent
- the arc extent, in degreestype
- one of OPEN
, CHORD
, or PIE
IllegalArgumentException
- if type is invalidpublic void setArc(Point2D p, Dimension2D d, double start, double extent, int type)
p
- the upper left point of the bounding boxd
- the dimensions of the bounding boxstart
- the start angle, in degreesextent
- the arc extent, in degreestype
- one of OPEN
, CHORD
, or PIE
IllegalArgumentException
- if type is invalid
NullPointerException
- if p or d is nullpublic void setArc(Rectangle2D r, double start, double extent, int type)
r
- the new bounding boxstart
- the start angle, in degreesextent
- the arc extent, in degreestype
- one of OPEN
, CHORD
, or PIE
IllegalArgumentException
- if type is invalid
NullPointerException
- if r is nullpublic void setArc(Arc2D a)
a
- the arc to copy
NullPointerException
- if a is nullpublic void setArcByCenter(double x, double y, double r, double start, double extent, int type)
x
- the x coordinate of the center of the circley
- the y coordinate of the center of the circler
- the radius of the circlestart
- the start angle, in degreesextent
- the arc extent, in degreestype
- one of OPEN
, CHORD
, or PIE
IllegalArgumentException
- if type is invalidpublic void setArcByTangent(Point2D p1, Point2D p2, Point2D p3, double r)
p1
- the first pointp2
- the tangent line intersection pointp3
- the third pointr
- the radius of the arc
NullPointerException
- if any point is nullpublic abstract void setAngleStart(double start)
start
- the new start anglegetAngleStart()
public abstract void setAngleExtent(double extent)
extent
- the new extent anglegetAngleExtent()
public void setAngleStart(Point2D p)
p
- the new start point
NullPointerException
- if p is nullgetStartPoint()
,
getAngleStart()
public void setAngles(double x1, double y1, double x2, double y2)
x1
- the first x coordinatey1
- the first y coordinatex2
- the second x coordinatey2
- the second y coordinatesetAngleStart(Point2D)
public void setAngles(Point2D p1, Point2D p2)
p1
- the first pointp2
- the second point
NullPointerException
- if either point is nullsetAngleStart(Point2D)
public void setArcType(int type)
type
- one of OPEN
, CHORD
, or PIE
IllegalArgumentException
- if type is invalidgetArcType()
public void setFrame(double x, double y, double w, double h)
setFrame
in class RectangularShape
x
- the new x coordinatey
- the new y coordinatew
- the new widthh
- the new heightRectangularShape.getFrame()
public Rectangle2D getBounds2D()
getBounds
, as it takes into consideration the start and
end angles, and the center point of a pie wedge, rather than just the
overall ellipse.
RectangularShape.getBounds()
protected abstract Rectangle2D makeBounds(double x, double y, double w, double h)
x
- the x coordinatey
- the y coordinatew
- the widthh
- the height
public boolean containsAngle(double a)
a
- the angle to test
public boolean contains(double x, double y)
x
- the x coordinate to testy
- the y coordinate to test
public boolean intersects(double x, double y, double w, double h)
x
- the x coordinate of the rectangley
- the y coordinate of the rectanglew
- the width of the rectangleh
- the height of the rectangle
contains(double, double)
public boolean contains(double x, double y, double w, double h)
x
- the x coordinate of the rectangley
- the y coordinate of the rectanglew
- the width of the rectangleh
- the height of the rectangle
Area
public boolean contains(Rectangle2D r)
contains
in interface Shape
contains
in class RectangularShape
r
- the rectangle
Shape.contains(double, double, double, double)
public PathIterator getPathIterator(AffineTransform at)
at
- the transformation, or null
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |