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 1a8b7844e..04cd98992 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 @@ -255,6 +255,15 @@ protected List layoutRecursively(final ElkNode layoutNode, final TestCo ElkPadding padding = childNode.getProperty(CoreOptions.PADDING); childNode.setDimensions(Math.max(childNode.getWidth(), size.x + padding.left + padding.right), Math.max(childNode.getHeight(), size.y + padding.top + padding.bottom)); + } else { + // If no approximator is set, use the set sizes for atomic nodes and use the properties + // 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)); + } } } } 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 5a0081047..7aa5f959e 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022 Kiel University and others. + * Copyright (c) 2022-2024 Kiel University and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -51,8 +51,9 @@ public void testTwoLevelLayoutHorizontalScaling() { toplevel.setProperty(CoreOptions.ALGORITHM, "org.eclipse.elk.fixed"); 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 - toplevel.setDimensions(20, 50); + // 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); ElkNode child1 = ElkGraphUtil.createNode(toplevel); child1.setProperty(CoreOptions.TOPDOWN_LAYOUT, true); @@ -105,7 +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 - toplevel.setDimensions(40, 30); + graph.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH, 40.0); + graph.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO, 1.33333); ElkNode child1 = ElkGraphUtil.createNode(toplevel); child1.setProperty(CoreOptions.TOPDOWN_LAYOUT, true); @@ -159,7 +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 - toplevel.setDimensions(300, 300); + graph.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH, 300.0); + graph.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO, 1.0); ElkNode child1 = ElkGraphUtil.createNode(toplevel); child1.setProperty(CoreOptions.TOPDOWN_LAYOUT, true); @@ -212,7 +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 - toplevel.setDimensions(300, 300); + graph.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH, 300.0); + graph.setProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO, 1.0); ElkNode child1 = ElkGraphUtil.createNode(toplevel); child1.setProperty(CoreOptions.TOPDOWN_LAYOUT, true);