Search in sources :

Example 1 with LayoutAlgorithm

use of org.opennms.features.topology.api.LayoutAlgorithm in project opennms by OpenNMS.

the class ManualLayoutAlgorithmTest method verifyAppliesXAndYCoordinates.

/*
     * This test verifies, that the vertex coordinates of x and y are applied to the
     * layout, if they exist.
     */
@Test
public void verifyAppliesXAndYCoordinates() {
    final ManualTest test = new ManualTest(new SimpleGraphBuilder("dummy").vertex("1").vX(0).vY(0).vertex("2").vX(1).vY(1).get());
    final LayoutAlgorithm layoutAlgorithm = new ManualLayoutAlgorithm(test.layoutManager);
    layoutAlgorithm.updateLayout(test.graph);
    Assert.assertEquals(ImmutableMap.builder().put(new DefaultVertexRef("dummy", "1"), new Point(0, 0)).put(new DefaultVertexRef("dummy", "2"), new Point(1, 1)).build(), test.layout.getLocations());
}
Also used : SimpleGraphBuilder(org.opennms.features.topology.api.support.SimpleGraphBuilder) GridLayoutAlgorithm(org.opennms.features.topology.app.internal.jung.GridLayoutAlgorithm) LayoutAlgorithm(org.opennms.features.topology.api.LayoutAlgorithm) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) Point(org.opennms.features.topology.api.Point) Test(org.junit.Test)

Example 2 with LayoutAlgorithm

use of org.opennms.features.topology.api.LayoutAlgorithm in project opennms by OpenNMS.

the class DefaultTopologyService method getPreferredLayoutAlgorithm.

// Determines default layout
@Override
public LayoutAlgorithm getPreferredLayoutAlgorithm(String metaTopologyId, String namespace) {
    Objects.requireNonNull(metaTopologyId);
    Objects.requireNonNull(namespace);
    final GraphProvider graphProvider = getGraphProvider(metaTopologyId, namespace);
    final String preferredLayout = graphProvider.getDefaults().getPreferredLayout();
    final LayoutAlgorithm preferredLayoutAlgorithm = serviceLocator != null ? findLayoutAlgorithm(preferredLayout) : DEFAULT_LAYOUT_ALGORITHM;
    return preferredLayoutAlgorithm;
}
Also used : D3TopoLayoutAlgorithm(org.opennms.features.topology.app.internal.jung.D3TopoLayoutAlgorithm) LayoutAlgorithm(org.opennms.features.topology.api.LayoutAlgorithm) GraphProvider(org.opennms.features.topology.api.topo.GraphProvider)

Aggregations

LayoutAlgorithm (org.opennms.features.topology.api.LayoutAlgorithm)2 Test (org.junit.Test)1 Point (org.opennms.features.topology.api.Point)1 SimpleGraphBuilder (org.opennms.features.topology.api.support.SimpleGraphBuilder)1 DefaultVertexRef (org.opennms.features.topology.api.topo.DefaultVertexRef)1 GraphProvider (org.opennms.features.topology.api.topo.GraphProvider)1 D3TopoLayoutAlgorithm (org.opennms.features.topology.app.internal.jung.D3TopoLayoutAlgorithm)1 GridLayoutAlgorithm (org.opennms.features.topology.app.internal.jung.GridLayoutAlgorithm)1