Java Reference
In-Depth Information
demonstratedtheresultofdoingsoin
Figure7-17
.IfIhadnotdoneso,youwouldhave
seen the window shown in
Figure 7-23
.
Figure 7-23.
Applying the default
SRC_OVER
rule with an alpha value of 1.0.
Clipping Shape
Graphics2D
declares
void clip(Shape clipShape)
and inherits
void
setClip(Shape clipShape)
from
Graphics
forsettingtheclippingshapeat-
tribute. Call
clip()
to make the overall clipping shape smaller; call
setClip()
to make the overall clipping shape larger. Pass any object whose class implements the
java.awt.Shape
interface to
clipShape
. Call
Shape getClip()
(inherited
from
Graphics
) to return the current clipping shape; null returns when the clipping
shape is the entire drawing surface.
Java 2D provides a collection of
Shape
implementation classes. Also, the
java.awt.Polygon
class that predates Java 2D has been retrofitted to implement