Search in sources :

Example 11 with AbstractEdge

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

the class HierarchyLayoutAlgorithmTest method basicLayout.

/**
     * Generates the following graph:
     *
     *     t1-v1
     *    /     \
     *  t1-v2  t1-v3
     *
     * and verifies the resulting X and Y coordinates.
     */
@Test
public void basicLayout() {
    // Vertices
    vertices.add(new LevelAwareTestVertex("v1", 0));
    vertices.add(new LevelAwareTestVertex("v2", 1));
    vertices.add(new LevelAwareTestVertex("v3", 1));
    // Edges
    edges.add(new AbstractEdge("test", "v1-v2", vertices.get(0), vertices.get(1)));
    edges.add(new AbstractEdge("test", "v1-v3", vertices.get(0), vertices.get(2)));
    buildLayout();
    expectVertexToBeAt(0, 150.0d, 100.0d);
    expectVertexToBeAt(1, 100.0d, 200.0d);
    expectVertexToBeAt(2, 200.0d, 200.0d);
}
Also used : AbstractEdge(org.opennms.features.topology.api.topo.AbstractEdge) Test(org.junit.Test)

Example 12 with AbstractEdge

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

the class HierarchyLayoutAlgorithmTest method notSoBasicLayout.

/**
     * Generates the following graph:
     *
     *     t1-v1       t2-v1
     *    /     \
     *  t1-v2  t1-v3
     *   /
     * t1-v4
     *
     * and verifies the resulting X and Y coordinates.
     */
@Test
public void notSoBasicLayout() {
    // Vertices
    vertices.add(new LevelAwareTestVertex("t1-v1", 0));
    vertices.add(new LevelAwareTestVertex("t1-v2", 1));
    vertices.add(new LevelAwareTestVertex("t1-v3", 1));
    vertices.add(new LevelAwareTestVertex("t1-v4", 2));
    vertices.add(new LevelAwareTestVertex("t2-v1", 0));
    // Edges
    edges.add(new AbstractEdge("test", "t1-v1-v2", vertices.get(0), vertices.get(1)));
    edges.add(new AbstractEdge("test", "t1-v1-v3", vertices.get(0), vertices.get(2)));
    edges.add(new AbstractEdge("test", "t1-v2-v4", vertices.get(1), vertices.get(3)));
    buildLayout();
    expectVertexToBeAt(0, 150.0d, 100.0d);
    expectVertexToBeAt(1, 100.0d, 200.0d);
    expectVertexToBeAt(2, 200.0d, 200.0d);
    expectVertexToBeAt(3, 100.0d, 300.0d);
    expectVertexToBeAt(4, 300.0d, 100.0d);
}
Also used : AbstractEdge(org.opennms.features.topology.api.topo.AbstractEdge) Test(org.junit.Test)

Aggregations

AbstractEdge (org.opennms.features.topology.api.topo.AbstractEdge)12 Vertex (org.opennms.features.topology.api.topo.Vertex)5 DefaultVertexRef (org.opennms.features.topology.api.topo.DefaultVertexRef)4 Edge (org.opennms.features.topology.api.topo.Edge)4 SimpleConnector (org.opennms.features.topology.api.topo.SimpleConnector)4 Test (org.junit.Test)3 VertexRef (org.opennms.features.topology.api.topo.VertexRef)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Random (java.util.Random)2 SimpleLeafVertex (org.opennms.features.topology.api.topo.SimpleLeafVertex)2 FormLayout (com.vaadin.ui.FormLayout)1 UnweightedShortestPath (edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath)1 DirectedSparseGraph (edu.uci.ics.jung.graph.DirectedSparseGraph)1 IgnoreHopCriteria (org.opennms.features.topology.api.support.IgnoreHopCriteria)1 AbstractVertex (org.opennms.features.topology.api.topo.AbstractVertex)1 EdgeRef (org.opennms.features.topology.api.topo.EdgeRef)1 TestVertex (org.opennms.features.topology.app.internal.TestVertex)1 OnmsApplication (org.opennms.netmgt.model.OnmsApplication)1