When a figure is modified (let's say, its color changed), it calls its repaint() method. repaint() creates a DamageRegion object, which contains a reference to this figure and the region it damaged, and passes it to its parent figure. By default, the damaged region is simply the bounding box of the figure. (The DamageRegion instances are static to avoid the cost of allocating them on the heap.) This call propagates upwards until it reaches the JCanvas, which calls the DamageRegion object's apply() method. This method transforms the damage region into screen coordinates, and calls Swing's RepaintManager to schedule a future paint operation of that region.
(Currently, all damage regions are rectangles. In the future, we hope to support non-rectangular damage regions to allow more efficient repainting of long multi-segment lines.)
Some time later, Swing's event loop runs again, and calls the paint(Graphics2D) method of the JCanvas. Swing has already set a clip region in the Graphics2D object (the graphics drawing port), so the JCanvas extracts this, converts it to the pane's coordinate system, and passes it to the pane. From then on, the paint request propagates downwards, except that: