Skip to content

Commit

Permalink
Nodes define their own width and height even in case no approximator is
Browse files Browse the repository at this point in the history
set
  • Loading branch information
Eddykasp committed Dec 11, 2024
1 parent b6ed84a commit 9b31e8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,16 @@ protected List<ElkEdge> 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(
childNode.getProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH),
childNode.getProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_WIDTH) /
childNode.getProperty(CoreOptions.TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO)
);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
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);
Expand Down Expand Up @@ -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);
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);
Expand Down Expand Up @@ -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);
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);
Expand Down Expand Up @@ -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);
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);
Expand Down

0 comments on commit 9b31e8f

Please sign in to comment.