use of org.eclipse.elk.core.math.ElkRectangle 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);
}
use of org.eclipse.elk.core.math.ElkRectangle in project elk by eclipse.
the class CompactionTest method testSubsequentDirectionsCompaction.
/* --------------------------------------------------
* Testing subsequent calls with different directions
* -------------------------------------------------- */
@Test
public void testSubsequentDirectionsCompaction() {
CGraph graph = new CGraph(EnumSet.allOf(Direction.class));
CTestNode one = new CTestNode(new ElkRectangle(0, 0, 20, 20));
graph.cNodes.add(one);
CTestNode two = new CTestNode(new ElkRectangle(25, 0, 20, 20));
graph.cNodes.add(two);
CTestNode three = new CTestNode(new ElkRectangle(0, 25, 20, 20));
graph.cNodes.add(three);
CTestNode four = new CTestNode(new ElkRectangle(25, 25, 20, 20));
graph.cNodes.add(four);
Set<Direction> directions = EnumSet.of(Direction.LEFT, Direction.RIGHT, Direction.UP, Direction.DOWN);
// subsequently apply all combinations of four subsequent compaction steps
for (Direction d1 : directions) {
for (Direction d2 : directions) {
for (Direction d3 : directions) {
for (Direction d4 : directions) {
compacter(graph).changeDirection(d1).compact().changeDirection(d2).compact().changeDirection(d3).compact().changeDirection(d4).compact().finish();
// the way we modeled the graph, every node should stay where it is
String currentDirections = d1 + " " + d2 + " " + d3 + " " + d4;
assertEquals(currentDirections, 0, one.hitbox.x, EPSILON);
assertEquals(currentDirections, 0, one.hitbox.y, EPSILON);
assertEquals(currentDirections, 25, two.hitbox.x, EPSILON);
assertEquals(currentDirections, 0, two.hitbox.y, EPSILON);
assertEquals(currentDirections, 0, three.hitbox.x, EPSILON);
assertEquals(currentDirections, 25, three.hitbox.y, EPSILON);
assertEquals(currentDirections, 25, four.hitbox.x, EPSILON);
assertEquals(currentDirections, 25, four.hitbox.y, EPSILON);
}
}
}
}
}
use of org.eclipse.elk.core.math.ElkRectangle in project elk by eclipse.
the class CompactionTest method testDownCompaction.
@Test
public void testDownCompaction() {
CGraph graph = new CGraph(EnumSet.allOf(Direction.class));
CTestNode upper = new CTestNode(new ElkRectangle(0, 0, 20, 20));
graph.cNodes.add(upper);
CTestNode lower = new CTestNode(new ElkRectangle(0, 30, 20, 20));
graph.cNodes.add(lower);
compacter(graph).changeDirection(Direction.DOWN).compact().finish();
assertEquals(5, upper.hitbox.y, EPSILON);
assertEquals(30, lower.hitbox.y, EPSILON);
}
use of org.eclipse.elk.core.math.ElkRectangle in project elk by eclipse.
the class CompactionTest method testHorizontalSpacings.
/* --------------------------------------------------
* Testing different kinds of spacings.
* --------------------------------------------------*/
/*
* We support different spacing values between nodes and edges in vertical and horizontal
* direction. Thereby "vertical" and "horizontal" depends on the compaction direction.
* Furthermore, we support individual spacings between any pair of nodes.
*/
/**
* Horizontal spacing should be preserved when compaction leftwards or rightwards.
*/
@Test
public void testHorizontalSpacings() {
CGraph graph = new CGraph(EnumSet.allOf(Direction.class));
// test horizontal direction
CTestNodeSpacing one = new CTestNodeSpacing(new ElkRectangle(0, 0, 20, 20), 5d, 0d);
graph.cNodes.add(one);
CTestNodeSpacing two = new CTestNodeSpacing(new ElkRectangle(50, 0, 20, 20), 7d, 0d);
graph.cNodes.add(two);
CTestNodeSpacing three = new CTestNodeSpacing(new ElkRectangle(150, 0, 20, 20), 10d, 0d);
graph.cNodes.add(three);
compacter(graph).changeDirection(Direction.LEFT).compact().finish();
assertEquals(0, one.hitbox.x, EPSILON);
assertEquals(27, two.hitbox.x, EPSILON);
assertEquals(57, three.hitbox.x, EPSILON);
compacter(graph).changeDirection(Direction.RIGHT).compact().finish();
assertEquals(0, one.hitbox.x, EPSILON);
assertEquals(27, two.hitbox.x, EPSILON);
assertEquals(57, three.hitbox.x, EPSILON);
compacter(graph).changeDirection(Direction.LEFT).compact().finish();
assertEquals(0, one.hitbox.x, EPSILON);
assertEquals(27, two.hitbox.x, EPSILON);
assertEquals(57, three.hitbox.x, EPSILON);
}
use of org.eclipse.elk.core.math.ElkRectangle in project elk by eclipse.
the class CompactionTest method testRightCompaction.
@Test
public void testRightCompaction() {
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, 0, 20, 20));
graph.cNodes.add(right);
compacter(graph).changeDirection(Direction.RIGHT).compact().finish();
assertEquals(5, left.hitbox.x, EPSILON);
assertEquals(30, right.hitbox.x, EPSILON);
}
Aggregations