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