Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.awt.geom.RectangularShape
java.awt.geom.Arc2D
public abstract class Arc2D
extends RectangularShape
Nested Class Summary | |
static class |
|
static class |
|
Field Summary | |
static int |
|
static int |
|
static int |
|
Constructor Summary | |
|
Method Summary | |
boolean |
|
boolean |
|
boolean |
|
boolean |
|
abstract double |
|
abstract double |
|
int |
|
Rectangle2D |
|
Point2D |
|
PathIterator |
|
Point2D |
|
boolean |
|
protected abstract Rectangle2D |
|
abstract void |
|
abstract void |
|
void |
|
void |
|
void | |
abstract void |
|
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
Methods inherited from class java.awt.geom.RectangularShape | |
clone , contains , contains , getBounds , getCenterX , getCenterY , getFrame , getHeight , getMaxX , getMaxY , getMinX , getMinY , getPathIterator , getWidth , getX , getY , intersects , isEmpty , setFrame , setFrame , setFrame , setFrameFromCenter , setFrameFromCenter , setFrameFromDiagonal , setFrameFromDiagonal |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static final int CHORD
A closed arc with a single segment connecting the endpoints (a chord).
- Field Value:
- 1
public static final int OPEN
An open arc, with no segment connecting the endpoints. This type of arc still contains the same points as a chorded version.
- Field Value:
- 0
public static final int PIE
A closed arc with two segments, one from each endpoint, meeting at the center of the ellipse.
- Field Value:
- 2
public boolean contains(double x, double y)
Determines if the arc contains the given point. If the bounding box is empty, then this will return false. The area considered 'inside' an arc of type OPEN is the same as the area inside an equivalent filled CHORD-type arc. The area considered 'inside' a CHORD-type arc is the same as the filled area.
- Parameters:
x
- the x coordinate to testy
- the y coordinate to test
- Returns:
- true if the point is inside the arc
public boolean contains(double x, double y, double w, double h)
Tests if a given rectangle is contained in the area of the arc.
- Parameters:
x
- the x coordinate of the rectangley
- the y coordinate of the rectanglew
- the width of the rectangleh
- the height of the rectangle
- Returns:
- true if the arc contains the rectangle
public boolean contains(Rectangle2D r)
Tests if a given rectangle is contained in the area of the arc.
- Overrides:
- contains in interface RectangularShape
- Parameters:
r
- the rectangle
- Returns:
- true if the arc contains the rectangle
public boolean containsAngle(double a)
Tests if the given angle, in degrees, is included in the arc. All angles are normalized to be between 0 and 360 degrees.
- Parameters:
a
- the angle to test
- Returns:
- true if it is contained
public abstract double getAngleExtent()
Get the extent angle of the arc in degrees.
- Returns:
- the extent angle
- See Also:
setAngleExtent(double)
public abstract double getAngleStart()
Get the starting angle of the arc in degrees.
- Returns:
- the starting angle
- See Also:
setAngleStart(double)
public int getArcType()
Return the closure type of the arc.
- Returns:
- the closure type
- See Also:
OPEN
,CHORD
,PIE
,setArcType(int)
public Rectangle2D getBounds2D()
Gets the bounds of the arc. This is much tighter thangetBounds
, as it takes into consideration the start and end angles, and the center point of a pie wedge, rather than just the overall ellipse.
- Specified by:
- getBounds2D in interface Shape
- Returns:
- the bounds of the arc
- See Also:
getBounds()
public PathIterator getPathIterator(AffineTransform at)
Returns an iterator over this arc, with an optional transformation. This iterator is threadsafe, so future modifications to the arc do not affect the iteration.
- Specified by:
- getPathIterator in interface Shape
- Parameters:
at
- the transformation, or null
- Returns:
- a path iterator
public Point2D getStartPoint()
Returns the starting point of the arc.
- Returns:
- the start point
public boolean intersects(double x, double y, double w, double h)
Tests if a given rectangle intersects the area of the arc. For a definition of the 'inside' area, see the contains() method.
- Specified by:
- intersects in interface Shape
- Parameters:
x
- the x coordinate of the rectangley
- the y coordinate of the rectanglew
- the width of the rectangleh
- the height of the rectangle
- Returns:
- true if the two shapes share common points
- See Also:
contains(double,double)
protected abstract Rectangle2D makeBounds(double x, double y, double w, double h)
Construct a bounding box in a precision appropriate for the subclass.
- Parameters:
x
- the x coordinatey
- the y coordinatew
- the widthh
- the height
- Returns:
- the rectangle for use in getBounds2D
public abstract void setAngleExtent(double extent)
Set the extent, in degrees.
- Parameters:
extent
- the new extent angle
- See Also:
getAngleExtent()
public abstract void setAngleStart(double start)
Set the start, in degrees.
- Parameters:
start
- the new start angle
- See Also:
getAngleStart()
public void setAngleStart(Point2D p)
Sets the starting angle to the angle of the given point relative to the center of the arc. The extent remains constant; in other words, this rotates the arc.
- Parameters:
p
- the new start point
- Throws:
NullPointerException
- if p is null
- See Also:
getStartPoint()
,getAngleStart()
public 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. The arc will be non-empty, and will extend counterclockwise.
- Parameters:
x1
- the first x coordinatey1
- the first y coordinatex2
- the second x coordinatey2
- the second y coordinate
- See Also:
setAngleStart(Point2D)
public 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. The arc will be non-empty, and will extend counterclockwise.
- Parameters:
p1
- the first pointp2
- the second point
- Throws:
NullPointerException
- if either point is null
- See Also:
setAngleStart(Point2D)
public abstract void setArc(double x, double y, double w, double h, double start, double extent, int type)
Set the parameters of the arc. The angles are in degrees, and a positive extent sweeps counterclockwise (from the positive x-axis to the negative y-axis).
- Parameters:
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 ofOPEN
,CHORD
, orPIE
- Throws:
IllegalArgumentException
- if type is invalid
public void setArc(Arc2D a)
Set the parameters of the arc from the given one.
- Parameters:
a
- the arc to copy
- Throws:
NullPointerException
- if a is null
public void setArc(Point2D p, Dimension2D d, double start, double extent, int type)
Set the parameters of the arc. The angles are in degrees, and a positive extent sweeps counterclockwise (from the positive x-axis to the negative y-axis).
- Throws:
IllegalArgumentException
- if type is invalidNullPointerException
- if p or d is null
public void setArc(Rectangle2D r, double start, double extent, int type)
Set the parameters of the arc. The angles are in degrees, and a positive extent sweeps counterclockwise (from the positive x-axis to the negative y-axis).
- Throws:
IllegalArgumentException
- if type is invalidNullPointerException
- if r is null
public void setArcByCenter(double x, double y, double r, double start, double extent, int type)
Set the parameters of the arc. The angles are in degrees, and a positive extent sweeps counterclockwise (from the positive x-axis to the negative y-axis). This controls the center point and radius, so the arc will be circular.
- Throws:
IllegalArgumentException
- if type is invalid
public 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. The arc will be circular, will begin on the tangent point of the line extending from p1 to p2, and will end on the tangent point of the line extending from p2 to p3. XXX What happens if the points are colinear, or the radius negative?
- Parameters:
p1
- the first pointp2
- the tangent line intersection pointp3
- the third pointr
- the radius of the arc
- Throws:
NullPointerException
- if any point is null
public void setArcType(int type)
Set the closure type of this arc.
- Throws:
IllegalArgumentException
- if type is invalid
- See Also:
getArcType()
public 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.
- Overrides:
- setFrame in interface RectangularShape
- Parameters:
x
- the new x coordinatey
- the new y coordinatew
- the new widthh
- the new height
- See Also:
getFrame()