Java Reference
In-Depth Information
9.1.4 Layout
Draw2d provides layout using two steps: first by marking figures as invalid if
they need layout, and second by validating “branches” of invalid figures. Layout
occurs all at once because Draw2d employs a deferred update strategy and,
therefore, avoids displaying intermediate states when multiple figures become
invalid.
Draw2d uses the term validation to perform layout. The validate()
method can be extended to perform other functions that require integration with
the update manager. When the validate() method is called, a figure performs
its layout and then validates its children.
Layout requires information on the size of children figures, so methods are
provided for querying minimum, maximum, and preferred sizes. If you know an
available dimension, you can pass it as a hint to a figure when querying, which
instructs the figure to consider the dimension when it returns its size requirements.
If a figure changes so that layout is required, it calls revalidate() to mark
itself as invalid and requesting revalidation on its parent. This continues up the
hierarchy and ends with an entry in the update manager's list of invalid figures.
The update manager performs top-down layout by first setting the bounds of the
parent and calling validate() on its children.
9.1.5 Connections and Routing
Draw2d provides a connection to form a line between two points. A
PolylineConnection holds source and target ConnectionAnchor elements.
A ConnectionRouter manages end and intermediate points along the line.
Figure 9-6 illustrates a connection and its associated elements.
Labels placed using
ConnectionLocators
Endpoint
u
2
v
PolylineDecoration
Midpoint
Anchor Location
1
PolylineConnection
Figure 9-6
Polyline connection
The main difference between a connection and regular figures is that the
ConnectionRouter is responsible for setting its bounds. Specialized routers can
 
Search WWH ::




Custom Search