The figure interface
The Figure interface is the key interface that defines the role of
figure. It extends VisibleComponent, so it has the
visible property and a pair of paint() methods, and
UserObjectContainer, so it has a field for a semantic object.
A figure can be contained in one or more figure sets (see the next
page for more on figure sets.) One of these must be the parent
returned by getParent(). In the Diva canvas, FigureContainer is
implemented by FigureLayer and AbstractFigureContainer, so the parent
can either be a layer or another figure.
A figure has two methods that return geometry-related objects:
getBounds() and getShape(). The shape is intended for use by anything
that needs a reasonable estimate of the figure's actual shape, but
figures that have very complex shapes may choose to simply return the
bounding box. Both the bounds and the shape are given in the enclosing
transform context of the figure.
Most of the remaining methods in the Figure interface deal with
the figure geometry. The transform() and translate() methods change
the figure's coordinates, either directly or by changing the figure's
associated transform context; contains() and intersects() test if the
figure contains or intersects the given rectangle; hit() is similar to
intersects(), but takes account of transparent regions (such as the
inside of an unfilled rectangle).
Note that Figure inherits repaint() from CanvasComponent. This
method propagates a damage region up the tree, until it gets to the
JCanvas, at which point the appropriate region of the JCanvas is
marked damaged. (This is the region that will later be passed to
paint() if there are no other intervening calls that also damage the
canvas.) repaint() must be called by every client that changes the
appearance of the figure, to ensure that the change becomes visible.
|