Drawing Some Graphics
The central method in Painter is the paint method. This is where all the drawing operations take place—drawing lines, ellipses, rectangles, text, with a wide variety of effects. To make those effects happen, Painter uses Java 2D—that is, Graphics2D objects, not the Graphics objects used in the previous chapters.
To let the user expand and reduce figures interactively while dragging the mouse, Painter uses two different Graphics2D objects—one corresponding to the internal image where the final figure is stored when the user is done drawing, and one corresponding to the window while the user is dragging the mouse. To make the drawing operations easier, the current graphics context is stored in a variable named gImage, and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access