Search in sources :

Example 86 with VertexRef

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

the class RealUltimateLayoutAlgorithm method doISOMLayout.

private static void doISOMLayout(final Layout graphLayout, SparseGraph<VertexRef, EdgeRef> jungGraph, Dimension size) {
    NonStupidISOMLayout layout = new NonStupidISOMLayout(jungGraph, graphLayout);
    layout.setInitializer(initializer(graphLayout));
    layout.setSize(size);
    while (!layout.done()) {
        layout.step();
    }
    for (VertexRef v : jungGraph.getVertices()) {
        graphLayout.setLocation(v, new Point(layout.getX(v), layout.getY(v)));
    }
}
Also used : NonStupidISOMLayout(org.opennms.features.topology.app.internal.jung.ISOMLayoutAlgorithm.NonStupidISOMLayout) Point(org.opennms.features.topology.api.Point) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Example 87 with VertexRef

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

the class SavedHistory method getFocusVertices.

private static Set<VertexRef> getFocusVertices(GraphContainer graphContainer) {
    final Set<VertexRef> retVal = new HashSet<>();
    Criteria[] criterias = graphContainer.getCriteria();
    for (Criteria crit : criterias) {
        if (crit instanceof VertexHopGraphProvider.VertexHopCriteria && !(crit instanceof CollapsibleCriteria)) {
            retVal.addAll(((VertexHopGraphProvider.VertexHopCriteria) crit).getVertices());
        }
    }
    return retVal;
}
Also used : CollapsibleCriteria(org.opennms.features.topology.api.topo.CollapsibleCriteria) CollapsibleCriteria(org.opennms.features.topology.api.topo.CollapsibleCriteria) SearchCriteria(org.opennms.features.topology.api.topo.SearchCriteria) Criteria(org.opennms.features.topology.api.topo.Criteria) VertexRef(org.opennms.features.topology.api.topo.VertexRef) HashSet(java.util.HashSet)

Example 88 with VertexRef

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

the class VertexHopGraphProvider method getFocusNodes.

public Set<VertexRef> getFocusNodes(Criteria... criteria) {
    Set<VertexRef> focusNodes = new HashSet<VertexRef>();
    for (Criteria criterium : criteria) {
        try {
            VertexHopCriteria hopCriterium = (VertexHopCriteria) criterium;
            focusNodes.addAll(hopCriterium.getVertices());
        } catch (ClassCastException e) {
        }
    }
    return focusNodes;
}
Also used : CollapsibleCriteria(org.opennms.features.topology.api.topo.CollapsibleCriteria) Criteria(org.opennms.features.topology.api.topo.Criteria) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) VertexRef(org.opennms.features.topology.api.topo.VertexRef) HashSet(java.util.HashSet)

Example 89 with VertexRef

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

the class VertexInfoPanelItemProvider method findSingleSelectedItem.

@Override
protected Optional<VertexRef> findSingleSelectedItem(GraphContainer container) {
    Collection<VertexRef> selectedVertexRefs = container.getSelectionManager().getSelectedVertexRefs();
    if (selectedVertexRefs.size() == 1) {
        final VertexRef vertexRef = selectedVertexRefs.iterator().next();
        Vertex vertex = container.getTopologyServiceClient().getVertex(vertexRef);
        return Optional.ofNullable(vertex);
    }
    return Optional.empty();
}
Also used : Vertex(org.opennms.features.topology.api.topo.Vertex) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Example 90 with VertexRef

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

the class BreadcrumbPathCalculator method findPath.

static List<VertexRef> findPath(Map<VertexRef, EdgeRef> incomingEdgeMap, VertexRef vertexToFind) {
    Objects.requireNonNull(incomingEdgeMap);
    Objects.requireNonNull(vertexToFind);
    List<VertexRef> vertexRefs = Lists.newArrayList();
    if (incomingEdgeMap.get(vertexToFind) != null) {
        addPathRecursively(vertexRefs, vertexToFind, incomingEdgeMap);
        if (vertexRefs.size() >= 2) {
            Iterator<VertexRef> it = vertexRefs.iterator();
            VertexRef left = it.next();
            while (it.hasNext()) {
                VertexRef right = it.next();
                if (left.getNamespace().equals(right.getNamespace())) {
                    it.remove();
                }
                left = right;
            }
        }
    }
    return vertexRefs;
}
Also used : VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Aggregations

VertexRef (org.opennms.features.topology.api.topo.VertexRef)105 DefaultVertexRef (org.opennms.features.topology.api.topo.DefaultVertexRef)33 Vertex (org.opennms.features.topology.api.topo.Vertex)31 Point (org.opennms.features.topology.api.Point)23 Criteria (org.opennms.features.topology.api.topo.Criteria)22 Edge (org.opennms.features.topology.api.topo.Edge)22 Test (org.junit.Test)21 List (java.util.List)20 ArrayList (java.util.ArrayList)19 Collectors (java.util.stream.Collectors)18 EdgeRef (org.opennms.features.topology.api.topo.EdgeRef)18 Map (java.util.Map)17 Status (org.opennms.features.topology.api.topo.Status)15 Collection (java.util.Collection)13 HashSet (java.util.HashSet)13 SparseGraph (edu.uci.ics.jung.graph.SparseGraph)12 HashMap (java.util.HashMap)12 Layout (org.opennms.features.topology.api.Layout)12 AbstractVertex (org.opennms.features.topology.api.topo.AbstractVertex)12 Lists (com.google.common.collect.Lists)11