Search in sources :

Example 6 with AbstractLayoutProvider

use of org.eclipse.elk.core.AbstractLayoutProvider in project elk by eclipse.

the class DirectLayoutTest method testELKLayered.

/**
 * Test a plain Java layout using the ELK Layered algorithm.
 */
@Test
public void testELKLayered() {
    // create a KGraph for layout
    ElkNode parentNode = GraphTestUtils.createSimpleGraph();
    // add layout options to the elements of the graph
    addLayeredOptions(parentNode);
    // create a progress monitor
    IElkProgressMonitor progressMonitor = new BasicProgressMonitor();
    // create the layout provider
    AbstractLayoutProvider layoutProvider = new LayeredLayoutProvider();
    layoutProvider.initialize(null);
    // perform layout on the created graph
    layoutProvider.layout(parentNode, progressMonitor);
    // execute a trivial junit test
    for (ElkNode child : parentNode.getChildren()) {
        if (child.getX() <= 0 || child.getY() <= 0) {
            Assert.fail("Not all node coordinates have been set properly.");
        }
    }
    // output layout information
    printLayoutInfo(parentNode, progressMonitor);
}
Also used : ElkNode(org.eclipse.elk.graph.ElkNode) IElkProgressMonitor(org.eclipse.elk.core.util.IElkProgressMonitor) BasicProgressMonitor(org.eclipse.elk.core.util.BasicProgressMonitor) LayeredLayoutProvider(org.eclipse.elk.alg.layered.LayeredLayoutProvider) AbstractLayoutProvider(org.eclipse.elk.core.AbstractLayoutProvider) Test(org.junit.Test)

Aggregations

AbstractLayoutProvider (org.eclipse.elk.core.AbstractLayoutProvider)6 LayoutAlgorithmData (org.eclipse.elk.core.data.LayoutAlgorithmData)4 ElkNode (org.eclipse.elk.graph.ElkNode)3 Graph (org.eclipse.elk.alg.spore.graph.Graph)2 IElkProgressMonitor (org.eclipse.elk.core.util.IElkProgressMonitor)2 Sets (com.google.common.collect.Sets)1 List (java.util.List)1 Set (java.util.Set)1 TEdge (org.eclipse.elk.alg.common.TEdge)1 IOverlapHandler (org.eclipse.elk.alg.common.spore.IOverlapHandler)1 InternalProperties (org.eclipse.elk.alg.common.spore.InternalProperties)1 ScanlineOverlapCheck (org.eclipse.elk.alg.common.spore.ScanlineOverlapCheck)1 SVGImage (org.eclipse.elk.alg.common.utils.SVGImage)1 ElkGraphTransformer (org.eclipse.elk.alg.disco.transform.ElkGraphTransformer)1 LayeredLayoutProvider (org.eclipse.elk.alg.layered.LayeredLayoutProvider)1 OverlapRemovalStrategy (org.eclipse.elk.alg.spore.options.OverlapRemovalStrategy)1 RootSelection (org.eclipse.elk.alg.spore.options.RootSelection)1 SpanningTreeCostFunction (org.eclipse.elk.alg.spore.options.SpanningTreeCostFunction)1 SporeCompactionOptions (org.eclipse.elk.alg.spore.options.SporeCompactionOptions)1 SporeOverlapRemovalOptions (org.eclipse.elk.alg.spore.options.SporeOverlapRemovalOptions)1