|
Connectors
Connectors are a special kind of figure that joins two other
figures together. Each connector has exactly two sites, the tailSite and
the headSite, that it uses to determine the location of each of its ends,
and in some case, the angle at that end. Each site is attached to a
figure, except in the case of AutonomousSite, which "floats"
independently of any figure. In general, which a figure is moved, the controller
or interactor that is responsible for moving the figure will also tell any
attached connectors to reroute themselves, and hence the connectors appear to
remain attached to the figures.
The route() method of Connector tells it to completely reroute itself, while the
reroute() method tells it to reroute itself based on its current route, with the
intention that this form of routing could be implemented more efficiently. The
headMoved() and tailMoved() methods provide an even finer-grained form of
routing request, in which the connector can optimize the reroute according to
which end moved. AbstractConnector provides default implementations of all of
the methods of Connector except route(). (The other routing methods just call
route().) In addition, it provides a paintable implementation of connectors,
using an instance of diva.canvas.toolbox.PaintedShape. It overrides the
tranfsform() method to do nothing, since it's not reasonable to transform a
connector (the sites determine its location), and marks translate() as abstract
to force concrete subclasses to provide an efficient implementation. In the
Diva canvas, there are currently these connector implementations:
- StraightConnector draw a straight line between its endpoints.
- ArcConnector draws a circular arc between its endpoints. The attribute angle
sets the angle at which the connector strikes the figure, relative to the
line between the centers of the two figures at the ends of the connector.
(The default is 45 degrees.)
Connectors can have a ConnectorEnd object attached to each end. A connector
end is a graphic such as an arrow-head, a diamond or triangle as used in UML,
and so on. Currently, these objects are implemented in the Arrowhead and Blob
classes.
|