Java Reference
In-Depth Information
The Java Graphics Class
TheJavaGraphicsclassisanabstractbaseclassthatallowsapplicationsto
drawontothevariousdevices,aswellascreatingoff-screenimages.A
Graphicsobjectcontainsinformationthatdefinesthebasicrenderingop-
erations.Thisstateinformationincludesthefollowingproperties:
TheComponentobjectonwhichdrawingtakesplace
Atranslationoriginforrenderingandforclippingcoordinates
Thecurrentclippingrectangle
Thecurrentcolor
Thecurrentfont
Thecurrentlogicalpixeloperationfunction
ThecurrentXORalternationcolor
Someoftheseattributes,suchastheComponent,thetranslationori-
gin,thecolorandthefont,havealreadybeenmentioned.InJava,render-
ingoperationsmodifyonlypixelswhichliewithintheareaboundedby
thecurrentclippingrectangle,oneoftheattributesofthegraphicsob-
ject. Table27-2 listssomeofthemethodsintheJavaGraphicsclass.
Table 27-2
Commonly Used Method the Graphics Class
RETURNS
METHOD/ACTION
abstract
void
clearRect(int x, int y, int width, int height)
Clears the specified rectangle byfilling it with
the current background color.
abstract
void
clipRect(int x, int y, int width, int height)
Intersects the current clip with the specified rectangle.
abstract
void
copyArea(int x, int y, int width, int height, int dx,
int dy)
Copies an area of the component distance in dx and dy.
abstract
Graphics create()
Creates a new Graphics object that is a copyof the
current one.
Graphics create(int x, int y, int width, int height)
Creates a new Graphics object based on this Graphics
object, but with a new translation and clip area.
(continues)
 
Search WWH ::




Custom Search