acm.graphics
Class GArc

java.lang.Object
  |
  +--acm.graphics.GObject
        |
        +--acm.graphics.GArc

public class GArc extends GObject

The GArc class is a graphical object whose appearance consists of an arc. If unfilled, the arc is simply a portion of the circumference of an ellipse; if filled, the arc is a pie-shaped wedge connected to the center of the figure.

[examples forthcoming]


Field Summary
static double ARC_TOLERANCE
This constant defines how close (measured in pixel units) a point has to be to an arc before that point is considered to be "contained" within the arc.
 
Constructor Summary
GArc(double width, double height, double start, double sweep)
Creates a new GArc object consisting of an elliptical arc located at the point (0, 0).
GArc(double x, double y, double width, double height, double start, double sweep)
Creates a new GArc object consisting of an elliptical arc inscribed in a rectangle located at the point (xy) with the specified width and height.
 
Method Summary
boolean contains(double x, double y)
Checks to see whether a point is inside the object.
Point getArcPoint(double angle)
Returns the point on the ellipse for the arc at the specified angle.
Rectangle getBounds()
Returns the bounding box of this object.
double getStart()
Returns the starting angle for this GArc object.
double getSweep()
Returns the sweep angle for this GArc object.
void paint(Graphics g)
Implements the paint operation for this graphical object.
void setStart(double start)
Sets the starting angle for this GArc object.
void setSweep(double sweep)
Sets the sweep angle for this GArc object.
 

Inherited Method Summary
void addMouseListener(MouseListener listener)
Adds a mouse listener to this graphical object. [Inherited from GObject]
void addMouseMotionListener(MouseMotionListener listener)
Adds a mouse motion listener to this graphical object. [Inherited from GObject]
Color getColor()
Returns the color used to display this object. [Inherited from GObject]
Color getFillColor()
Returns the color used to display the filled region of this object. [Inherited from GObject]
double getHeight()
Returns the height of this object. [Inherited from GObject]
Point getLocation()
Returns the nearest Point corresponding to the location of this object. [Inherited from GObject]
Dimension getSize()
Returns the size of this object as a Dimension. [Inherited from GObject]
double getWidth()
Returns the width of this object. [Inherited from GObject]
double getX()
Returns the x-coordinate of the object. [Inherited from GObject]
double getY()
Returns the y-coordinate of the object. [Inherited from GObject]
boolean isFilled()
Returns whether this object is filled. [Inherited from GObject]
boolean isVisible()
Checks to see whether this object is visible. [Inherited from GObject]
void moveToBack()
Moves this object to the back of the display in stacking order. [Inherited from GObject]
void moveToFront()
Moves this object to the front of the display in stacking order. [Inherited from GObject]
void removeMouseListener(MouseListener listener)
Removes a mouse listener from this graphical object. [Inherited from GObject]
void removeMouseMotionListener(MouseMotionListener listener)
Removes a mouse motion listener from this graphical object. [Inherited from GObject]
void scale(double sf)
Scales the object on the screen by the scale factor sf, which applies in both dimensions. [Inherited from GObject]
void scale(double sx, double sy)
Scales the object on the screen by the scale factors sx and sy. [Inherited from GObject]
void setColor(Color c)
Sets the color used to display this object. [Inherited from GObject]
void setFillColor(Color c)
Sets the color used to display the filled region of this object. [Inherited from GObject]
void setFilled(boolean fill)
Sets whether this object is filled. [Inherited from GObject]
void setLocation(double x, double y)
Sets the location of this object to the point (x, y). [Inherited from GObject]
void setSize(double width, double height)
Changes the size of this object to the specified width and height. [Inherited from GObject]
void setVisible(boolean visible)
Sets whether this object is visible. [Inherited from GObject]
void translate(double dx, double dy)
Moves the object on the screen using the displacements dx and dy. [Inherited from GObject]

Field Detail

public static final double ARC_TOLERANCE

This constant defines how close (measured in pixel units) a point has to be to an arc before that point is considered to be "contained" within the arc.
Constructor Detail

public GArc(double width, double height, double start, double sweep)

Creates a new GArc object consisting of an elliptical arc located at the point (0, 0). For complete descriptions of the other parameters, see the entry for the GArc constructor that includes explicit x and y parameters.
 
Usage: GArc garc = new GArc(width, height, start, sweep);
Parameters: 
width  The width of the surrounding rectangle
height  The height of the surrounding rectangle
start  The angle at which the arc begins measured in degrees counterclockwise from the +x axis
sweep  The extent of the arc, measured in degrees counterclockwise
 

public GArc(double x, double y, double width, double height, double start, double sweep)

Creates a new GArc object consisting of an elliptical arc inscribed in a rectangle located at the point (xy) with the specified width and height. The start parameter indicates the angle at which the arc begins and is measured in degrees counterclockwise from the +x axis. Thus, a start angle of 0 indicates an arc that begins along the line running eastward from the center (the 3:00 o’clock position), a start angle of 135 begins along the line running northwest, and a start angle of -90 begins along the line running south (the 6:00 o’clock position). The sweep parameter indicates the extent of the arc and is also measured in degrees counterclockwise. A sweep angle of 90 defines a quarter circle extending counterclockwise from the start angle, and a sweep angle of -180 defines a semicircle extending clockwise.
 
Usage: GArc garc = new GArc(x, y, width, height, start, sweep);
Parameters: 
x  The x-coordinate of the surrounding rectangle
y  The y-coordinate of the surrounding rectangle
width  The width of the surrounding rectangle
height  The height of the surrounding rectangle
start  The angle at which the arc begins measured in degrees counterclockwise from the +x axis
sweep  The extent of the arc, measured in degrees counterclockwise
 
Method Detail

public boolean contains(double x, double y)

Checks to see whether a point is inside the object. For the GArc class, containment depends on whether the arc is filled. Filled arcs are a wedge in which containment can be defined in a natural way; unfilled arcs are essentially lines, which means that containment is defined to mean that the point is within ARC_TOLERANCE pixels of the arc.
 
Usage: if (garc.contains(x, y)) . . .
Parameters: 
x  The x-coordinate of the point being tested
y  The y-coordinate of the point being tested
Returns: true if the point (xy) is inside
 

public Point getArcPoint(double angle)

Returns the point on the ellipse for the arc at the specified angle. The typical use of this method is to return the coordinates of the arc endpoints.
 
Usage: Point pt = garc.getArcPoint(angle)
Parameter: 
angle  The angle at which to locate the point, measured in degrees
Returns: The point on the arc at that angle
 

public Rectangle getBounds()

Returns the bounding box of this object.
 
Usage: Rectangle bounds = garc.getBounds();
Returns: The bounding box of this object
 

public double getStart()

Returns the starting angle for this GArc object.
 
Usage: double start = garc.getStart();
Returns: The starting angle for this arc
 

public double getSweep()

Returns the sweep angle for this GArc object.
 
Usage: double sweep = garc.getSweep();
Returns: The sweep angle for this arc
 

public void paint(Graphics g)

Implements the paint operation for this graphical object. This method is not called directly by clients.

public void setStart(double start)

Sets the starting angle for this GArc object.
 
Usage: garc.setStart(start);
Parameter: 
start  The new starting angle
 

public void setSweep(double sweep)

Sets the sweep angle for this GArc object.
 
Usage: garc.setSweep(sweep);
Parameter: 
sweep  The new sweep angle