Skip to content

Commit

Permalink
Revert "Added custom default for box and rectpacking contentAlignment."
Browse files Browse the repository at this point in the history
This reverts commit cb59d9e.
  • Loading branch information
soerendomroes committed Apr 1, 2020
1 parent 35f24ab commit c5f5fe1
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -42,9 +39,6 @@
* </p>
*/
public class RectPackingLayoutProvider extends AbstractLayoutProvider {

public static final Set<ContentAlignment> DEFAULT_ALIGNMENT =
EnumSet.of(ContentAlignment.H_CENTER, ContentAlignment.V_TOP);
/**
* Calculating and applying layout to the model.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ programmatic option bendPoints: KVectorChain {
advanced option contentAlignment: EnumSet<ContentAlignment> {
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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -55,9 +52,6 @@
*/
public class BoxLayoutProvider extends AbstractLayoutProvider {

public static final Set<ContentAlignment> DEFAULT_ALIGNMENT =
EnumSet.of(ContentAlignment.H_CENTER, ContentAlignment.V_TOP);

/** default value for aspect ratio. */
public static final double DEF_ASPECT_RATIO = 1.3;

Expand All @@ -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);
Expand Down Expand Up @@ -268,8 +260,7 @@ private KVector placeBoxes(final List<ElkNode> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ContentAlignment> defaultAlignment) {
public static void translate(final ElkNode parent, final KVector newSize, final KVector oldSize) {
Set<ContentAlignment> 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;

Expand Down

0 comments on commit c5f5fe1

Please sign in to comment.