|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object acm.graphics.GObject acm.graphics.GArc
public class GArc
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.
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 (x , y )
with the specified width and height. |
Method Summary | |
---|---|
boolean |
contains(double x,
double y)
Checks to see whether a point is inside the object. |
protected Rectangle |
getAWTBounds()
Returns an AWT Rectangle that specifies the bounds of this object. |
GRectangle |
getBounds()
Returns the bounding box of the arc. |
GPoint |
getEndPoint()
Returns the point at which the arc ends. |
Color |
getFillColor()
Returns the color used to display the filled region of this object. |
GRectangle |
getFrameRectangle()
Returns the bounds of the GRectangle in which this arc is inscribed. |
double |
getStartAngle()
Returns the starting angle for this GArc object. |
GPoint |
getStartPoint()
Returns the point at which the arc starts. |
double |
getSweepAngle()
Returns the sweep angle for this GArc object. |
boolean |
isFilled()
Returns whether this object is filled. |
void |
paint(Graphics g)
Implements the paint operation for this graphical object. |
String |
paramString()
Returns a string indicating the parameters of this object. |
void |
scale(double sf)
Scales the object on the screen by the scale factor sf , which applies
in both dimensions. |
void |
scale(double sx,
double sy)
Scales the object on the screen by the scale factors sx and sy . |
void |
setFillColor(Color color)
Sets the color used to display the filled region of this object. |
void |
setFilled(boolean fill)
Sets whether this object is filled. |
void |
setFrameRectangle(double x,
double y,
double width,
double height)
Changes the arc bounds to the specified values. |
void |
setFrameRectangle(GRectangle bounds)
Changes the arc bounds to the values from the specified GRectangle . |
void |
setStartAngle(double start)
Sets the starting angle for this GArc object. |
void |
setSweepAngle(double sweep)
Sets the sweep angle for this GArc object. |
Methods inherited from class acm.graphics.GObject |
---|
addActionListener, addMouseListener, addMouseMotionListener, areMouseListenersEnabled, colorName, contains, fireActionEvent, fireActionEvent, fireMouseListeners, getColor, getComponent, getHeight, getLocation, getObjectColor, getParent, getSize, getWidth, getX, getY, isVisible, move, movePolar, paintObject, pause, removeActionListener, removeMouseListener, removeMouseMotionListener, repaint, sendBackward, sendForward, sendToBack, sendToFront, setColor, setLocation, setLocation, setParent, setVisible, start, start, toString, updateEnabledList |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final double ARC_TOLERANCE
Constructor Detail |
---|
public GArc(double width, double height, double start, double sweep)
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.
width
- The width of the rectangle in which the arc is inscribedheight
- The height of the rectangle in which the arc is inscribedstart
- The angle at which the arc begins measured in degrees counterclockwise
from the +x axissweep
- The extent of the arc, measured in degrees counterclockwisepublic GArc(double x, double y, double width, double height, double start, double sweep)
GArc
object consisting of an elliptical arc
inscribed in a rectangle located at the point (x
, y
)
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
oclock 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
oclock 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.
x
- The x-coordinate for the rectangle in which the arc is inscribedy
- The y-coordinate for the rectangle in which the arc is inscribedwidth
- The width of the rectangle in which the arc is inscribedheight
- The height of the rectangle in which the arc is inscribedstart
- The angle at which the arc begins measured in degrees counterclockwise
from the +x axissweep
- The extent of the arc, measured in degrees counterclockwiseMethod Detail |
---|
public boolean contains(double x, double y)
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.
contains
in class GObject
x
- The x-coordinate of the point being testedy
- The y-coordinate of the point being tested
true
if the point (x
, y
) is insideprotected Rectangle getAWTBounds()
Rectangle
that specifies the bounds of this object.
Rectangle
that specifies the bounds of this objectpublic GRectangle getBounds()
setFrameRectangle
.
To obtain the bounds used to describe the Java arc, use
getFrameRectangle
.
getBounds
in class GObject
public GPoint getEndPoint()
public Color getFillColor()
getFillColor
returns the color of the
object.
getFillColor
in interface GFillable
public GRectangle getFrameRectangle()
GRectangle
in which this arc is inscribed.
Note that this is usually different from the bounding box returned by
getBounds
, which returns the bounding
box in which the displayed portion of the arc is contained.
GRectangle
in which this arc is inscribedpublic double getStartAngle()
GArc
object.
public GPoint getStartPoint()
public double getSweepAngle()
GArc
object.
public boolean isFilled()
isFilled
in interface GFillable
public void paint(Graphics g)
paint
operation for this graphical object. This method
is not called directly by clients.
paint
in class GObject
g
- The graphics context into which the painting is donepublic String paramString()
paramString
in class GObject
public final void scale(double sf)
sf
, which applies
in both dimensions.
scale
in interface GScalable
sf
- The factor used to scale all coordinates in both dimensionspublic void scale(double sx, double sy)
sx
and sy
.
scale
in interface GScalable
sx
- The factor used to scale all coordinates in the x directionsy
- The factor used to scale all coordinates in the y directionpublic void setFillColor(Color color)
setFillColor
in interface GFillable
color
- The color used to display the filled region of this objectpublic void setFilled(boolean fill)
setFilled
in interface GFillable
fill
- true
if the object should be filled, false
for an outlinepublic void setFrameRectangle(double x, double y, double width, double height)
x
- The x-coordinate for the rectangle in which the arc is inscribedy
- The y-coordinate for the rectangle in which the arc is inscribedwidth
- The width of the rectangle in which the arc is inscribedheight
- The height of the rectangle in which the arc is inscribedpublic final void setFrameRectangle(GRectangle bounds)
GRectangle
.
bounds
- A GRectangle
specifying the new arc boundspublic void setStartAngle(double start)
GArc
object.
start
- The new starting anglepublic void setSweepAngle(double sweep)
GArc
object.
sweep
- The new sweep angle
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |