use of org.knime.core.node.workflow.NodeUIInformation in project knime-core by knime.
the class HorizAlignCommand method undo.
/**
* {@inheritDoc}
*/
@Override
public void undo() {
Map<NodeID, NodeUIInformation> oldPositions = m_alignMgr.getOldNodeCoordinates();
Map<ConnectionID, ConnectionUIInformation> oldBendpoints = m_alignMgr.getOldBendpoints();
// re-position nodes
for (Map.Entry<NodeID, NodeUIInformation> e : oldPositions.entrySet()) {
NodeContainer nc = m_wfm.getNodeContainer(e.getKey());
if (nc == null) {
continue;
}
nc.setUIInformation(e.getValue());
}
// re-create bendpoints
for (Map.Entry<ConnectionID, ConnectionUIInformation> e : oldBendpoints.entrySet()) {
ConnectionContainer cc = m_wfm.getConnection(e.getKey());
if (cc == null) {
continue;
}
cc.setUIInfo(e.getValue());
}
}
use of org.knime.core.node.workflow.NodeUIInformation in project knime-core by knime.
the class VerticAlignCommand method undo.
/**
* {@inheritDoc}
*/
@Override
public void undo() {
Map<NodeID, NodeUIInformation> oldPositions = m_alignMgr.getOldNodeCoordinates();
Map<ConnectionID, ConnectionUIInformation> oldBendpoints = m_alignMgr.getOldBendpoints();
// re-position nodes
for (Map.Entry<NodeID, NodeUIInformation> e : oldPositions.entrySet()) {
NodeContainer nc = m_wfm.getNodeContainer(e.getKey());
if (nc == null) {
continue;
}
nc.setUIInformation(e.getValue());
}
// re-create bendpoints
for (Map.Entry<ConnectionID, ConnectionUIInformation> e : oldBendpoints.entrySet()) {
ConnectionContainer cc = m_wfm.getConnection(e.getKey());
if (cc == null) {
continue;
}
cc.setUIInfo(e.getValue());
}
}
use of org.knime.core.node.workflow.NodeUIInformation in project knime-core by knime.
the class ReplaceHelper method reconnect.
/**
* Connects new node with connection of the old node.
*
* @param container new node container
*/
public void reconnect(final NodeContainer container) {
// reset node location
NodeUIInformation uiInformation = m_oldNode.getUIInformation();
int[] bounds = uiInformation.getBounds();
NodeUIInformation info = NodeUIInformation.builder().setNodeLocation(bounds[0], bounds[1], -1, -1).setHasAbsoluteCoordinates(true).setSnapToGrid(uiInformation.getSnapToGrid()).setIsDropLocation(false).build();
container.setUIInformation(info);
int inShift;
int outShift;
if (m_oldNode instanceof WorkflowManager && !(container instanceof WorkflowManager)) {
inShift = 0;
// replacing a metanode (no opt. flow var ports) with a "normal" node (that has optional flow var ports)
if (m_oldNode.getNrInPorts() > 0 && container.getNrInPorts() > 1) {
// shift ports one index - unless we need to use the invisible optional flow var port of new node
if (!m_oldNode.getInPort(0).getPortType().equals(FlowVariablePortObject.TYPE)) {
inShift = 1;
} else if (container.getInPort(1).getPortType().equals(FlowVariablePortObject.TYPE)) {
inShift = 1;
}
}
outShift = 0;
if (m_oldNode.getNrOutPorts() > 0 && container.getNrOutPorts() > 1) {
if (!m_oldNode.getOutPort(0).getPortType().equals(FlowVariablePortObject.TYPE)) {
outShift = 1;
} else if (container.getOutPort(1).getPortType().equals(FlowVariablePortObject.TYPE)) {
outShift = 1;
}
}
} else if (!(m_oldNode instanceof WorkflowManager) && container instanceof WorkflowManager) {
// replacing a "normal" node with a metanode
inShift = -1;
for (ConnectionContainer cc : m_incomingConnections) {
if (cc.getDestPort() == 0) {
inShift = 0;
break;
}
}
outShift = -1;
for (ConnectionContainer cc : m_outgoingConnections) {
if (cc.getSourcePort() == 0) {
outShift = 0;
break;
}
}
} else {
inShift = 0;
outShift = 0;
}
// set incoming connections
NodeID newId = container.getID();
for (ConnectionContainer c : m_incomingConnections) {
if (m_wfm.canAddConnection(c.getSource(), c.getSourcePort(), newId, c.getDestPort() + inShift)) {
m_wfm.addConnection(c.getSource(), c.getSourcePort(), newId, c.getDestPort() + inShift);
} else {
break;
}
}
// set outgoing connections
for (ConnectionContainer c : m_outgoingConnections) {
if (m_wfm.canAddConnection(newId, c.getSourcePort() + outShift, c.getDest(), c.getDestPort())) {
m_wfm.addConnection(newId, c.getSourcePort() + outShift, c.getDest(), c.getDestPort());
} else {
break;
}
}
}
use of org.knime.core.node.workflow.NodeUIInformation 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 };
}
use of org.knime.core.node.workflow.NodeUIInformation in project knime-core by knime.
the class AbstractWorkflowPortBarEditPart method refreshVisuals.
/**
* {@inheritDoc}
*/
@Override
protected void refreshVisuals() {
NodeUIInformation uiInfo = ((WorkflowPortBar) getModel()).getUIInfo();
if (uiInfo != null && !((AbstractWorkflowPortBarFigure) getFigure()).isInitialized()) {
int[] bounds = uiInfo.getBounds();
((AbstractWorkflowPortBarFigure) getFigure()).setBounds(new Rectangle(bounds[0], bounds[1], bounds[2], bounds[3]));
}
super.refreshVisuals();
}
Aggregations