java.awt.geom
Class Arc2D
java.lang.Object
|
+--java.awt.geom.RectangularShape
|
+--java.awt.geom.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.
Since:Author:- Eric Blake <ebb9@email.byu.edu>
boolean | contains(double x, double y)
|
boolean | contains(double x, double y, double w, double h)
|
boolean | contains(java.awt.geom.Rectangle2D r)
|
boolean | containsAngle(double a)
|
double | getAngleExtent()
|
double | getAngleStart()
|
int | getArcType()
|
java.awt.geom.Rectangle2D | getBounds2D()
|
java.awt.geom.Point2D | getEndPoint()
|
java.awt.geom.PathIterator | getPathIterator(java.awt.geom.AffineTransform at)
|
java.awt.geom.Point2D | getStartPoint()
|
boolean | intersects(double x, double y, double w, double h)
|
java.awt.geom.Rectangle2D | makeBounds(double x, double y, double w, double h)
|
void | setAngleExtent(double extent)
|
void | setAngleStart(double start)
|
void | setAngleStart(java.awt.geom.Point2D p)
|
void | setAngles(double x1, double y1, double x2, double y2)
|
void | setAngles(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2)
|
void | setArc(double x, double y, double w, double h, double start, double extent, int type)
|
void | setArc(java.awt.geom.Point2D p, java.awt.geom.Dimension2D d, double start, double extent, int type)
|
void | setArc(java.awt.geom.Rectangle2D r, double start, double extent, int type)
|
void | setArc(java.awt.geom.Arc2D a)
|
void | setArcByCenter(double x, double y, double r, double start, double extent, int type)
|
void | setArcByTangent(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2, java.awt.geom.Point2D p3, double r)
|
void | setArcType(int type)
|
void | setFrame(double x, double y, double w, double h)
|
CHORD
public static final int CHORD
A closed arc with a single segment connecting the endpoints (a chord).
OPEN
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.
PIE
public static final int PIE
A closed arc with two segments, one from each endpoint, meeting at the
center of the ellipse.
Arc2D
protected Arc2D(int type)
Create a new arc, with the specified closure type.
Parameters:
Throws:
contains
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.
Parameters:
Returns:
- true if the point is inside the arc
contains
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:
Returns:
- true if the arc contains the rectangle
contains
public boolean contains(java.awt.geom.Rectangle2D r)
Tests if a given rectangle is contained in the area of the arc.
Parameters:
Returns:
- true if the arc contains the rectangle
containsAngle
public boolean containsAngle(double a)
Tests if the given angle, in degrees, is included in the arc.
XXX Does this normalize all angles to -180 - 180 first?
Parameters:
Returns:
getAngleExtent
public double getAngleExtent()
Get the extent angle of the arc in degrees.
Returns:
See Also:
getAngleStart
public double getAngleStart()
Get the starting angle of the arc in degrees.
Returns:
See Also:
getArcType
public int getArcType()
Return the closure type of the arc.
Returns:
See Also:
getBounds2D
public Rectangle2D getBounds2D()
Gets the bounds of the arc. This is much tighter than
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.
Returns:
See Also:
getEndPoint
public Point2D getEndPoint()
Returns the ending point of the arc.
Returns:
getPathIterator
public PathIterator getPathIterator(java.awt.geom.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.
Parameters:
Returns:
getStartPoint
public Point2D getStartPoint()
Returns the starting point of the arc.
Returns:
intersects
public boolean intersects(double x, double y, double w, double h)
Tests if a given rectangle intersects the area of the arc.
Parameters:
Returns:
- true if the two shapes share common points
makeBounds
protected Rectangle2D makeBounds(double x, double y, double w, double h)
Construct a bounding box in a precision appropriate for the subclass.
Parameters:
Returns:
- the rectangle for use in getBounds2D
setAngleExtent
public void setAngleExtent(double extent)
Set the extent, in degrees.
Parameters:
See Also:
setAngleStart
public void setAngleStart(double start)
Set the start, in degrees.
Parameters:
See Also:
setAngleStart
public void setAngleStart(java.awt.geom.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:
Throws:
See Also:
setAngles
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:
See Also:
setAngles
public void setAngles(java.awt.geom.Point2D p1, java.awt.geom.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:
Throws:
See Also:
setArc
public 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:
Throws:
setArc
public void setArc(java.awt.geom.Arc2D a)
Set the parameters of the arc from the given one.
Parameters:
Throws:
setArc
public void setArc(java.awt.geom.Point2D p, java.awt.geom.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).
Parameters:
Throws:
setArc
public void setArc(java.awt.geom.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).
Parameters:
Throws:
setArcByCenter
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.
Parameters:
Throws:
setArcByTangent
public void setArcByTangent(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2, java.awt.geom.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:
Throws:
setArcType
public void setArcType(int type)
Set the closure type of this arc.
Parameters:
Throws:
See Also:
setFrame
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.
Parameters:
See Also: