Java Reference
In-Depth Information
Table 27-2
Commonly Used Method the Graphics Class (continued)
RETURNS
METHOD/ACTION
boolean
hitClip(int x, int y, int width, int height)
Returns true if the specified rectangular area intersects
the bounding rectangle of the current clipping area.
abstract
void
setClip(int x, int y, int width, int height)
Sets the current clip to the rectangle specified bythe
given coordinates.
abstract
void
setClip(Shape clip)
Sets the current clipping area to an arbitraryclip shape.
abstract
void
setColor(Color c)
Sets this graphics context's current color.
abstract
void
setFont(Font font)
Sets this graphics context's font.
abstract
void
setPaintMode()
Sets the paint mode of this graphics context to
overwrite the destination with this graphics context's
current color.
abstract
void
setXORMode(Color c1)
Sets the paint mode of this graphics context to
alternate between this graphics context's current color
and the new specified color.
String
toString()
Returns a String object representing this Graphics
object's value.
abstract
void
translate(int x, int y)
Translates the origin of the graphics context to the point
(x, y) in the current coordinate system.
Vector-Based Drawing
Several methods of the Graphics class allow drawing straight and curved
lines on a graphics object. For example, to draw a filled oval you can use the
fillOval() method. The method draws a solid ellipse or circle, as follows:
g.fillOval(50, 60, 200, 100);
———-—-
| | | |__ height of bounding rectangle
| | |_______ width of bounding rectangle
| |___________ y of upper left corner
|_______________ x of upper left corner
Search WWH ::




Custom Search