From 5999901e375ab610347f8599c62f9cbe6ea638ea Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Wed, 11 Dec 2024 16:16:09 +0100 Subject: [PATCH] Nodes define their own width and height even in case no approximator is set(#1097) --- .../elk/core/RecursiveGraphLayoutEngine.java | 7 ++++--- .../elk/alg/topdown/test/TopdownLayoutTest.java | 16 ++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/RecursiveGraphLayoutEngine.java b/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/RecursiveGraphLayoutEngine.java index 04cd98992..f06465932 100644 --- a/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/RecursiveGraphLayoutEngine.java +++ b/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/RecursiveGraphLayoutEngine.java @@ -260,9 +260,10 @@ protected List layoutRecursively(final ElkNode layoutNode, final TestCo // that have been set for nodes containing further children if (childNode.getChildren().size() != 0) { childNode.setDimensions( - layoutNode.getProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH), - layoutNode.getProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH) / - layoutNode.getProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO)); + childNode.getProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH), + childNode.getProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH) / + childNode.getProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO) + ); } } } diff --git a/test/org.eclipse.elk.alg.topdown.test/src/org/eclipse/elk/alg/topdown/test/TopdownLayoutTest.java b/test/org.eclipse.elk.alg.topdown.test/src/org/eclipse/elk/alg/topdown/test/TopdownLayoutTest.java index 7aa5f959e..f5e181fa7 100644 --- a/test/org.eclipse.elk.alg.topdown.test/src/org/eclipse/elk/alg/topdown/test/TopdownLayoutTest.java +++ b/test/org.eclipse.elk.alg.topdown.test/src/org/eclipse/elk/alg/topdown/test/TopdownLayoutTest.java @@ -52,8 +52,8 @@ public void testTwoLevelLayoutHorizontalScaling() { toplevel.setProperty(CoreOptions.PADDING, new ElkPadding()); toplevel.setProperty(CoreOptions.SPACING_NODE_NODE, 0.0); // set size of node so that children will be scaled down - graph.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH, 20.0); - graph.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO, 0.4); + toplevel.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH, 20.0); + toplevel.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO, 0.4); ElkNode child1 = ElkGraphUtil.createNode(toplevel); child1.setProperty(CoreOptions.TOPDOWN_LAYOUT, true); @@ -106,8 +106,8 @@ public void testTwoLevelLayoutVerticalScaling() { toplevel.setProperty(CoreOptions.PADDING, new ElkPadding()); toplevel.setProperty(CoreOptions.SPACING_NODE_NODE, 0.0); // set size of node so that children will be scaled down - graph.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH, 40.0); - graph.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO, 1.33333); + toplevel.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH, 40.0); + toplevel.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO, 1.33333); ElkNode child1 = ElkGraphUtil.createNode(toplevel); child1.setProperty(CoreOptions.TOPDOWN_LAYOUT, true); @@ -161,8 +161,8 @@ public void testScaleCap() { toplevel.setProperty(CoreOptions.PADDING, new ElkPadding()); toplevel.setProperty(CoreOptions.SPACING_NODE_NODE, 0.0); // set size of node so that children will be scaled down - graph.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH, 300.0); - graph.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO, 1.0); + toplevel.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH, 300.0); + toplevel.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO, 1.0); ElkNode child1 = ElkGraphUtil.createNode(toplevel); child1.setProperty(CoreOptions.TOPDOWN_LAYOUT, true); @@ -215,8 +215,8 @@ public void testScaleCapBounded() { toplevel.setProperty(CoreOptions.PADDING, new ElkPadding()); toplevel.setProperty(CoreOptions.SPACING_NODE_NODE, 0.0); // set size of node so that children will be scaled down - graph.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH, 300.0); - graph.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO, 1.0); + toplevel.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH, 300.0); + toplevel.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO, 1.0); ElkNode child1 = ElkGraphUtil.createNode(toplevel); child1.setProperty(CoreOptions.TOPDOWN_LAYOUT, true);