Figure wrappers

A wrapper is a class that has a single child. Wrappers serve a special purpose in the Diva canvas: wrappers are not proper figures, but act as Decorators (in the sense of Gamma et al) for other figures. Typically, wrappers affect that way in which the figure it wraps is rendered.

The diagram shows the place of wrappers together with some of the subclasses implemented in the Diva canvas. Any figure can be wrapped by calling the wrap() method of its parent. This method must be implemented by containers to place the figure in the wrapper and insert the wrapper in the tree in its place. Once this has been done, the wrapper will receive all paint() calls before the wrapped figure, allowing it to draw additional elements on the screen or make other modifications that affect how the figure appears on the screen.

In general, a wrapper may also wrap another wrapper. To allow consistent access to the figures (as opposed to the wrappers) that make up the image, the wrapper class has methods to access the following related objects:

These relations are shown in this figure:

A simple example of a wrapper is the BasicHighlighter class in diva.canvas.toolbox. This class draws a translucent box around its wrapped figure, and then forwards the paint() call to the figure. The class ReshapeManipulator in diva.canvas.interaction draws a set of grab-handles over the top of various points of the child figure.

Other classes shown in the diagram will not be implemented until a future release of Diva. The RenderContext node contains a set of parameters that define the current rendering context, such as the line stroke and rendering style. The RenderQuality node attempts to provide varying levels of rendering quality by adjusting rendering parameters. It is intended for use in typical interactive applications, where rendering quality can be sacrificed for performance during a user interaction. RenderQuality provides caching of a rendered figure, again for use in interactive applications.


Top: The Diva Canvas Previous: The figure classes Up: Figures Next: Feature sets