IN THIS CHAPTER
The Basic Java 2D Recipe
Set the Graphics2D Context…
…and Render Something
Rendering on Components
Shape Primitives
Graphics Stroking
Fill Attributes and Painting
Transparency and Compositing
Text
Clipping
Coordinate Space Transformations
Techniques for Graphical User Input
Double Buffering
Comprehensive Example: Kspace Visualization
The Java 2D API extends the Java Advanced Windowing Toolkit (AWT) to provide classes for professional 2D graphics, text, and imaging. The subject of this chapter is the use of Java 2D for graphics and text. Java 2D imaging is the subject of Chapter 4, “The Immediate Mode Imaging Model.”
Keep in mind that, for the most part, all discussion referring to shapes will apply equally to text because for all intents and purposes, text is represented as shapes. Operations such as texture mapping, stroking, and alpha composting can be applied equally to shapes and text.
The key to using Java 2D for graphics is to understand a simple basic programming paradigm that we will refer to as the Basic Java 2D Recipe.