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 });
}
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;
}
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();
}
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);
}
}
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();
}
Aggregations