use of org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria in project opennms by OpenNMS.
the class TopologyUI method getFocusVertices.
private int getFocusVertices(GraphContainer graphContainer) {
int count = 0;
Criteria[] crits = graphContainer.getCriteria();
for (Criteria criteria : crits) {
try {
VertexHopCriteria catCrit = (VertexHopCriteria) criteria;
count += catCrit.getVertices().size();
} catch (ClassCastException e) {
}
}
return count;
}
use of org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria in project opennms by OpenNMS.
the class RemoveFocusOtherVerticesOperation method execute.
@Override
public void execute(List<VertexRef> targets, final OperationContext operationContext) {
final GraphContainer graphContainer = operationContext.getGraphContainer();
final Set<VertexHopCriteria> criteriaForGraphContainer = Criteria.getCriteriaForGraphContainer(graphContainer, VertexHopCriteria.class);
boolean didRemoveCriteria = false;
for (VertexHopCriteria eachCriteria : criteriaForGraphContainer) {
boolean shouldRemove = true;
for (VertexRef vertex : eachCriteria.getVertices()) {
if (targets.contains(vertex)) {
// The criteria references at least one of our targets, so
// we shouldn't remove it
shouldRemove = false;
break;
}
}
if (shouldRemove) {
graphContainer.removeCriteria(eachCriteria);
didRemoveCriteria = true;
}
}
if (didRemoveCriteria) {
// Only update the layout if any changes were made
graphContainer.redoLayout();
}
}
use of org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria in project opennms by OpenNMS.
the class RemoveFocusVerticesOperation method execute.
@Override
public void execute(List<VertexRef> targets, final OperationContext operationContext) {
if (targets == null || targets.isEmpty()) {
return;
}
final GraphContainer graphContainer = operationContext.getGraphContainer();
final Set<VertexHopCriteria> criteriaForGraphContainer = Criteria.getCriteriaForGraphContainer(graphContainer, VertexHopCriteria.class);
for (VertexHopCriteria eachCriteria : criteriaForGraphContainer) {
for (VertexRef eachTarget : targets) {
if (eachCriteria.getVertices().contains(eachTarget)) {
graphContainer.removeCriteria(eachCriteria);
}
}
}
graphContainer.redoLayout();
}
use of org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria in project opennms by OpenNMS.
the class EnhancedLinkdTopologyProvider method addVertexHopCriteria.
@Override
public void addVertexHopCriteria(SearchResult searchResult, GraphContainer container) {
LOG.debug("SearchProvider->addVertexHopCriteria: called with search result: '{}'", searchResult);
VertexHopCriteria criterion = LinkdHopCriteriaFactory.createCriteria(searchResult.getId(), searchResult.getLabel());
container.addCriteria(criterion);
LOG.debug("SearchProvider->addVertexHop: adding hop criteria {}.", criterion);
logCriteriaInContainer(container);
}
use of org.opennms.features.topology.api.support.VertexHopGraphProvider.VertexHopCriteria in project opennms by OpenNMS.
the class EnhancedLinkdTopologyProvider method getVertexRefsBy.
@Override
public Set<VertexRef> getVertexRefsBy(SearchResult searchResult, GraphContainer container) {
LOG.debug("SearchProvider->getVertexRefsBy: called with search result: '{}'", searchResult);
org.opennms.features.topology.api.topo.Criteria criterion = findCriterion(searchResult.getId(), container);
Set<VertexRef> vertices = ((VertexHopCriteria) criterion).getVertices();
LOG.debug("SearchProvider->getVertexRefsBy: found '{}' vertices.", vertices.size());
return vertices;
}
Aggregations