From c105e7b85006d0103a375ed2b8e7c48180091063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulf=20R=C3=BCegg?= Date: Tue, 19 May 2020 21:26:54 +0200 Subject: [PATCH] core.nodespacing: #576 further adjustments --- .../elk/alg/common/nodespacing/internal/NodeContext.java | 4 ++-- .../internal/algorithm/NodeLabelCellCreator.java | 9 +++++---- .../internal/algorithm/PortLabelPlacementCalculator.java | 6 ++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/plugins/org.eclipse.elk.alg.common/src/org/eclipse/elk/alg/common/nodespacing/internal/NodeContext.java b/plugins/org.eclipse.elk.alg.common/src/org/eclipse/elk/alg/common/nodespacing/internal/NodeContext.java index 1f3f227d36..d3edddd5cf 100644 --- a/plugins/org.eclipse.elk.alg.common/src/org/eclipse/elk/alg/common/nodespacing/internal/NodeContext.java +++ b/plugins/org.eclipse.elk.alg.common/src/org/eclipse/elk/alg/common/nodespacing/internal/NodeContext.java @@ -74,7 +74,7 @@ public final class NodeContext { /** Space to leave around the node label area. */ public final ElkPadding nodeLabelsPadding; /** Space between a node and its outside labels. */ - public final double nodeLabelSpacing; + public final ElkMargin nodeLabelsMargin; /** Space between two labels. */ public final double labelLabelSpacing; /** Space between two different label cells. */ @@ -144,7 +144,7 @@ public NodeContext(final GraphAdapter parentGraph, final NodeAdapter node) // Copy spacings for convenience nodeLabelsPadding = IndividualSpacings.getIndividualOrInherited(node, CoreOptions.NODE_LABELS_PADDING); - nodeLabelSpacing = IndividualSpacings.getIndividualOrInherited(node, CoreOptions.SPACING_LABEL_NODE); + nodeLabelsMargin = IndividualSpacings.getIndividualOrInherited(node, CoreOptions.NODE_LABELS_MARGIN); labelLabelSpacing = IndividualSpacings.getIndividualOrInherited(node, CoreOptions.SPACING_LABEL_LABEL); portPortSpacing = IndividualSpacings.getIndividualOrInherited(node, CoreOptions.SPACING_PORT_PORT); portLabelSpacing = IndividualSpacings.getIndividualOrInherited(node, CoreOptions.SPACING_LABEL_PORT); diff --git a/plugins/org.eclipse.elk.alg.common/src/org/eclipse/elk/alg/common/nodespacing/internal/algorithm/NodeLabelCellCreator.java b/plugins/org.eclipse.elk.alg.common/src/org/eclipse/elk/alg/common/nodespacing/internal/algorithm/NodeLabelCellCreator.java index abd69696ea..9a503fe33a 100644 --- a/plugins/org.eclipse.elk.alg.common/src/org/eclipse/elk/alg/common/nodespacing/internal/algorithm/NodeLabelCellCreator.java +++ b/plugins/org.eclipse.elk.alg.common/src/org/eclipse/elk/alg/common/nodespacing/internal/algorithm/NodeLabelCellCreator.java @@ -108,22 +108,23 @@ private static void createNodeLabelCellContainers(final NodeContext nodeContext, if (!onlyInside) { StripContainerCell northContainer = new StripContainerCell( Strip.HORIZONTAL, symmetry, nodeContext.labelCellSpacing); - northContainer.getPadding().bottom = nodeContext.nodeLabelSpacing; + // Note that top margin translates to bottom padding (likewise for the cases below) + northContainer.getPadding().bottom = nodeContext.nodeLabelsMargin.top; nodeContext.outsideNodeLabelContainers.put(PortSide.NORTH, northContainer); StripContainerCell southContainer = new StripContainerCell( Strip.HORIZONTAL, symmetry, nodeContext.labelCellSpacing); - southContainer.getPadding().top = nodeContext.nodeLabelSpacing; + southContainer.getPadding().top = nodeContext.nodeLabelsMargin.bottom; nodeContext.outsideNodeLabelContainers.put(PortSide.SOUTH, southContainer); StripContainerCell westContainer = new StripContainerCell( Strip.VERTICAL, symmetry, nodeContext.labelCellSpacing); - westContainer.getPadding().right = nodeContext.nodeLabelSpacing; + westContainer.getPadding().right = nodeContext.nodeLabelsMargin.left; nodeContext.outsideNodeLabelContainers.put(PortSide.WEST, westContainer); StripContainerCell eastContainer = new StripContainerCell( Strip.VERTICAL, symmetry, nodeContext.labelCellSpacing); - eastContainer.getPadding().left = nodeContext.nodeLabelSpacing; + eastContainer.getPadding().left = nodeContext.nodeLabelsMargin.right; nodeContext.outsideNodeLabelContainers.put(PortSide.EAST, eastContainer); } } diff --git a/plugins/org.eclipse.elk.alg.common/src/org/eclipse/elk/alg/common/nodespacing/internal/algorithm/PortLabelPlacementCalculator.java b/plugins/org.eclipse.elk.alg.common/src/org/eclipse/elk/alg/common/nodespacing/internal/algorithm/PortLabelPlacementCalculator.java index 3e1a098ef8..3ca4466519 100644 --- a/plugins/org.eclipse.elk.alg.common/src/org/eclipse/elk/alg/common/nodespacing/internal/algorithm/PortLabelPlacementCalculator.java +++ b/plugins/org.eclipse.elk.alg.common/src/org/eclipse/elk/alg/common/nodespacing/internal/algorithm/PortLabelPlacementCalculator.java @@ -241,12 +241,10 @@ private static void constrainedInsidePortLabelPlacement(final NodeContext nodeCo ElkRectangle labelContainerRect = insidePortLabelContainer.getCellRectangle(); double leftBorder = labelContainerRect.x + ElkMath.maxd( insidePortLabelContainer.getPadding().left, - nodeContext.surroundingPortMargins.left, - nodeContext.nodeLabelSpacing); + nodeContext.surroundingPortMargins.left); double rightBorder = labelContainerRect.x + labelContainerRect.width - ElkMath.maxd( insidePortLabelContainer.getPadding().right, - nodeContext.surroundingPortMargins.right, - nodeContext.nodeLabelSpacing); + nodeContext.surroundingPortMargins.right); // Obtain a rectangle strip overlap remover, which will actually do most of the work RectangleStripOverlapRemover overlapRemover = RectangleStripOverlapRemover