
Table 4−6: Graphics Operations of Java 2D (continued)
Operation Methods Description
Hit detection hit() Tests whether a given rectangle
(in device coordinates) intersects
the interior or outline of an
arbitrary
Shape. Uses the clip,
transfor m, and stroke attributes
when testing the outline of a
Shape.
Text drawing
drawString(),
drawGlyphVector(),
inherited methods
Java 2D defines text-drawing
methods that take
String,
java.text.AttributedCharacter-
Iterator, and java.awt.font.-
GlyphVector arguments. Text
drawing uses the clip, transform,
font, paint, and composite
attributes. Note, however, that
AttributedCharacterIterator
objects supply their own fonts.
Image drawing
drawImage(),
drawRenderableImage(),
drawRenderedImage(),
inherited methods
Java 2D defines new image-
drawing methods that draw
special types of images.
java.awt.image.BufferedImage is
the most important new type.
These methods use the clip,
transfor m, and composite
attributes.
The Coordinate System
By default, Java 2D uses the same coordinate system as AWT. The origin is in the
upper-left corner of the drawing surface. X coordinate values increase to the right,
and Y coordinate values increase as they go down. When drawing to a screen or
an off-scr een image, X and Y coordinates are measur ed in pixels. When drawing
to a printer or other high-resolution device, however, X and Y coordinates are
measur ed in points instead of pixels (and there are 72 points ...