use of org.eclipse.elk.alg.layered.compaction.oned.CGroup in project elk by eclipse.
the class CompactionTest method testNoSpacingAppliedWithinGroups.
/**
* Two separate groups, three nodes each.
*
* Care has to be taken when calculating the initial position of a {@link CGroup} not to include
* any spacing between the group nodes. (Group nodes are rigidly fixed relative to each other
* and thus no other spacing should be applied in between them). This test asserts that the
* initial position of the groups is as expected.
*/
@Test
public void testNoSpacingAppliedWithinGroups() {
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(20, 10, 20, 20));
graph.cNodes.add(two);
CTestNode three = new CTestNode(new ElkRectangle(40, 20, 20, 20));
graph.cNodes.add(three);
CGroup g1 = new CGroup(one, two, three);
graph.cGroups.add(g1);
CTestNode four = new CTestNode(new ElkRectangle(22, 80, 20, 20));
graph.cNodes.add(four);
CTestNode five = new CTestNode(new ElkRectangle(42, 90, 20, 20));
graph.cNodes.add(five);
CTestNode six = new CTestNode(new ElkRectangle(62, 100, 20, 20));
graph.cNodes.add(six);
CGroup g2 = new CGroup(four, five, six);
graph.cGroups.add(g2);
compacter(graph).changeDirection(Direction.LEFT).compact().changeDirection(Direction.RIGHT).compact().changeDirection(Direction.UP).compact().changeDirection(Direction.DOWN).compact().finish();
assertEquals(0, one.hitbox.x, EPSILON);
assertEquals(20, two.hitbox.x, EPSILON);
assertEquals(40, three.hitbox.x, EPSILON);
assertEquals(0, four.hitbox.x, EPSILON);
assertEquals(20, five.hitbox.x, EPSILON);
assertEquals(40, six.hitbox.x, EPSILON);
assertEquals(0, one.hitbox.y, EPSILON);
assertEquals(10, two.hitbox.y, EPSILON);
assertEquals(20, three.hitbox.y, EPSILON);
assertEquals(35, four.hitbox.y, EPSILON);
assertEquals(45, five.hitbox.y, EPSILON);
assertEquals(55, six.hitbox.y, EPSILON);
}
use of org.eclipse.elk.alg.layered.compaction.oned.CGroup in project elk by eclipse.
the class CompactionTest method testLeftGroupCompaction.
/**
* The connection indicates a grouping, not an edge.
*
* +--+
* | | +--+
* +--+ | |
* +--+
* |
* +--+
* | |
* +--+
*/
@Test
public void testLeftGroupCompaction() {
CGraph graph = new CGraph(EnumSet.allOf(Direction.class));
CTestNode left = new CTestNode(new ElkRectangle(0, 0, 20, 20));
graph.cNodes.add(left);
CTestNode upperRight = new CTestNode(new ElkRectangle(40, 5, 20, 20));
graph.cNodes.add(upperRight);
CTestNode lowerRight = new CTestNode(new ElkRectangle(30, 25, 20, 20));
graph.cNodes.add(lowerRight);
CGroup group = new CGroup(upperRight, lowerRight);
graph.cGroups.add(group);
compacter(graph).changeDirection(Direction.LEFT).compact().finish();
assertEquals(0, left.hitbox.x, EPSILON);
assertEquals(25, upperRight.hitbox.x, EPSILON);
assertEquals(15, lowerRight.hitbox.x, EPSILON);
}
use of org.eclipse.elk.alg.layered.compaction.oned.CGroup in project elk by eclipse.
the class CompactionTest method testUpGroupCompaction.
/**
* The connection indicates a grouping, not an edge.
*
* +--+
* | |
* +--+ +--+
* | |
* +--+---+--+
* | |
* +--+
*/
@Test
public void testUpGroupCompaction() {
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, 20, 20));
graph.cNodes.add(lowerLeft);
CTestNode right = new CTestNode(new ElkRectangle(25, 30, 20, 20));
graph.cNodes.add(right);
CGroup group = new CGroup(lowerLeft, right);
graph.cGroups.add(group);
compacter(graph).changeDirection(Direction.UP).compact().finish();
assertEquals(0, upperLeft.hitbox.y, EPSILON);
assertEquals(25, lowerLeft.hitbox.y, EPSILON);
assertEquals(15, right.hitbox.y, EPSILON);
}
Aggregations