Search in sources :

Example 1 with ConnectionBendpointMoveHandel

use of org.knime.workbench.editor2.editparts.snap.ConnectionBendpointMoveHandel 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)1 List (java.util.List)1 AbsoluteBendpoint (org.eclipse.draw2d.AbsoluteBendpoint)1 Bendpoint (org.eclipse.draw2d.Bendpoint)1 Point (org.eclipse.draw2d.geometry.Point)1 PointList (org.eclipse.draw2d.geometry.PointList)1 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)1 ConnectionBendpointCreationHandel (org.knime.workbench.editor2.editparts.snap.ConnectionBendpointCreationHandel)1 ConnectionBendpointMoveHandel (org.knime.workbench.editor2.editparts.snap.ConnectionBendpointMoveHandel)1