From c5f5fe1de5b8feeb50edac8109ee7d4e164a1fb0 Mon Sep 17 00:00:00 2001
From: Soeren Domroes
Date: Wed, 1 Apr 2020 17:38:08 +0200
Subject: [PATCH] Revert "Added custom default for box and rectpacking
contentAlignment."
This reverts commit cb59d9e6ac2f4c1c5372c3b4418c1ddbef862fa6.
---
.../alg/rectpacking/RectPackingLayoutProvider.java | 6 ------
.../eclipse/elk/alg/rectpacking/util/BlockRow.java | 4 +---
.../src/org/eclipse/elk/core/Core.melk | 2 +-
.../org/eclipse/elk/core/util/BoxLayoutProvider.java | 11 +----------
.../src/org/eclipse/elk/core/util/ElkUtil.java | 7 +------
5 files changed, 4 insertions(+), 26 deletions(-)
diff --git a/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/RectPackingLayoutProvider.java b/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/RectPackingLayoutProvider.java
index 6382d74a03..8298a1c132 100644
--- a/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/RectPackingLayoutProvider.java
+++ b/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/RectPackingLayoutProvider.java
@@ -11,9 +11,7 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.EnumSet;
import java.util.List;
-import java.util.Set;
import org.eclipse.elk.alg.rectpacking.firstiteration.AreaApproximation;
import org.eclipse.elk.alg.rectpacking.options.RectPackingOptions;
@@ -24,7 +22,6 @@
import org.eclipse.elk.core.AbstractLayoutProvider;
import org.eclipse.elk.core.math.ElkPadding;
import org.eclipse.elk.core.math.KVector;
-import org.eclipse.elk.core.options.ContentAlignment;
import org.eclipse.elk.core.util.ElkUtil;
import org.eclipse.elk.core.util.IElkProgressMonitor;
import org.eclipse.elk.graph.ElkNode;
@@ -42,9 +39,6 @@
*
*/
public class RectPackingLayoutProvider extends AbstractLayoutProvider {
-
- public static final Set DEFAULT_ALIGNMENT =
- EnumSet.of(ContentAlignment.H_CENTER, ContentAlignment.V_TOP);
/**
* Calculating and applying layout to the model.
*/
diff --git a/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/util/BlockRow.java b/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/util/BlockRow.java
index 582fad7d7f..5cc2d69b50 100644
--- a/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/util/BlockRow.java
+++ b/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/util/BlockRow.java
@@ -12,7 +12,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.elk.alg.rectpacking.RectPackingLayoutProvider;
import org.eclipse.elk.core.math.KVector;
import org.eclipse.elk.core.util.ElkUtil;
import org.eclipse.elk.graph.ElkNode;
@@ -135,8 +134,7 @@ public void expand(final double widthForRow, final double additionalHeightForRow
i++;
double newWidth = rect.getWidth();
double newHeight = rect.getHeight();
- ElkUtil.translate(rect, new KVector(newWidth, newHeight), new KVector(oldWidth, oldHeight),
- RectPackingLayoutProvider.DEFAULT_ALIGNMENT);
+ ElkUtil.translate(rect, new KVector(newWidth, newHeight), new KVector(oldWidth, oldHeight));
}
}
diff --git a/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/Core.melk b/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/Core.melk
index 66fc63750b..057ad67834 100644
--- a/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/Core.melk
+++ b/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/Core.melk
@@ -171,7 +171,7 @@ programmatic option bendPoints: KVectorChain {
advanced option contentAlignment: EnumSet {
label "Content Alignment"
description "Specifies how the content of compound nodes is to be aligned, e.g. top-left."
- default = EnumSet.noneOf(ContentAlignment)
+ default = EnumSet.of(ContentAlignment.H_CENTER, ContentAlignment.V_TOP)
targets parents
legacyIds de.cau.cs.kieler.klay.layered.contentAlignment
}
diff --git a/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/util/BoxLayoutProvider.java b/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/util/BoxLayoutProvider.java
index 9ec2026de9..6170bade68 100644
--- a/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/util/BoxLayoutProvider.java
+++ b/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/util/BoxLayoutProvider.java
@@ -13,19 +13,16 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
-import java.util.EnumSet;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Queue;
-import java.util.Set;
import org.eclipse.elk.core.AbstractLayoutProvider;
import org.eclipse.elk.core.math.ElkPadding;
import org.eclipse.elk.core.math.KVector;
import org.eclipse.elk.core.options.BoxLayouterOptions;
-import org.eclipse.elk.core.options.ContentAlignment;
import org.eclipse.elk.core.options.CoreOptions;
import org.eclipse.elk.graph.ElkNode;
@@ -55,9 +52,6 @@
*/
public class BoxLayoutProvider extends AbstractLayoutProvider {
- public static final Set DEFAULT_ALIGNMENT =
- EnumSet.of(ContentAlignment.H_CENTER, ContentAlignment.V_TOP);
-
/** default value for aspect ratio. */
public static final double DEF_ASPECT_RATIO = 1.3;
@@ -70,8 +64,6 @@ public void layout(final ElkNode layoutNode, final IElkProgressMonitor progressM
boolean expandNodes = layoutNode.getProperty(BoxLayouterOptions.EXPAND_NODES);
boolean interactive = layoutNode.getProperty(BoxLayouterOptions.INTERACTIVE);
- // Set custom default for content alignment.
-
switch (layoutNode.getProperty(BoxLayouterOptions.BOX_PACKING_MODE)) {
case SIMPLE:
placeBoxes(layoutNode, objSpacing, padding, expandNodes, interactive);
@@ -268,8 +260,7 @@ private KVector placeBoxes(final List sortedBoxes, final double minSpac
double oldWidth = box.getWidth();
box.setWidth(newWidth);
// Content alignment
- ElkUtil.translate(box, new KVector(newWidth, newHeight), new KVector(oldWidth, oldHeight),
- DEFAULT_ALIGNMENT);
+ ElkUtil.translate(box, new KVector(newWidth, newHeight), new KVector(oldWidth, oldHeight));
}
xpos += box.getWidth() + minSpacing;
}
diff --git a/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/util/ElkUtil.java b/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/util/ElkUtil.java
index b0b6156aa7..286aebe458 100644
--- a/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/util/ElkUtil.java
+++ b/plugins/org.eclipse.elk.core/src/org/eclipse/elk/core/util/ElkUtil.java
@@ -610,14 +610,9 @@ public static void translate(final ElkEdgeSection section, final double xoffset,
* @param newSize The new size.
* @param oldSize The old size.
*/
- public static void translate(final ElkNode parent, final KVector newSize, final KVector oldSize,
- final Set defaultAlignment) {
+ public static void translate(final ElkNode parent, final KVector newSize, final KVector oldSize) {
Set contentAlignment =
parent.getProperty(CoreOptions.CONTENT_ALIGNMENT);
- if (defaultAlignment != null && (!parent.hasProperty(CoreOptions.CONTENT_ALIGNMENT)
- || parent.getProperty(CoreOptions.CONTENT_ALIGNMENT).isEmpty())) {
- contentAlignment = defaultAlignment;
- }
double xTranslate = 0;
double yTranslate = 0;