Search in sources :

Example 1 with RoundedChopboxAnchor

use of org.eclipse.zest.core.widgets.internal.RoundedChopboxAnchor 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;
}
Also used : MidpointLocator(org.eclipse.draw2d.MidpointLocator) Locator(org.eclipse.draw2d.Locator) ChopboxAnchor(org.eclipse.draw2d.ChopboxAnchor) RoundedChopboxAnchor(org.eclipse.zest.core.widgets.internal.RoundedChopboxAnchor) LoopAnchor(org.eclipse.zest.core.widgets.internal.LoopAnchor) MidpointLocator(org.eclipse.draw2d.MidpointLocator) RoundedChopboxAnchor(org.eclipse.zest.core.widgets.internal.RoundedChopboxAnchor) Label(org.eclipse.draw2d.Label) PolylineArcConnection(org.eclipse.zest.core.widgets.internal.PolylineArcConnection) Point(org.eclipse.draw2d.geometry.Point) LayoutBendPoint(org.eclipse.zest.layouts.LayoutBendPoint)

Aggregations

ChopboxAnchor (org.eclipse.draw2d.ChopboxAnchor)1 Label (org.eclipse.draw2d.Label)1 Locator (org.eclipse.draw2d.Locator)1 MidpointLocator (org.eclipse.draw2d.MidpointLocator)1 Point (org.eclipse.draw2d.geometry.Point)1 LoopAnchor (org.eclipse.zest.core.widgets.internal.LoopAnchor)1 PolylineArcConnection (org.eclipse.zest.core.widgets.internal.PolylineArcConnection)1 RoundedChopboxAnchor (org.eclipse.zest.core.widgets.internal.RoundedChopboxAnchor)1 LayoutBendPoint (org.eclipse.zest.layouts.LayoutBendPoint)1