Class Arc
java.lang.Object
|
+----Line
|
+----Arc
- public class Arc
- extends Line
Utility class to represent an arc connecting two points.
- Version:
- $Revision: 1.5 $, $Date: 2000/10/30 17:03:31 $
- Author:
- John Cavanaugh
-
arcAngle
- The number of degress the arc encompasses.
-
boundingRect
- A rectangle which encloses the circle the arc lies upon.
-
bulge
- The amount of "bulge" in the arc.
-
R2D
- The number of degrees in a radian.
-
radius
- The radius of the arc.
-
startAngle
- The direction from the center of the circle to the start of
the arc, in degrees (0 degrees is 3 o'clock).
-
xC
- X coordinate of center of the circle the arc lies on.
-
yC
- Y coordinate of center of the circle the arc lies on.
-
Arc(int, int, int, int, int, boolean)
- Constructs an arc, figuring out the appropriate radius
and center given the endpoints and offset.
-
draw(Graphics)
- Draws the arc.
-
findDirection(Point, Point)
- Figure out the direction from one point to another.
-
getRectangle()
- Gets a rectangle that the arc fits into.
-
isCloser(Point, int)
- Checks whether the point is within a given distance from the arc.
-
toString()
- Gets a string describing the arc.
R2D
private final double R2D
- The number of degrees in a radian.
bulge
private int bulge
- The amount of "bulge" in the arc. This is the maximum number of
pixels that the arc departs from a straight line.
xC
private int xC
- X coordinate of center of the circle the arc lies on.
yC
private int yC
- Y coordinate of center of the circle the arc lies on.
radius
private int radius
- The radius of the arc. As a special case, zero means to draw
a straight line instead of an arc;
boundingRect
private Rectangle boundingRect
- A rectangle which encloses the circle the arc lies upon. Used
in drawing the arc.
arcAngle
private int arcAngle
- The number of degress the arc encompasses. Used in drawing
the arc.
startAngle
private int startAngle
- The direction from the center of the circle to the start of
the arc, in degrees (0 degrees is 3 o'clock). Use in drawing
the arc.
Arc
public Arc(int x1,
int y1,
int x2,
int y2,
int bulge,
boolean direction)
- Constructs an arc, figuring out the appropriate radius
and center given the endpoints and offset.
- Parameters:
- x1 - X coordinate of first endpoint.
- y1 - Y coordinate of first endpoint.
- x2 - X coordinate of second endpoint.
- y2 - Y coordinate of second endpoint.
- bulge - The amount of bend in the arc.
- direction - A switch indicating whether the center is
"above" or "below" a line between the
endpoints.
draw
public void draw(Graphics g)
- Draws the arc. The color must be set in advance.
- Parameters:
- g - The graphics context for the drawing area.
- Overrides:
- draw in class Line
getRectangle
private Rectangle getRectangle()
- Gets a rectangle that the arc fits into.
- Returns:
- The rectangle which encloses the circle the arc
lies upon.
isCloser
public boolean isCloser(Point p,
int delta)
- Checks whether the point is within a given distance from the arc.
- Parameters:
- p - A point.
- delta - A distance.
- Returns:
- True if the point is within delta units of the
arc; false otherwise.
- Overrides:
- isCloser in class Line
findDirection
private double findDirection(Point a,
Point b)
- Figure out the direction from one point to another.
- Parameters:
- a - the starting point.
- b - the destination.
- Returns:
- the direction in radians from point a to
point b.
toString
public String toString()
- Gets a string describing the arc.
- Returns:
- A string describing the arc object.
- Overrides:
- toString in class Line