Every Graphics has an associated clipping rectangle. Clipping rectangles are so named because they clip rendering to the rectangle they represent. In addition, with the advent of the Java 2D Api, clipping can be set to an arbitrary shape instead of being restricted to a rectangle.
The methods below, which are repeated from “Graphics Parameters”, are provided by java.awt.Graphics for setting and getting the clipping region:
void setClip(int x, int y, int w, int h)
void clipRect(int x, int y, int w, int h)
The first two methods set the clipping region. The first method sets the clipping region to a rectangle, and while the second sets it to an arbitrary shape.
The next two methods ...