Search in sources :

Example 16 with NodeUIInformation

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

the class NodeUIInformationTest method testBuilderAndGetter.

@Test
public void testBuilderAndGetter() {
    NodeUIInformation uiinf = NodeUIInformation.builder().setHasAbsoluteCoordinates(false).setIsDropLocation(true).setIsSymbolRelative(false).setSnapToGrid(true).setNodeLocation(10, 11, 13, 15).translate(new int[] { 2, 3 }).build();
    assertEquals(uiinf.hasAbsoluteCoordinates(), false);
    assertEquals(uiinf.isSymbolRelative(), false);
    assertEquals(uiinf.isDropLocation(), true);
    assertEquals(uiinf.getSnapToGrid(), true);
    assertArrayEquals(uiinf.getBounds(), new int[] { 12, 14, 13, 15 });
}
Also used : NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) Test(org.junit.Test)

Example 17 with NodeUIInformation

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

the class WorkflowEditor method getLocationRightOf.

private Point getLocationRightOf(final NodeContainerEditPart refNode) {
    NodeUIInformation ui = refNode.getNodeContainer().getUIInformation();
    int xOffset = 100;
    int yOffset = 120;
    // adjust offset to grid location
    if (getEditorSnapToGrid()) {
        // with grid enabled we use the grid size as offset (but at least a bit mire than the node width)
        xOffset = getEditorGridXOffset((int) (refNode.getFigure().getBounds().width * 1.1));
        yOffset = getEditorGridYOffset((int) (refNode.getFigure().getBounds().height * 1.1));
    }
    // first try: right of reference node
    Point loc = new Point(ui.getBounds()[0] + xOffset, ui.getBounds()[1]);
    // make sure we have a free spot
    while (isNodeAtAbs(loc)) {
        // move it down a bit
        loc.y += yOffset;
    }
    return loc;
}
Also used : NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) Point(org.eclipse.draw2d.geometry.Point) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint) Point(org.eclipse.draw2d.geometry.Point) PrecisionPoint(org.eclipse.draw2d.geometry.PrecisionPoint)

Example 18 with NodeUIInformation

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

the class AbstractCreateNewConnectedNodeCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    m_newNode = createNewNode();
    if (m_newNode != null) {
        if (m_connectTo != null) {
            autoConnectNewNode();
        }
        NodeContainer newNode = getHostWFM().getNodeContainer(m_newNode);
        NodeUIInformation uiInfo = newNode.getUIInformation();
        // create extra info and set it
        if (uiInfo == null) {
            uiInfo = NodeUIInformation.builder().setNodeLocation(m_location.x, m_location.y, -1, -1).build();
        } else {
            uiInfo = NodeUIInformation.builder(uiInfo).setNodeLocation(m_location.x, m_location.y, uiInfo.getBounds()[2], uiInfo.getBounds()[3]).build();
        }
        newNode.setUIInformation(uiInfo);
    }
    // make sure the new node is selected and visible
    m_viewer.deselectAll();
}
Also used : NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) NodeContainer(org.knime.core.node.workflow.NodeContainer)

Example 19 with NodeUIInformation

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

the class ChangeNodeBoundsCommand method undo.

/**
 * Sets the old bounds.
 *
 * @see org.eclipse.gef.commands.Command#execute()
 */
@Override
public void undo() {
    if (!Arrays.equals(m_oldBounds, m_newBounds)) {
        NodeUIInformation information = NodeUIInformation.builder().setNodeLocation(m_oldBounds[0], m_oldBounds[1], m_oldBounds[2], m_oldBounds[3]).build();
        NodeContainer container = getHostWFM().getNodeContainer(m_nodeID);
        container.setUIInformation(information);
    }
}
Also used : NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) NodeContainer(org.knime.core.node.workflow.NodeContainer)

Example 20 with NodeUIInformation

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

the class ChangeWorkflowPortBarCommand method execute.

/**
 * Sets the new bounds.
 *
 * @see org.eclipse.gef.commands.Command#execute()
 */
@Override
public void execute() {
    WorkflowPortBar barModel = (WorkflowPortBar) m_bar.getModel();
    NodeUIInformation uiInfo = NodeUIInformation.builder().setNodeLocation(m_newBounds.x, m_newBounds.y, m_newBounds.width, m_newBounds.height).build();
    // must set explicitly so that event is fired by container
    barModel.setUIInfo(uiInfo);
    IFigure fig = m_bar.getFigure();
    fig.setBounds(m_newBounds);
    fig.getParent().setConstraint(fig, m_newBounds);
    m_bar.getParent().refresh();
}
Also used : WorkflowPortBar(org.knime.workbench.editor2.model.WorkflowPortBar) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)31 NodeID (org.knime.core.node.workflow.NodeID)11 ConnectionUIInformation (org.knime.core.node.workflow.ConnectionUIInformation)8 NodeContainer (org.knime.core.node.workflow.NodeContainer)7 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)7 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)7 WorkflowPortBar (org.knime.workbench.editor2.model.WorkflowPortBar)7 ConnectionID (org.knime.core.node.workflow.ConnectionID)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)5 Point (org.eclipse.draw2d.geometry.Point)4 Rectangle (org.eclipse.draw2d.geometry.Rectangle)4 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)4 MessageBox (org.eclipse.swt.widgets.MessageBox)3 NodeAnnotation (org.knime.core.node.workflow.NodeAnnotation)3 WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)3 ArrayList (java.util.ArrayList)2 IFigure (org.eclipse.draw2d.IFigure)2 Test (org.junit.Test)2