Painting of Figures

Figures are painted using a Graphics. The Graphics abstraction allows Draw2d to wrapper an SWT GC for extended functionality as well as performance optimizations. For example, Graphics supports pushing and popping of the current state. A figure paints using the following process:

Z-Order

The result of this process is that a figure composition (which structurally is a tree) paints in a pre-order, depth-first manner. The exception being the borders which are painted post-order. Using push and pop, changes made to the Graphics by one branch of figures have no affect on other branches. The order in which figures paint is often referred to as z-order. This term comes from the fact that the paint order creates the illusion of depth, and the z-axis would be perpendicular to the display's x and y axes. Z-order or paint order is also manifested in the way hit testing is done.

Clipping

When a figure paints its children, it first clips the Graphics to its client area. As each child is painted, the graphics is also clipped to the child's bounds. This prevents the child from painting outside of its bounds or the client area of the parent. Clipping is cumulative based on the entire parent chain. Below, Figure 3 is parented by Figure 2, which is parented by Figure 1.

See Also