Search in sources :

Example 1 with ConnectionBendpointCreationHandel

use of org.knime.workbench.editor2.editparts.snap.ConnectionBendpointCreationHandel in project knime-core by knime.

the class ConnectionBendpointEditPolicy method createHandlesForAutomaticBendpoints.

private List createHandlesForAutomaticBendpoints() {
    List<ConnectionBendpointCreationHandel> list = new ArrayList<ConnectionBendpointCreationHandel>();
    ConnectionEditPart connEP = (ConnectionEditPart) getHost();
    PointList points = getConnection().getPoints();
    for (int i = 0; i < points.size() - 1; i++) {
        list.add(new ConnectionBendpointCreationHandel(connEP, 0, i));
    }
    return list;
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) ArrayList(java.util.ArrayList) AbsoluteBendpoint(org.eclipse.draw2d.AbsoluteBendpoint) Point(org.eclipse.draw2d.geometry.Point) Bendpoint(org.eclipse.draw2d.Bendpoint) ConnectionBendpointCreationHandel(org.knime.workbench.editor2.editparts.snap.ConnectionBendpointCreationHandel)

Example 2 with ConnectionBendpointCreationHandel

use of org.knime.workbench.editor2.editparts.snap.ConnectionBendpointCreationHandel in project knime-core by knime.

the class ConnectionBendpointEditPolicy method createHandlesForUserBendpoints.

private List createHandlesForUserBendpoints() {
    List<Object> list = new ArrayList<Object>();
    ConnectionEditPart connEP = (ConnectionEditPart) getHost();
    PointList points = getConnection().getPoints();
    List bendPoints = (List) getConnection().getRoutingConstraint();
    int bendPointIndex = 0;
    Point currBendPoint = null;
    if (bendPoints == null) {
        bendPoints = NULL_CONSTRAINT;
    } else if (!bendPoints.isEmpty()) {
        currBendPoint = ((Bendpoint) bendPoints.get(0)).getLocation();
    }
    for (int i = 0; i < points.size() - 1; i++) {
        // Put a create handle on the middle of every segment
        list.add(new ConnectionBendpointCreationHandel(connEP, bendPointIndex, i));
        // move handle
        if (i < points.size() - 1 && bendPointIndex < bendPoints.size() && currBendPoint.equals(points.getPoint(i + 1))) {
            list.add(new ConnectionBendpointMoveHandel(connEP, bendPointIndex, i + 1));
            // Go to the next user bendpoint
            bendPointIndex++;
            if (bendPointIndex < bendPoints.size()) {
                currBendPoint = ((Bendpoint) bendPoints.get(bendPointIndex)).getLocation();
            }
        }
    }
    return list;
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) ConnectionBendpointMoveHandel(org.knime.workbench.editor2.editparts.snap.ConnectionBendpointMoveHandel) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) PointList(org.eclipse.draw2d.geometry.PointList) List(java.util.List) Point(org.eclipse.draw2d.geometry.Point) AbsoluteBendpoint(org.eclipse.draw2d.AbsoluteBendpoint) Bendpoint(org.eclipse.draw2d.Bendpoint) AbsoluteBendpoint(org.eclipse.draw2d.AbsoluteBendpoint) Point(org.eclipse.draw2d.geometry.Point) Bendpoint(org.eclipse.draw2d.Bendpoint) ConnectionBendpointCreationHandel(org.knime.workbench.editor2.editparts.snap.ConnectionBendpointCreationHandel)

Aggregations

ArrayList (java.util.ArrayList)2 AbsoluteBendpoint (org.eclipse.draw2d.AbsoluteBendpoint)2 Bendpoint (org.eclipse.draw2d.Bendpoint)2 Point (org.eclipse.draw2d.geometry.Point)2 PointList (org.eclipse.draw2d.geometry.PointList)2 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)2 ConnectionBendpointCreationHandel (org.knime.workbench.editor2.editparts.snap.ConnectionBendpointCreationHandel)2 List (java.util.List)1 ConnectionBendpointMoveHandel (org.knime.workbench.editor2.editparts.snap.ConnectionBendpointMoveHandel)1