Search in sources :

Example 1 with LayeredOptions

use of org.eclipse.elk.alg.layered.options.LayeredOptions in project elk by eclipse.

the class PlainLayoutTest method testPlainLayout.

/**
 * Test a plain Java layout on a hierarchical graph using the ELK Layered algorithm.
 */
@Test
public void testPlainLayout() {
    // create a hierarchical KGraph for layout
    ElkNode parentNode = GraphTestUtils.createHierarchicalGraph();
    // configure every hierarchical node to use ELK Layered (which would also be the default)
    getAllElkNodes(parentNode).forEachRemaining(node -> {
        if (!node.getChildren().isEmpty()) {
            node.setProperty(CoreOptions.ALGORITHM, LayeredOptions.ALGORITHM_ID);
        }
    });
    // create a progress monitor
    IElkProgressMonitor progressMonitor = new BasicProgressMonitor();
    // initialize the meta data service with ELK Layered's meta data
    LayoutMetaDataService service = LayoutMetaDataService.getInstance();
    service.registerLayoutMetaDataProviders(new LayeredOptions());
    // instantiate a recursive graph layout engine and execute layout
    RecursiveGraphLayoutEngine layoutEngine = new RecursiveGraphLayoutEngine();
    layoutEngine.layout(parentNode, progressMonitor);
    // output layout information
    printLayoutInfo(parentNode, progressMonitor);
}
Also used : ElkNode(org.eclipse.elk.graph.ElkNode) IElkProgressMonitor(org.eclipse.elk.core.util.IElkProgressMonitor) LayeredOptions(org.eclipse.elk.alg.layered.options.LayeredOptions) BasicProgressMonitor(org.eclipse.elk.core.util.BasicProgressMonitor) RecursiveGraphLayoutEngine(org.eclipse.elk.core.RecursiveGraphLayoutEngine) LayoutMetaDataService(org.eclipse.elk.core.data.LayoutMetaDataService) Test(org.junit.Test)

Aggregations

LayeredOptions (org.eclipse.elk.alg.layered.options.LayeredOptions)1 RecursiveGraphLayoutEngine (org.eclipse.elk.core.RecursiveGraphLayoutEngine)1 LayoutMetaDataService (org.eclipse.elk.core.data.LayoutMetaDataService)1 BasicProgressMonitor (org.eclipse.elk.core.util.BasicProgressMonitor)1 IElkProgressMonitor (org.eclipse.elk.core.util.IElkProgressMonitor)1 ElkNode (org.eclipse.elk.graph.ElkNode)1 Test (org.junit.Test)1