Search in sources :

Example 11 with WorkflowAnnotation

use of org.knime.core.node.workflow.WorkflowAnnotation in project knime-core by knime.

the class AbstractWorkflowPortBarEditPart method getMinMaxXcoordInWorkflow.

/**
 * returns the minX coordinate and the maxX coordinate of all nodes, annotations and bendpoints in the flow (taking
 * the size of the elements into account). Or Integer.MIN/MAX_value if no elements exist.
 * @return new int[] {minX, maxX};
 */
protected int[] getMinMaxXcoordInWorkflow() {
    int maxX = Integer.MIN_VALUE;
    int minX = Integer.MAX_VALUE;
    // find the smallest and the biggest X coordinate in all the UI infos in the flow
    WorkflowManagerUI manager = ((WorkflowPortBar) getModel()).getWorkflowManager();
    for (NodeContainerUI nc : manager.getNodeContainers()) {
        int nodeWidth = NodeContainerFigure.WIDTH;
        NodeAnnotation nodeAnno = nc.getNodeAnnotation();
        if ((nodeAnno != null) && (nodeAnno.getWidth() > nodeWidth)) {
            nodeWidth = nodeAnno.getWidth();
        }
        NodeUIInformation uiInfo = nc.getUIInformation();
        if (uiInfo != null) {
            int x = uiInfo.getBounds()[0];
            // right border of node
            x = x + (nodeWidth / 2);
            if (maxX < x) {
                maxX = x;
            }
            // left border of node
            x = x - nodeWidth;
            if (minX > x) {
                minX = x;
            }
        }
    }
    for (WorkflowAnnotation anno : manager.getWorkflowAnnotations()) {
        int x = anno.getX();
        if (minX > x) {
            minX = x;
        }
        x = x + anno.getWidth();
        if (maxX < x) {
            maxX = x;
        }
    }
    for (ConnectionContainerUI conn : manager.getConnectionContainers()) {
        ConnectionUIInformation uiInfo = conn.getUIInfo();
        if (uiInfo != null) {
            int[][] bendpoints = uiInfo.getAllBendpoints();
            if (bendpoints != null) {
                for (int[] b : bendpoints) {
                    if (maxX < b[0]) {
                        maxX = b[0];
                    }
                    if (minX > b[0]) {
                        minX = b[0];
                    }
                }
            }
        }
    }
    return new int[] { minX, maxX };
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) WorkflowPortBar(org.knime.workbench.editor2.model.WorkflowPortBar) NodeAnnotation(org.knime.core.node.workflow.NodeAnnotation) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation) ConnectionContainerUI(org.knime.core.ui.node.workflow.ConnectionContainerUI) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation)

Aggregations

WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)11 NodeID (org.knime.core.node.workflow.NodeID)8 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)7 WorkflowRootEditPart (org.knime.workbench.editor2.editparts.WorkflowRootEditPart)3 ArrayList (java.util.ArrayList)2 EditPartViewer (org.eclipse.gef.EditPartViewer)2 ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)2 ConnectionUIInformation (org.knime.core.node.workflow.ConnectionUIInformation)2 NodeAnnotation (org.knime.core.node.workflow.NodeAnnotation)2 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)2 WorkflowCopyContent (org.knime.core.node.workflow.WorkflowCopyContent)2 WorkflowPersistor (org.knime.core.node.workflow.WorkflowPersistor)2 HashSet (java.util.HashSet)1 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 ZoomManager (org.eclipse.gef.editparts.ZoomManager)1 InputDialog (org.eclipse.jface.dialogs.InputDialog)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 IEditorPart (org.eclipse.ui.IEditorPart)1 Annotation (org.knime.core.node.workflow.Annotation)1