Search in sources :

Example 1 with SporeMetaDataProvider

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));
}
Also used : ElkNode(org.eclipse.elk.graph.ElkNode) SporeMetaDataProvider(org.eclipse.elk.alg.spore.options.SporeMetaDataProvider) Copier(org.eclipse.emf.ecore.util.EcoreUtil.Copier) RecursiveGraphLayoutEngine(org.eclipse.elk.core.RecursiveGraphLayoutEngine) BasicProgressMonitor(org.eclipse.elk.core.util.BasicProgressMonitor) LayoutMetaDataService(org.eclipse.elk.core.data.LayoutMetaDataService) Test(org.junit.Test)

Aggregations

SporeMetaDataProvider (org.eclipse.elk.alg.spore.options.SporeMetaDataProvider)1 RecursiveGraphLayoutEngine (org.eclipse.elk.core.RecursiveGraphLayoutEngine)1 LayoutMetaDataService (org.eclipse.elk.core.data.LayoutMetaDataService)1 BasicProgressMonitor (org.eclipse.elk.core.util.BasicProgressMonitor)1 ElkNode (org.eclipse.elk.graph.ElkNode)1 Copier (org.eclipse.emf.ecore.util.EcoreUtil.Copier)1 Test (org.junit.Test)1