From 96b118da139e0c3e0e08c9e9264db686fbed42cb Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Thu, 19 Oct 2023 14:20:34 +0200 Subject: [PATCH] Fix graph size calculation --- .../vertiflex/p4edgerouting/Edgerouter.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/plugins/org.eclipse.elk.alg.vertiflex/src/org/eclipse/elk/alg/vertiflex/p4edgerouting/Edgerouter.java b/plugins/org.eclipse.elk.alg.vertiflex/src/org/eclipse/elk/alg/vertiflex/p4edgerouting/Edgerouter.java index 38d9524cb..7697f5b97 100644 --- a/plugins/org.eclipse.elk.alg.vertiflex/src/org/eclipse/elk/alg/vertiflex/p4edgerouting/Edgerouter.java +++ b/plugins/org.eclipse.elk.alg.vertiflex/src/org/eclipse/elk/alg/vertiflex/p4edgerouting/Edgerouter.java @@ -13,6 +13,7 @@ import org.eclipse.elk.alg.vertiflex.VertiFlexLayoutPhases; import org.eclipse.elk.core.alg.ILayoutPhase; import org.eclipse.elk.core.alg.LayoutProcessorConfiguration; +import org.eclipse.elk.core.math.ElkMargin; import org.eclipse.elk.core.math.ElkPadding; import org.eclipse.elk.core.options.CoreOptions; import org.eclipse.elk.core.util.ElkUtil; @@ -77,10 +78,21 @@ private void routeEdges(final ElkNode node) { private void setCanvas(final ElkNode graph) { ElkPadding padding = graph.getProperty(CoreOptions.PADDING); - ElkUtil.computeChildAreaDimensions(graph); + double maxX = 0.0; + double maxY = 0.0; + for (ElkNode node : graph.getChildren()) { + ElkMargin margin = node.getProperty(CoreOptions.MARGINS); - graph.setWidth(graph.getProperty(CoreOptions.CHILD_AREA_WIDTH) + padding.left + padding.right); - graph.setHeight(graph.getProperty(CoreOptions.CHILD_AREA_HEIGHT) + padding.top + padding.bottom); + if (maxX < node.getX() + node.getWidth() + margin.right) { + maxX = node.getX() + node.getWidth() + margin.right; + } + if (maxY < node.getY() + node.getHeight() + margin.bottom) { + maxY = node.getY() + node.getHeight() + margin.bottom; + } + } + + graph.setWidth(maxX + padding.right); + graph.setHeight(maxY + padding.bottom); } }