Diva
Home
About
Demos
Downloads
Packages
Forum
Mail lists

JCanvas architecture

The Diva canvas has a highly structured internal architecture. At the top level of the architecture is an instance of JCanvas, which is a Swing component, and thus embeddable in any Swing user interface. Below that is a tree of graphical components, with the key roles defined by the interfaces in this figure:

The interface that defines the role of every node in the graphical component tree is CanvasComponent. This interface defines methods that traverse the tree upwards. getParent() always returns the immediate parent of the node. getTransformContext() returns the enclosing transform context (see the section on transform contexts). The two repaint methods propagate repaint requests up the tree to the JCanvas and ultimately to the Swing repaint manager (see the section on damage regions).

The interface that extends CanvasComponent with the notion of visibility and paintability is VisibleComponent. It has setVisible() and isVisible() methods, so that display can be turned on and off. The paint() method must be implemented to paint the whole component, while the paint(Rectangle2D) method must paint at least within the given rectangle. This can be used by components to optimize their painting.

The remaining interfaces are explained in more detail on following pages. Here is a diagram illustrating (somewhat inaccurately) how these interfaces are implemented in the key components provided by the canvas (the blue classes are those shown on the figure above):

All of these classes are explained in detail on following pages, but here is an overview. The JCanvas contains a single CanvasPane. Concrete subclasses of CanvasPane contain a stack of CanvasLayers. One in particular, FigureLayer, contains a set of Figures.

Below this level, two forms of structural recursion take place. The first form of recursion is figure containment. The AbstractFigureContainer class is a Figure that contains other figures, and so any concrete subclass is an aggregation of Figures (which may in turn be FigureContainers).

The second form of recursion is pane containment. An instance of PaneWrapper contains a CanvasPane, thus providing a recursive link back to near the top of the canvas architecture. This approach allows a visualization or editing component to be written for a pane, and then easily embedded into any other pane.


Top: The Diva Canvas Design Reference Up: The JCanvas architecture Next: Canvas and panes

Send feedback to cxh at eecs berkeley edu
Contact 
©2002-2018 U.C. Regents