I am using GEF to create a tool that visualises dependencies between files. I successfully managed to do the connections between nodes and I can also switch the functionality to use the ManhattenConnectionRouter
.
However I find trouble using the FanRouter
.
I tried following the logic example that GEF provides, but I still have problems. Unfortunately there is no other tutorial that shows how to implement a FanRouter
.
Here are excerpts of my code:
The base class, implementing the FreeformLayer
:
public class DependencyGraphPart extends AbstractGraphicalEditPart implements LayerConstants {
private DependencyGraphAdapter adapter;
public DependencyGraphPart(){
super();
adapter = new DependencyGraphAdapter();
}
@Override protected IFigure createFigure() {
FreeformLayer layer = new FreeformLayer();
layer.setLayoutManager(new FreeformLayout());
layer.setBorder(new LineBorder(1));
return layer;
}
@Override protected void refreshVisuals(){
ConnectionLayer cLayer = (ConnectionLayer) getLayer(CONNECTION_LAYER);
cLayer.setAntialias(SWT.ON);
AutomaticRouter frouter = new FanRouter();
cLayer.setConnectionRouter(frouter);
}
And here my ConnectionClass:
public class DCDependencyPart extends AbstractConnectionEditPart{
private DCDependencyAdapter adapter;
private Label label;
public DCDependencyPart() {
super();
adapter = new DCDependencyAdapter();
}
@Override protected void createEditPolicies() {
installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new ConnectionEndpointEditPolicy());
}
@Override
protected IFigure createFigure(){
PolylineConnection conn = new PolylineConnection();
conn.setLineWidth(conn.getLineWidth()*2);
conn.setConnectionRouter(new FanRouter());
conn.setTargetDecoration(new PolylineDecoration());
conn.setToolTip(new TooltipFigure());
label = new Label("1");
label.setOpaque(true);
label.setBackgroundColor(ColorConstants.buttonLightest);
label.setBorder(new LineBorder());
conn.add(label, new MidpointLocator (conn, 0));
return conn;
}
When I tried to implement the ManhattenConnectionRouter
I had no problems doing so by just adding it to the Connection-class. (No modification of the DependencyGraphPart
)
These are the two places where I make actively usage of any Router
.
Unfortunately I don't know draw2d and/or GEF well enough to find my problem.