Search in sources :

Example 1 with PolylineArcConnection

use of org.eclipse.zest.core.widgets.internal.PolylineArcConnection 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)

Example 2 with PolylineArcConnection

use of org.eclipse.zest.core.widgets.internal.PolylineArcConnection in project archi by archimatetool.

the class GraphConnection method doUpdateFigure.

private void doUpdateFigure(Connection connection) {
    if (connection == null || this.isDisposed()) {
        return;
    }
    Shape connectionShape = (Shape) connection;
    connectionShape.setLineStyle(getLineStyle());
    if (this.getText() != null || this.getImage() != null) {
        // Label l = new Label(this.getText(), this.getImage());
        if (this.getImage() != null) {
            this.connectionLabel.setIcon(this.getImage());
        }
        if (this.getText() != null) {
            this.connectionLabel.setText(this.getText());
        }
        this.connectionLabel.setFont(this.getFont());
    }
    if (highlighted) {
        connectionShape.setForegroundColor(getHighlightColor());
        connectionShape.setLineWidth(getLineWidth() * 2);
    } else {
        connectionShape.setForegroundColor(getLineColor());
        connectionShape.setLineWidth(getLineWidth());
    }
    if (connection instanceof PolylineArcConnection) {
        PolylineArcConnection arcConnection = (PolylineArcConnection) connection;
        arcConnection.setDepth(curveDepth);
    }
    if ((connectionStyle & ZestStyles.CONNECTIONS_DIRECTED) > 0) {
        PolygonDecoration decoration = new PolygonDecoration();
        if (getLineWidth() < 3) {
            decoration.setScale(9, 3);
        } else {
            double logLineWith = getLineWidth() / 2.0;
            decoration.setScale(7 * logLineWith, 3 * logLineWith);
        }
        ((PolylineConnection) connection).setTargetDecoration(decoration);
    }
    IFigure toolTip;
    if (this.getTooltip() == null && getText() != null && getText().length() > 0 && hasCustomTooltip == false) {
        toolTip = new Label();
        ((Label) toolTip).setText(getText());
    } else {
        toolTip = this.getTooltip();
    }
    connection.setToolTip(toolTip);
}
Also used : Shape(org.eclipse.draw2d.Shape) PolygonDecoration(org.eclipse.draw2d.PolygonDecoration) Label(org.eclipse.draw2d.Label) PolylineArcConnection(org.eclipse.zest.core.widgets.internal.PolylineArcConnection) PolylineConnection(org.eclipse.draw2d.PolylineConnection) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

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