Skip to content

Commit

Permalink
Allow to set minimum size constraint together with fixed size. (#812)
Browse files Browse the repository at this point in the history
  • Loading branch information
soerendomroes committed Mar 23, 2022
1 parent 453429f commit 9997aed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Expand Up @@ -12,6 +12,7 @@
import org.eclipse.elk.alg.common.nodespacing.internal.NodeContext;
import org.eclipse.elk.core.math.ElkRectangle;
import org.eclipse.elk.core.math.KVector;
import org.eclipse.elk.core.options.CoreOptions;
import org.eclipse.elk.core.options.PortConstraints;
import org.eclipse.elk.core.options.PortSide;
import org.eclipse.elk.core.options.SizeConstraint;
Expand Down Expand Up @@ -64,7 +65,11 @@ public static void setNodeWidth(final NodeContext nodeContext) {
}

// Set the node's width
nodeSize.x = width;
if (nodeContext.node.getGraph().getProperty(CoreOptions.NODE_SIZE_FIXED_GRAPH_SIZE)) {
nodeSize.x = Math.max(nodeSize.x, width);
} else {
nodeSize.x = width;
}

// Set the cell system's width and tell it to compute horizontal coordinates and widths
ElkRectangle nodeCellRectangle = nodeContext.nodeContainer.getCellRectangle();
Expand Down Expand Up @@ -121,7 +126,11 @@ public static void setNodeHeight(final NodeContext nodeContext) {
}

// Set the node's height
nodeSize.y = height;
if (nodeContext.node.getGraph().getProperty(CoreOptions.NODE_SIZE_FIXED_GRAPH_SIZE)) {
nodeSize.y = Math.max(nodeSize.y, height);
} else {
nodeSize.y = height;
}

// Set the cell system's height and tell it to compute vertical coordinates and heights
ElkRectangle nodeCellRectangle = nodeContext.nodeContainer.getCellRectangle();
Expand Down
Expand Up @@ -155,9 +155,7 @@ public void doLayout(final LGraph lgraph, final IElkProgressMonitor monitor) {
componentsProcessor.combine(components, lgraph);

// Resize the resulting graph, according to minimal size constraints and such
if (!lgraph.getProperty(LayeredOptions.NODE_SIZE_FIXED_GRAPH_SIZE)) {
resizeGraph(lgraph);
}
resizeGraph(lgraph);

theMonitor.done();
}
Expand Down Expand Up @@ -698,7 +696,9 @@ private void resizeGraph(final LGraph lgraph) {
adjustedSize.y = Math.max(calculatedSize.y, minSize.y);
}

resizeGraphNoReallyIMeanIt(lgraph, calculatedSize, adjustedSize);
if (!lgraph.getProperty(LayeredOptions.NODE_SIZE_FIXED_GRAPH_SIZE)) {
resizeGraphNoReallyIMeanIt(lgraph, calculatedSize, adjustedSize);
}
}


Expand Down

0 comments on commit 9997aed

Please sign in to comment.