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

Variable Index

 o arcAngle
The number of degress the arc encompasses.
 o boundingRect
A rectangle which encloses the circle the arc lies upon.
 o bulge
The amount of "bulge" in the arc.
 o R2D
The number of degrees in a radian.
 o radius
The radius of the arc.
 o startAngle
The direction from the center of the circle to the start of the arc, in degrees (0 degrees is 3 o'clock).
 o xC
X coordinate of center of the circle the arc lies on.
 o yC
Y coordinate of center of the circle the arc lies on.

Constructor Index

 o Arc(int, int, int, int, int, boolean)
Constructs an arc, figuring out the appropriate radius and center given the endpoints and offset.

Method Index

 o draw(Graphics)
Draws the arc.
 o findDirection(Point, Point)
Figure out the direction from one point to another.
 o getRectangle()
Gets a rectangle that the arc fits into.
 o isCloser(Point, int)
Checks whether the point is within a given distance from the arc.
 o toString()
Gets a string describing the arc.

Variables

 o R2D
 private final double R2D
The number of degrees in a radian.

 o 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.

 o xC
 private int xC
X coordinate of center of the circle the arc lies on.

 o yC
 private int yC
Y coordinate of center of the circle the arc lies on.

 o radius
 private int radius
The radius of the arc. As a special case, zero means to draw a straight line instead of an arc;

 o boundingRect
 private Rectangle boundingRect
A rectangle which encloses the circle the arc lies upon. Used in drawing the arc.

 o arcAngle
 private int arcAngle
The number of degress the arc encompasses. Used in drawing the arc.

 o 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.

Constructors

 o 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.

Methods

 o 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
 o getRectangle
 private Rectangle getRectangle()
Gets a rectangle that the arc fits into.

Returns:
The rectangle which encloses the circle the arc lies upon.
 o 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
 o 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.
 o toString
 public String toString()
Gets a string describing the arc.

Returns:
A string describing the arc object.
Overrides:
toString in class Line