Skip to content

Commit

Permalink
Graph size calculation
Browse files Browse the repository at this point in the history
Correctly compute graph size and consider padding instead of magicnumber
  • Loading branch information
Eddykasp committed Oct 19, 2023
1 parent e1605f4 commit 1f968f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

}

0 comments on commit 1f968f4

Please sign in to comment.