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

Translating a Coordinate System's Origin

Unless specified otherwise, the origin of a Graphics' coordinate system coincides with the upper left-hand corner of its associated component, image or print job, as illustrated in “The Graphics Coordinate System”.

Graphics.translate() can be used to translate the origin to a new location. The translate method is passed two integer values representing a point in the original coordinate system that will become the origin of the translated coordinate system.

Translating a coordinate system's origin is done for numerous reasons; one reason is to scroll the contents of a container without scrollbars, as our next applet illustrates.

The applet shown in Figure 3-12 displays an image that can be scrolled by dragging ...

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