use of org.eclipse.zest.core.widgets.internal.LoopAnchor in project archi by archimatetool.
the class GraphConnection method doCreateFigure.
private PolylineArcConnection doCreateFigure() {
PolylineArcConnection connectionFigure = cachedOrNewConnectionFigure();
ChopboxAnchor sourceAnchor = null;
ChopboxAnchor targetAnchor = null;
this.connectionLabel = new Label();
Locator labelLocator = null;
if (getSource() == getDestination()) {
// If this is a self loop, create a looped arc and put the locator
// at the top
// of the connection
sourceAnchor = new LoopAnchor(getSource().getNodeFigure());
targetAnchor = new LoopAnchor(getDestination().getNodeFigure());
labelLocator = new MidpointLocator(connectionFigure, 0) {
@Override
protected Point getReferencePoint() {
Point p = Point.SINGLETON;
p.x = getConnection().getPoints().getPoint(getIndex()).x;
p.y = (int) (getConnection().getPoints().getPoint(getIndex()).y - (curveDepth * 1.5));
getConnection().translateToAbsolute(p);
return p;
}
};
} else {
if (curveDepth != 0) {
connectionFigure.setDepth(this.curveDepth);
}
sourceAnchor = new RoundedChopboxAnchor(getSource().getNodeFigure(), 8);
targetAnchor = new RoundedChopboxAnchor(getDestination().getNodeFigure(), 8);
labelLocator = new MidpointLocator(connectionFigure, 0);
}
connectionFigure.setSourceAnchor(sourceAnchor);
connectionFigure.setTargetAnchor(targetAnchor);
connectionFigure.add(this.connectionLabel, labelLocator);
doUpdateFigure(connectionFigure);
return connectionFigure;
}
Aggregations