Every Java 2D drawing operation can ultimately be treated as filling a shape using a paint and compositing the result onto the screen.
The composite, given the source and destination pixels, produces the final result that ultimately ends up onscreen.
Every Java 2D operation is subject to a transform, so that shapes may be translated, rotated, sheared, and scaled as they are drawn.
For instance, an infinitely thin line segment (with no interior) might be stroked into a one-pixel-wide rectangle.
Conceptually, drawing a straight black line in Java 2D can be thought of as creating a line segment, transforming it according to the current transform, stroking it to create a thin rectangle, querying this shape to compute the pixels being affected, generating the pixels using java.awt.Color.BLACK, and then compositing the results onto the screen.
Java 2D therefore optimizes common drawing operations so that many of these steps can be skipped.
For simplicity, the textual examples provided in this article have assumed that the screen is the destination device.
Since Java SE 6, Java2D and OpenGL have become interoperable, allowing, for example, the drawing of animated 3D graphics instead of icons on a Button (see JOGL).