Java Reference
In-Depth Information
In our
MindmapEditPartProvider
, we similarly add a
Map
and override
getEdgeEditPart()
to return our new
SubtopicEditPart
class.
public class
MindmapEditPartProvider
extends
AbstractEditPartProvider {
private final
Map<String, Class<?>> edgeMap =
new
HashMap<String,
Class<?>>();
{
edgeMap.put("Subtopic", SubtopicEditPart.
class
);
}
// . . .
@Override
protected
Class getEdgeEditPartClass(View view) {
return
(Class) edgeMap.get(view.getType());
}
}
Finally, we add our
SubtopicEditPart
, which simply returns a new
PolylineConnectionEx
as our link figure.
public class
SubtopicEditPart
extends
ConnectionNodeEditPart {
public
SubtopicEditPart(View view) {
super
(view);
}
@Override
protected
Connection createConnectionFigure() {
if
(getModel() ==
null
) {
return null;
}
Connection connection =
new
PolylineConnectionEx();
return
connection;
}
}
At this point, we can draw
Topic
rectangles and solid links between them to
signify subtopic relationships, as shown in Figure 10-53. Without labels to indi-
cate our
Topic
names on the diagram, it's still not terribly useful. Providing
usable labels requires a bit of work that we'd rather generate, so let's move to the
next section and compare this manual implementation of a simple mindmap with
that generated by the tooling component. For another example of contributing a
parser provider for labels, see Section 4.6.7, “Custom Parsers.”
Search WWH ::
Custom Search