Search in sources :

Example 1 with ConnectionAnchor

use of org.eclipse.draw2d.ConnectionAnchor in project tdi-studio-se by Talend.

the class LookupConnectionRouter method getEndDirection.

protected Vector getEndDirection(Connection conn) {
    ConnectionAnchor anchor = conn.getTargetAnchor();
    Point p = getEndPoint(conn);
    Rectangle rect;
    if (anchor.getOwner() == null) {
        rect = new Rectangle(p.x - 1, p.y - 1, 2, 2);
    } else {
        rect = conn.getTargetAnchor().getOwner().getBounds().getCopy();
        conn.getTargetAnchor().getOwner().translateToAbsolute(rect);
    }
    return getDirection(rect, p);
}
Also used : ConnectionAnchor(org.eclipse.draw2d.ConnectionAnchor) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point)

Example 2 with ConnectionAnchor

use of org.eclipse.draw2d.ConnectionAnchor in project yamcs-studio by yamcs.

the class PatchedConnectionLayerClippingStrategy method getEdgeClippingRectangle.

@Override
protected Rectangle[] getEdgeClippingRectangle(Connection connection) {
    // start with clipping the connection at its original bounds
    Rectangle clipRect = getAbsoluteBoundsAsCopy(connection);
    // in case we cannot infer source and target of the connection (e.g.
    // if XYAnchors are used), returning the bounds is all we can do
    ConnectionAnchor sourceAnchor = connection.getSourceAnchor();
    ConnectionAnchor targetAnchor = connection.getTargetAnchor();
    if (sourceAnchor == null || sourceAnchor.getOwner() == null || targetAnchor == null || targetAnchor.getOwner() == null) {
        return new Rectangle[] { clipRect };
    }
    // source and target figure are known, see if there is common
    // viewport
    // the connection has to be clipped at.
    IFigure sourceFigure = sourceAnchor.getOwner();
    IFigure targetFigure = targetAnchor.getOwner();
    if (!sourceFigure.isShowing() || !targetFigure.isShowing())
        return new Rectangle[] {};
    return super.getEdgeClippingRectangle(connection);
}
Also used : ConnectionAnchor(org.eclipse.draw2d.ConnectionAnchor) Rectangle(org.eclipse.draw2d.geometry.Rectangle) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with ConnectionAnchor

use of org.eclipse.draw2d.ConnectionAnchor in project yamcs-studio by yamcs.

the class WidgetNodeEditPolicy method getConnectionCreateCommand.

@Override
protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
    AbstractWidgetModel source = getWidgetEditPart().getWidgetModel();
    ConnectionAnchor anchor = getWidgetEditPart().getSourceConnectionAnchor(request);
    String sourceTerminal = getWidgetEditPart().getTerminalNameFromAnchor(anchor);
    ConnectionCreateCommand cmd = new ConnectionCreateCommand(source, sourceTerminal);
    request.setStartCommand(cmd);
    return cmd;
}
Also used : ConnectionAnchor(org.eclipse.draw2d.ConnectionAnchor) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) ConnectionCreateCommand(org.csstudio.opibuilder.commands.ConnectionCreateCommand)

Example 4 with ConnectionAnchor

use of org.eclipse.draw2d.ConnectionAnchor in project whole by wholeplatform.

the class ChildrenBranchesFigure method createTargetAnchors.

@Override
protected ConnectionAnchor[] createTargetAnchors() {
    @SuppressWarnings("unchecked") List<IFigure> children = getContentPane(0).getChildren();
    int childrenSize = children.size();
    if (childrenSize == 0)
        return NO_ANCHORS;
    else {
        ConnectionAnchor[] anchors = new ConnectionAnchor[childrenSize];
        for (int i = 0; i < childrenSize; i++) {
            IFigure child = children.get(i);
            if (child instanceof INodeFigure) {
                // TODO x size
                anchors[i] = ((INodeFigure) child).getTargetAnchor(0);
            } else
                anchors[i] = AnchorFactory.createLeftMiddleAnchor(child);
        }
        return anchors;
    }
}
Also used : ConnectionAnchor(org.eclipse.draw2d.ConnectionAnchor) INodeFigure(org.whole.lang.ui.figures.INodeFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 5 with ConnectionAnchor

use of org.eclipse.draw2d.ConnectionAnchor in project whole by wholeplatform.

the class AbstractStyledLayout method getChildPoint.

protected Point getChildPoint(int index, IFigure childFigure) {
    if (childFigure instanceof INodeFigure) {
        Point absoluteRootPoint = new Point(getRootPoint());
        childFigure.translateToAbsolute(absoluteRootPoint);
        ConnectionAnchor targetAnchor = ((INodeFigure) childFigure).getClosestTargetAnchor(absoluteRootPoint, getDistanceMetric());
        if (targetAnchor != null) {
            Point childPoint = targetAnchor.getLocation(absoluteRootPoint);
            childFigure.translateToRelative(childPoint);
            return childPoint;
        }
    }
    return getChildPoint2(index, childFigure);
}
Also used : ConnectionAnchor(org.eclipse.draw2d.ConnectionAnchor) INodeFigure(org.whole.lang.ui.figures.INodeFigure) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

ConnectionAnchor (org.eclipse.draw2d.ConnectionAnchor)18 Point (org.eclipse.draw2d.geometry.Point)9 IFigure (org.eclipse.draw2d.IFigure)8 INodeFigure (org.whole.lang.ui.figures.INodeFigure)7 Rectangle (org.eclipse.draw2d.geometry.Rectangle)5 ArrayList (java.util.ArrayList)4 ConnectionCreateCommand (org.csstudio.opibuilder.commands.ConnectionCreateCommand)2 Iterator (java.util.Iterator)1 List (java.util.List)1 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)1 AnchorListener (org.eclipse.draw2d.AnchorListener)1 ChopboxAnchor (org.eclipse.draw2d.ChopboxAnchor)1 Figure (org.eclipse.draw2d.Figure)1 EditPart (org.eclipse.gef.EditPart)1 INodeConnector (org.talend.core.model.process.INodeConnector)1 ConnectionFigure (org.talend.designer.core.ui.editor.connections.ConnectionFigure)1 DummyConnectionFigure (org.talend.designer.core.ui.editor.connections.DummyConnectionFigure)1