Diva
Home
About
Demos
Downloads
Packages
Forum
Mail lists

Figure decorators

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

The diagram shows Decorator together with some of the subclasses implemented in the Diva canvas. Any figure can be decorated by calling the decorate() method of its parent (a FigureContainer). This method must be implemented by containers to place the figure in the decorator and insert the decorator in the tree in its place. Once this has been done, the decorator will receive all paint() calls before the decorated 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 decorator may also decorate another decorator. To allow consistent access to the figures (as opposed to the decorators) that make up the image, the decorator class has methods to access the following related objects:

  • The parent is the immediate parent;
  • The container is the first ancestor that is not a decorator;
  • The child is the child single child of this decorator;
  • The decoratedFigure is the first descendent that is not a decorator.

These relations are shown in this figure:

A simple example of a decorator is the BasicHighlighter class in diva.canvas.toolbox. This class draws a translucent box around its child, and then forwards the paint() call to the child. Another example is the manipulator classes in diva.canvas.manipulator, which draw 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. RenderCache provides caching of a rendered figure, again for use in interactive applications.


Top: The Diva Canvas Design Reference Previous: The figure classes Up: The JCanvas architecture

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