use of org.eclipse.elk.alg.spore.options.SporeMetaDataProvider in project elk by eclipse.
the class ScanlineOverlapRemovalTest method scanlineTest.
/**
* Test whether the {@link ScanlineOverlapCheck} supports the overlap removal to find all
* overlaps in a special case.
*/
@Test
public void scanlineTest() {
// build test graphs
ElkNode graph1 = ElkGraphUtil.createGraph();
ElkNode n0 = ElkGraphUtil.createNode(graph1);
ElkNode n1 = ElkGraphUtil.createNode(graph1);
ElkNode n2 = ElkGraphUtil.createNode(graph1);
ElkNode n3 = ElkGraphUtil.createNode(graph1);
n0.setDimensions(160, 20);
n1.setDimensions(160, 20);
n2.setDimensions(20, 20);
n3.setDimensions(20, 20);
n0.setLocation(0, 30);
n1.setLocation(150, 40);
n2.setLocation(150, 0);
n3.setLocation(150, 70);
graph1.setProperty(CoreOptions.ALGORITHM, SporeOverlapRemovalOptions.ALGORITHM_ID);
Copier copier = new Copier();
ElkNode graph2 = (ElkNode) copier.copy(graph1);
graph2.setProperty(SporeOverlapRemovalOptions.OVERLAP_REMOVAL_RUN_SCANLINE, false);
// execute overlap removal with and without ScanlineOverlapCheck
LayoutMetaDataService lService = LayoutMetaDataService.getInstance();
lService.registerLayoutMetaDataProviders(new SporeMetaDataProvider());
RecursiveGraphLayoutEngine lEngine = new RecursiveGraphLayoutEngine();
lEngine.layout(graph1, new BasicProgressMonitor());
lEngine.layout(graph2, new BasicProgressMonitor());
// test
assertFalse(hasOverlaps(graph1));
assertTrue(hasOverlaps(graph2));
}
Aggregations