O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Clipping

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 setClip(Shape)

  • Rectangle getClipBounds()

  • Shape getClip()

  • 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required