
object retur ned by the getOutline() or getGlyphOutline() method of Glyph-
Vector can be used in the same way that you use any other Shape object. Use the
draw() method of Graphics2D to draw the outline of the glyph or glyphs. Use
fill() to fill the glyphs with an arbitrary Paint.You can transform the glyph
shapes by scaling, rotating, and skewing them and you can even use them to per-
for m clipping and hit detection.
Buffered Images
Java 2D introduces a new java.awt.Image subclass, java.awt.image.BufferedIm-
age. BufferedImage repr esents image data that is present in memory, unlike Image,
which typically repr esents str eaming image data being transferred over a network.
Java 2D also provides powerful image-processing classes that operate on
BufferedImage objects and are much simpler to use than the ImageFilter class of
Java 1.0.
As we discussed at the beginning of the chapter, Java knows how to read images
in commonly used formats from files and URLs. You can use the
getImage()
method of either Applet() or Toolkit to retrieve an Image, but the image data
may not have been fully read when the method retur ns. If you want to ensure that
the image is fully loaded, you have to use a
java.awt.MediaTracker. Note also
that both of these methods retur nread-only
Image objects, rather than read/write
BufferedImage objects.
If you are writing a Swing application, an easy way to load an image is with the
javax.swing.ImageIcon ...