Skip to content

Commit

Permalink
core.nodespacing: #576 further adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
uruuru committed May 19, 2020
1 parent 2402d99 commit c105e7b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c105e7b

Please sign in to comment.