Chapter 5. Rendering

One of the strengths of the 2D API is that shapes, text, and images can be manipulated in many of the same ways. In this chapter, I'll talk about the four parts of the rendering pipeline that apply to every graphics object:

transforming

Any graphics object can be transformed as it is rendered. A transformation can include translation, rotation, scaling, or shearing, or a combination of all four.

compositing

The process of putting pieces of a picture together is called compositing. The 2D API supports a handful of compositing rules and allows pieces of a picture to be partly or fully transparent.

clipping

Sometimes you don't want to draw outside a certain area, as though you were drawing only the part of a picture that's visible through a door frame. This operation is called clipping. The 2D API allows you to specify any Shape as a clipping path.

rendering hints

Antialiasing is a technique that is used to smooth out the rough edges ("jaggies") of a picture. The 2D rendering engine supports antialiasing and other speed and quality tradeoffs through a mechanism called rendering hints.

Get Java 2D Graphics 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.