use of org.eclipse.elk.alg.layered.compaction.oned.CGraph in project elk by eclipse.
the class CompactionTest method testLeftCompactionSpacingAware.
@Test
public void testLeftCompactionSpacingAware() {
CGraph graph = new CGraph(EnumSet.allOf(Direction.class));
CTestNode left = new CTestNode(new ElkRectangle(0, 0, 20, 20));
graph.cNodes.add(left);
CTestNode right = new CTestNode(new ElkRectangle(30, 20 + SPACING - 1, 20, 20));
graph.cNodes.add(right);
compacter(graph).changeDirection(Direction.LEFT).compact().finish();
assertEquals(0, left.hitbox.x, EPSILON);
assertEquals(25, right.hitbox.x, EPSILON);
}
use of org.eclipse.elk.alg.layered.compaction.oned.CGraph in project elk by eclipse.
the class CompactionTest method testVerticalSpacingDuringHorizontalCompaction.
/**
* "Two" is "center node". Node "one" is supposed to be blocked by "two", while "three" can move freely.
*/
@Test
public void testVerticalSpacingDuringHorizontalCompaction() {
CGraph graph = new CGraph(EnumSet.allOf(Direction.class));
CTestNodeSpacing one = new CTestNodeSpacing(new ElkRectangle(150, 11, 20, 20), 0d, 10d);
graph.cNodes.add(one);
CTestNodeSpacing two = new CTestNodeSpacing(new ElkRectangle(0, 40, 20, 20), 0d, 5d);
graph.cNodes.add(two);
CTestNodeSpacing three = new CTestNodeSpacing(new ElkRectangle(150, 76, 20, 20), 0d, 15d);
graph.cNodes.add(three);
compacter(graph).changeDirection(Direction.LEFT).compact().finish();
assertEquals(20, one.hitbox.x, EPSILON);
assertEquals(0, two.hitbox.x, EPSILON);
assertEquals(0, three.hitbox.x, EPSILON);
}
use of org.eclipse.elk.alg.layered.compaction.oned.CGraph in project elk by eclipse.
the class CompactionTest method testVeticalSpacings.
/**
* Vertical spacing should be preserved when compaction upwards or downwards.
*/
@Test
public void testVeticalSpacings() {
CGraph graph = new CGraph(EnumSet.allOf(Direction.class));
// test horizontal direction
CTestNodeSpacing one = new CTestNodeSpacing(new ElkRectangle(0, 0, 20, 20), 0d, 5d);
graph.cNodes.add(one);
CTestNodeSpacing two = new CTestNodeSpacing(new ElkRectangle(0, 50, 20, 20), 0d, 7d);
graph.cNodes.add(two);
CTestNodeSpacing three = new CTestNodeSpacing(new ElkRectangle(0, 150, 20, 20), 0d, 10d);
graph.cNodes.add(three);
compacter(graph).changeDirection(Direction.UP).compact().finish();
assertEquals(0, one.hitbox.y, EPSILON);
assertEquals(27, two.hitbox.y, EPSILON);
assertEquals(57, three.hitbox.y, EPSILON);
compacter(graph).changeDirection(Direction.DOWN).compact().finish();
assertEquals(0, one.hitbox.y, EPSILON);
assertEquals(27, two.hitbox.y, EPSILON);
assertEquals(57, three.hitbox.y, EPSILON);
compacter(graph).changeDirection(Direction.UP).compact().finish();
assertEquals(0, one.hitbox.y, EPSILON);
assertEquals(27, two.hitbox.y, EPSILON);
assertEquals(57, three.hitbox.y, EPSILON);
}
use of org.eclipse.elk.alg.layered.compaction.oned.CGraph in project elk by eclipse.
the class CompactionTest method testDownGroupCompaction.
/**
* The connection indicates a grouping, not an edge.
*
* +--+
* | |
* +--+-----+--+
* | |
* +--+ +--+
* | |
* +--+
*/
@Test
public void testDownGroupCompaction() {
CGraph graph = new CGraph(EnumSet.allOf(Direction.class));
CTestNode upperLeft = new CTestNode(new ElkRectangle(0, 0, 20, 20));
graph.cNodes.add(upperLeft);
CTestNode lowerLeft = new CTestNode(new ElkRectangle(5, 40, 10, 20));
graph.cNodes.add(lowerLeft);
CTestNode right = new CTestNode(new ElkRectangle(25, 10, 20, 20));
graph.cNodes.add(right);
CGroup group = new CGroup(upperLeft, right);
graph.cGroups.add(group);
compacter(graph).changeDirection(Direction.DOWN).compact().finish();
assertEquals(15, upperLeft.hitbox.y, EPSILON);
assertEquals(40, lowerLeft.hitbox.y, EPSILON);
assertEquals(25, right.hitbox.y, EPSILON);
}
use of org.eclipse.elk.alg.layered.compaction.oned.CGraph in project elk by eclipse.
the class CompactionTest method testLeftCompactionEqualCoordinate.
@Test
public void testLeftCompactionEqualCoordinate() {
CGraph graph = new CGraph(EnumSet.allOf(Direction.class));
CTestNode top = new CTestNodeSpacing(new ElkRectangle(0, 0, 20, 20), 0d, 0d);
graph.cNodes.add(top);
CTestNode bot = new CTestNodeSpacing(new ElkRectangle(30, 20, 20, 20), 0d, 0d);
graph.cNodes.add(bot);
compacter(graph).setConstraintAlgorithm(OneDimensionalCompactor.SCANLINE_CONSTRAINTS).changeDirection(Direction.LEFT).compact().finish();
assertEquals(0, top.hitbox.x, EPSILON);
assertEquals(0, bot.hitbox.x, EPSILON);
}
Aggregations