From 1f968f4713166eb09b1bc8fee7f9169166fe971c Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Thu, 19 Oct 2023 12:30:52 +0200 Subject: [PATCH] Graph size calculation Correctly compute graph size and consider padding instead of magicnumber --- .../alg/vertiflex/p3relative/RelativeXPlacer.java | 1 - .../alg/vertiflex/p5edgerouting/Edgerouter.java | 14 +++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/org.eclipse.elk.alg.vertiflex/src/org/eclipse/elk/alg/vertiflex/p3relative/RelativeXPlacer.java b/plugins/org.eclipse.elk.alg.vertiflex/src/org/eclipse/elk/alg/vertiflex/p3relative/RelativeXPlacer.java index 42c74118f..fd3ddf451 100644 --- a/plugins/org.eclipse.elk.alg.vertiflex/src/org/eclipse/elk/alg/vertiflex/p3relative/RelativeXPlacer.java +++ b/plugins/org.eclipse.elk.alg.vertiflex/src/org/eclipse/elk/alg/vertiflex/p3relative/RelativeXPlacer.java @@ -422,7 +422,6 @@ private void makeSimpleOutlines(final ElkNode graph) { + margins.right + spacingNodeNode / 2, graph.getY() - margins.top, new OutlineNode(graph.getWidth() / 2.0, graph.getY() - margins.top - spacingNodeNode / 2, endpart))); - // TODO double check whether this is the best way and place to calculate this // set min and max values graph.setProperty(InternalProperties.MIN_X, graph.getX() - margins.left); graph.setProperty(InternalProperties.MAX_X, diff --git a/plugins/org.eclipse.elk.alg.vertiflex/src/org/eclipse/elk/alg/vertiflex/p5edgerouting/Edgerouter.java b/plugins/org.eclipse.elk.alg.vertiflex/src/org/eclipse/elk/alg/vertiflex/p5edgerouting/Edgerouter.java index 552f2e6cc..ac307cd8b 100644 --- a/plugins/org.eclipse.elk.alg.vertiflex/src/org/eclipse/elk/alg/vertiflex/p5edgerouting/Edgerouter.java +++ b/plugins/org.eclipse.elk.alg.vertiflex/src/org/eclipse/elk/alg/vertiflex/p5edgerouting/Edgerouter.java @@ -13,6 +13,9 @@ 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.ElkPadding; +import org.eclipse.elk.core.options.CoreOptions; +import org.eclipse.elk.core.util.ElkUtil; import org.eclipse.elk.core.util.IElkProgressMonitor; import org.eclipse.elk.graph.ElkBendPoint; import org.eclipse.elk.graph.ElkEdge; @@ -72,11 +75,12 @@ private void routeEdges(final ElkNode node) { private void setCanvas(final ElkNode graph) { - ElkNode parent = graph.getChildren().get(0); - graph.setHeight(parent.getProperty(InternalProperties.MAX_Y) - - parent.getProperty(InternalProperties.MIN_Y) + 20.0); //TODO remove magic numbers - graph.setWidth(parent.getProperty(InternalProperties.MAX_X) - - parent.getProperty(InternalProperties.MIN_X) + 20.0); + ElkPadding padding = graph.getProperty(CoreOptions.PADDING); + + ElkUtil.computeChildAreaDimensions(graph); + + graph.setWidth(graph.getProperty(CoreOptions.CHILD_AREA_WIDTH) + padding.left + padding.right); + graph.setHeight(graph.getProperty(CoreOptions.CHILD_AREA_HEIGHT) + padding.top + padding.bottom); } }