java.awt.geom
Class Arc2D
- Cloneable, Shape
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.
static class | Arc2D.Double - This class implements an arc in double precision.
|
static class | Arc2D.Float - This class implements an arc in float precision.
|
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.
|
Arc2D(int type) - Create a new arc, with the specified closure type.
|
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.
|
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 | 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 | setArc(double x, double y, double w, double h, double start, double extent, int type) - Set the parameters of the arc.
|
void | setArc(Arc2D a) - Set the parameters of the arc from the given one.
|
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.
|
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 |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
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.
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.
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.
- contains in interface Shape
x
- the x coordinate to testy
- the y coordinate to test
- 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.
- contains in interface Shape
x
- the x coordinate of the rectangley
- the y coordinate of the rectanglew
- the width of the rectangleh
- the height of the rectangle
- 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.
All angles are normalized to be between 0 and 360 degrees.
getAngleExtent
public abstract double getAngleExtent()
Get the extent angle of the arc in degrees.
getAngleStart
public abstract double getAngleStart()
Get the starting angle of the arc in degrees.
getArcType
public int getArcType()
Return the closure type of the arc.
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.
- getBounds2D in interface Shape
intersects
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.
- intersects in interface Shape
x
- the x coordinate of the rectangley
- the y coordinate of the rectanglew
- the width of the rectangleh
- the height of the rectangle
- true if the two shapes share common points
makeBounds
protected abstract Rectangle2D makeBounds(double x,
double y,
double w,
double h)
Construct a bounding box in a precision appropriate for the subclass.
x
- the x coordinatey
- the y coordinatew
- the widthh
- the height
- the rectangle for use in getBounds2D
setAngleExtent
public abstract void setAngleExtent(double extent)
Set the extent, in degrees.
extent
- the new extent angle
setAngleStart
public abstract void setAngleStart(double start)
Set the start, in degrees.
start
- the new start angle
setAngleStart
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.
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.
x1
- the first x coordinatey1
- the first y coordinatex2
- the second x coordinatey2
- the second y coordinate
setAngles
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.
p1
- the first pointp2
- the second point
setArc
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).
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
setArc
public void setArc(Arc2D a)
Set the parameters of the arc from the given one.
setArc
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).
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
setArc
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).
r
- the new bounding boxstart
- the start angle, in degreesextent
- the arc extent, in degreestype
- one of OPEN
, CHORD
, or PIE
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.
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
setArcByTangent
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?
p1
- the first pointp2
- the tangent line intersection pointp3
- the third pointr
- the radius of the arc
setArcType
public void setArcType(int type)
Set the closure type of this arc.
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.
- setFrame in interface RectangularShape
x
- the new x coordinatey
- the new y coordinatew
- the new widthh
- the new height
Arc2D.java -- represents an arc in 2-D space
Copyright (C) 2002, 2003, 2004 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.