The Graphics Coordinate System

The graphics coordinate system is anchored in the upper left-hand corner of a component, with coordinates increasing down and to the right, as depicted in Figure 3-1.

Figure 3-1. Graphics Coordinate System. Circles represent coordinates, and squares represent pixels. Coordinates lie between pixels.

Coordinates lie between pixels of the output device. Operations that draw outlines of shapes, such as Graphics.drawRect(), traverse a coordinate path with a pen that hangs beneath and to the right of the path. The size of the pen is always one pixel wide and one pixel high.

Drawing Shapes

Example 3-1 lists an applet that ...

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.