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 ...
Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.