Java Reference
In-Depth Information
Adding Fixed Anchor Locations
By default, connections made between Topic s and their subtopics anchor on the
target using one of several anchor points. Although this works well for many dia-
grams, we don't want this in the mindmap. The situation is helped to an extent
by our automatic layout, which nicely anchors links to the right and left of the
topics, but that's not quite where we want them in the case of subtopics. Figure
4-10 is a simple example to illustrate the problem before the layout is added. As
you can see, the target decorators are positioned where the default chopbox
anchor point is calculated, using the center of the figure as a reference point. This
applies to the outgoing source end as well.
A SubSubtopic
A Subtopic
Another SubSubtopic
Topic
Yet Another
Another Subtopic
Figure 4-10
Mindmap chopbox anchors
Preferably, lines should connect at a fixed point for all Topic elements to the
left of the text at the target end. The source end should have the line connect at
a point to the right of the text. Following are SourceFixedConnection
Anchor and TargetFixedConnectionAnchor classes that you can add to the
generated TopicEditPart and Topic2EditPart classes. A root Topic never
needs a target anchor: After a subtopic connection is made, the figure changes.
We're going to ignore relationship links from our layout and don't want them to
be anchored the same as subtopic links, so we're applying our anchors only to
subtopic connections. The code we use is basically stripped-down versions of the
FixedConnectionAnchor provided with the GEF Logic Diagram example.
First, consider the additions to TopicEditPart :
private ConnectionAnchor sourceAnchor;
@Override
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart
connEditPart) {
if (sourceAnchor == null ) {
Search WWH ::




Custom Search