Search in sources :

Example 11 with Connection

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

the class DparallelLocator method getReferencePoint.

@Override
protected Point getReferencePoint() {
    Connection conn = getConnection();
    Point p = Point.SINGLETON;
    Point p1 = conn.getPoints().getPoint(getIndex());
    Point p2 = conn.getPoints().getPoint(getIndex() + 1);
    conn.translateToAbsolute(p1);
    conn.translateToAbsolute(p2);
    p.x = ((p2.x - p1.x) / 9) * 8 + p1.x;
    p.y = ((p2.y - p1.y) / 9) * 8 + p1.y;
    return p;
}
Also used : Connection(org.eclipse.draw2d.Connection) Point(org.eclipse.draw2d.geometry.Point)

Example 12 with Connection

use of org.eclipse.draw2d.Connection in project dbeaver by dbeaver.

the class GraphAnimation method recordFinalState.

public static void recordFinalState(IFigure child) {
    if (child instanceof Connection) {
        recordFinalState((Connection) child);
        return;
    }
    Rectangle rect2 = child.getBounds().getCopy();
    Rectangle rect1 = (Rectangle) initialStates.get(child);
    if (rect1.isEmpty()) {
        rect1.x = rect2.x;
        rect1.y = rect2.y;
        rect1.width = rect2.width;
    }
    finalStates.put(child, rect2);
}
Also used : Connection(org.eclipse.draw2d.Connection) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 13 with Connection

use of org.eclipse.draw2d.Connection in project knime-core by knime.

the class WorkflowConnectionBendpointTracker method updateSourceRequest.

/**
 * {@inheritDoc}
 */
@Override
protected void updateSourceRequest() {
    BendpointRequest request = (BendpointRequest) getSourceRequest();
    // get the currently dragging bendpoint
    Point dragPoint = getLocation();
    WorkflowEditor.adaptZoom(m_zoomManager, dragPoint, false);
    // get the two points next to the dragging bendpoint from the
    // list of all points of the connection
    PointList pList = ((Connection) request.getSource().getFigure()).getPoints();
    Point[] neighbourPoints = getNeighbourPoints(dragPoint, pList);
    // if the neighbours could not be determined to not apply snapping
    if (neighbourPoints == null) {
        request.setLocation(getLocation());
        return;
    }
    double xCorrection = 0.0;
    // check the drag point for all 4 vertical / horizontal lines
    // to snap to those lines
    double diff1 = Math.abs(dragPoint.x - neighbourPoints[0].x);
    if (diff1 < THRESHOLD) {
        xCorrection = diff1;
    }
    double diff2 = Math.abs(dragPoint.x - neighbourPoints[1].x);
    if ((diff2 < THRESHOLD) && (diff2 < diff1)) {
        // always apply the smaller correction
        xCorrection = diff2;
    }
    double yCorrection = 0.0;
    diff1 = Math.abs(dragPoint.y - neighbourPoints[0].y);
    if (diff1 < THRESHOLD) {
        yCorrection = diff1;
    }
    diff2 = Math.abs(dragPoint.y - neighbourPoints[1].y);
    if ((diff2 < THRESHOLD) && (diff2 < diff1)) {
        // always apply the smaller correction
        yCorrection = diff2;
    }
    request.setLocation(getLocation().translate((int) xCorrection, (int) yCorrection));
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) BendpointRequest(org.eclipse.gef.requests.BendpointRequest) Connection(org.eclipse.draw2d.Connection) Point(org.eclipse.draw2d.geometry.Point)

Example 14 with Connection

use of org.eclipse.draw2d.Connection in project dbeaver by serge-rider.

the class GraphAnimation method recordFinalState.

public static void recordFinalState(IFigure child) {
    if (child instanceof Connection) {
        recordFinalState((Connection) child);
        return;
    }
    Rectangle rect2 = child.getBounds().getCopy();
    Rectangle rect1 = (Rectangle) initialStates.get(child);
    if (rect1.isEmpty()) {
        rect1.x = rect2.x;
        rect1.y = rect2.y;
        rect1.width = rect2.width;
    }
    finalStates.put(child, rect2);
}
Also used : Connection(org.eclipse.draw2d.Connection) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 15 with Connection

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

the class RerouteConnectionAction method selectionChanged.

@Override
public void selectionChanged(IAction action, ISelection selection) {
    super.selectionChanged(action, selection);
    if (getSelectedConnection() == null) {
        return;
    }
    Connection figure = getSelectedConnection().getConnectionFigure();
    action.setEnabled(figure != null && figure.getConnectionRouter() instanceof FixedPointsConnectionRouter);
}
Also used : Connection(org.eclipse.draw2d.Connection) FixedPointsConnectionRouter(org.csstudio.opibuilder.editparts.FixedPointsConnectionRouter)

Aggregations

Connection (org.eclipse.draw2d.Connection)20 Point (org.eclipse.draw2d.geometry.Point)11 Rectangle (org.eclipse.draw2d.geometry.Rectangle)7 ArrayList (java.util.ArrayList)5 IFigure (org.eclipse.draw2d.IFigure)4 PointList (org.eclipse.draw2d.geometry.PointList)3 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)2 List (java.util.List)2 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)2 CreateBendpointCommand (com.archimatetool.editor.diagram.commands.CreateBendpointCommand)1 MoveBendpointCommand (com.archimatetool.editor.diagram.commands.MoveBendpointCommand)1 LinkedList (java.util.LinkedList)1 FixedPointsConnectionRouter (org.csstudio.opibuilder.editparts.FixedPointsConnectionRouter)1 ConnectionLayer (org.eclipse.draw2d.ConnectionLayer)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)1 Vector (org.eclipse.draw2d.geometry.Vector)1 EObject (org.eclipse.emf.ecore.EObject)1 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1