本文整理了Java中org.opennms.features.topology.api.topo.Vertex
类的一些代码示例,展示了Vertex
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex
类的具体详情如下:
包路径:org.opennms.features.topology.api.topo.Vertex
类名称:Vertex
暂无
代码示例来源:origin: stackoverflow.com
@Override
public int hashCode()
{
return getLabel().hashCode();
}
@Override
public boolean equals(Object o) {
Vertex v = (Vertex)o;
return v.getLabel().equals(this.getLabel());
}
@Override
public String toString()
{
return getLabel();
}
代码示例来源:origin: org.opennms.features.topology/api
protected WrappedVertex(Vertex vertex) {
this((VertexRef)vertex);
iconKey = vertex.getIconKey();
ipAddr = vertex.getIpAddress();
nodeID = vertex.getNodeID();
if (vertex.getParent() != null) parent = new WrappedVertex(vertex.getParent());
styleName = vertex.getStyleName();
tooltipText = vertex.getTooltipText();
x = vertex.getX();
y = vertex.getY();
group = vertex.isGroup();
locked = vertex.isLocked();
selected = vertex.isSelected();
}
代码示例来源:origin: OpenNMS/opennms
@Override
public int compare(Vertex v1, Vertex v2) {
return ComparisonChain.start()
.compare(getIndex(v1), getIndex(v2))
.compare(v1.getLabel(), v2.getLabel())
.compare(v1.getId(), v2.getId())
.result();
}
}).collect(Collectors.toList());
代码示例来源:origin: OpenNMS/opennms
private static String getTooltipText(Vertex vertex) {
String tooltipText = vertex.getTooltipText();
// If the tooltip text is null, use the label
tooltipText = (tooltipText == null ? vertex.getLabel() : tooltipText);
// If the label is null, use a blank string
return (tooltipText == null ? "" : tooltipText);
}
代码示例来源:origin: OpenNMS/opennms
private String createIconKey(Vertex vertex) {
return String.format("%s.%s", vertex.getNamespace(), vertex.getId());
}
代码示例来源:origin: OpenNMS/opennms
@Override
public void execute(final List<VertexRef> targets, final OperationContext operationContext) {
final VertexRef target = targets.get(0);
final Vertex vertex = getVertexItem(operationContext, target);
final Optional<OnmsNode> node = getNodeIfAvailable(vertex);
final List<String> locations = monitoringLocationDao.findAll().stream().map(OnmsMonitoringLocation::getLocationName).collect(Collectors.toList());
final String defaultLocation = node.isPresent()
? node.get().getLocation().getLocationName()
: MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID;
final List<String> ipAddresses = node.isPresent()
? Lists.newArrayList(node.get().getIpInterfaces()).stream().map(eachInterface -> InetAddressUtils.str(eachInterface.getIpAddress())).collect(Collectors.toList())
: Lists.newArrayList(vertex.getIpAddress());
final String defaultIp = getDefaultIp(vertex, node);
final String caption = String.format("Ping - %s (%s)", vertex.getLabel(), vertex.getIpAddress());
new PingWindow(pingClient,
locations, ipAddresses,
defaultLocation, defaultIp,
caption)
.open();
}
代码示例来源:origin: OpenNMS/opennms
/**
* Verifies that the provided vertex has a valid node assigned and the node has at least one ip address.
*
* @param vertex The vertex to check
* @return True if a node with at least one ip address is assigned, false otherwise.
*/
private boolean hasValidNodeId(Vertex vertex) {
return vertex.getNodeID() != null && getNodeIfAvailable(vertex).isPresent();
}
代码示例来源:origin: OpenNMS/opennms
final Collection<Vertex> vertices = graph.getDisplayVertices();
for (Vertex vertex : vertices) {
PointEntity pointEntity = layoutEntity.getPosition(vertex.getNamespace(), vertex.getId());
layout.setLocation(vertex, new Point(pointEntity.getX(), pointEntity.getY()));
}).count();
final long noVertexLocationCount = vertices.stream().filter(v -> {
boolean hasNoX = v.getX() == null || v.getX().intValue() == 0;
boolean hasNoY = v.getY() == null || v.getY().intValue() == 0;
return hasNoX && hasNoY;
}).count();
layout.setLocation(vertex, new Point(vertex.getX(), vertex.getY()));
代码示例来源:origin: OpenNMS/opennms
@Override
public void visitVertex(Vertex vertex) throws PaintException {
boolean selected = isSelected(m_graphContainer.getSelectionManager(), vertex);
Point initialLocation = m_layout.getInitialLocation(vertex);
Point location = m_layout.getLocation(vertex);
SharedVertex v = new SharedVertex();
v.setKey(vertex.getKey());
//TODO cast to int for now
v.setInitialX((int)initialLocation.getX());
v.setInitialY((int)initialLocation.getY());
v.setX((int)location.getX());
v.setY((int) location.getY());
v.setSelected(selected);
v.setStatus(getStatus(vertex));
v.setStatusCount(getStatusCount(vertex));
v.setSVGIconId(getIconId(vertex));
v.setLabel(vertex.getLabel());
v.setTooltipText(getTooltipText(vertex));
v.setStyleName(getVertexStyle(vertex, selected));
v.setTargets(getTargets(vertex));
v.setEdgePathOffset(getEdgePathOffset(vertex));
m_vertices.add(v);
}
代码示例来源:origin: org.opennms.features.topology.plugins/status
private boolean isGroup(VertexRef vertexRef) {
if(vertexRef instanceof Vertex) {
return ((Vertex) vertexRef).isGroup();
}
return false;
}
代码示例来源:origin: OpenNMS/opennms
private boolean hasValidIpAddress(Vertex vertexItem) {
// Only enable if we actually have something to ping
// Be aware that originally the ip address was also resolved via InetAddressUtils.getInetAddress(ipAddress)
// but in cases were the ipAddress is not reachable, the response thread would block and causing
// the ui to build the menubar very slowly. Therefore this was changed. See NMS-10452
return !Strings.isNullOrEmpty(vertexItem.getIpAddress());
}
代码示例来源:origin: org.opennms.features.topology.plugins/status
private Status getStatusForGroup(VertexRef groupRef) {
List<Vertex> vertices = getVertexProvider().getChildren(groupRef);
Collection<Integer> nodeIds = new ArrayList<Integer>();
for(Vertex vertex : vertices) {
if(!vertex.isGroup()) {
nodeIds.add(vertex.getNodeID());
}
}
CriteriaBuilder builder = new CriteriaBuilder(OnmsAlarm.class);
builder.alias("node", "node");
builder.in("node.id", nodeIds);
builder.ge("severity", OnmsSeverity.WARNING);
builder.orderBy("severity").desc();
builder.limit(1);
return getStatusForCriteria(builder);
}
代码示例来源:origin: OpenNMS/opennms
@Override
public Defaults getDefaults() {
return new Defaults()
.withCriteria(() -> {
if (getVertices().isEmpty()) {
return Lists.newArrayList();
}
return getVertices().stream().filter(e -> Icons.DATACENTER.equals(e.getIconKey())).map(DefaultVertexHopCriteria::new).collect(Collectors.toList());
});
}
代码示例来源:origin: org.opennms.features.topology.plugins/devutils
@Override
public void execute(List<VertexRef> targets, OperationContext operationContext) {
GraphProvider graphProvider = operationContext.getGraphContainer().getBaseTopology();
Map<String, WrappedVertex> idMap = new HashMap<String, WrappedVertex>();
// first create all the vertices;
List<WrappedVertex> vertices = new ArrayList<WrappedVertex>();
for(Vertex vertex : graphProvider.getVertices()) {
WrappedVertex wrappedVertex = WrappedVertex.create(vertex);
vertices.add(wrappedVertex);
idMap.put(vertex.getId(), wrappedVertex);
}
// then set the parents for each
for(Vertex vertex : graphProvider.getVertices()) {
Vertex parent = graphProvider.getParent(vertex);
if (parent != null) {
WrappedVertex wrappedVertex = idMap.get(vertex.getId());
WrappedVertex wrappedParent = idMap.get(parent.getId());
wrappedVertex.parent = wrappedParent;
}
}
// then create the edges
List<WrappedEdge> edges = new ArrayList<WrappedEdge>();
for(Edge edge : graphProvider.getEdges()) {
WrappedVertex wrappedSource = idMap.get(edge.getSource().getVertex().getId());
WrappedVertex wrappedTarget = idMap.get(edge.getTarget().getVertex().getId());
edges.add(new WrappedEdge(edge, wrappedSource, wrappedTarget));
}
WrappedGraph graph = new WrappedGraph(graphProvider.getVertexNamespace(), vertices, edges);
JAXB.marshal(graph, new File("/tmp/saved-graph.xml"));
}
代码示例来源:origin: org.opennms.features.topology/org.opennms.features.topology.netutils
@Override
public void execute(final List<VertexRef> targets, final OperationContext operationContext) {
final VertexRef target = targets.get(0);
final Vertex vertex = getVertexItem(operationContext, target);
final Optional<OnmsNode> node = getNodeIfAvailable(vertex);
final List<String> locations = monitoringLocationDao.findAll().stream().map(OnmsMonitoringLocation::getLocationName).collect(Collectors.toList());
final String defaultLocation = node.isPresent()
? node.get().getLocation().getLocationName()
: MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID;
final List<String> ipAddresses = node.isPresent()
? Lists.newArrayList(node.get().getIpInterfaces()).stream().map(eachInterface -> InetAddressUtils.str(eachInterface.getIpAddress())).collect(Collectors.toList())
: Lists.newArrayList(vertex.getIpAddress());
final String defaultIp = getDefaultIp(vertex, node);
final String caption = String.format("Ping - %s (%s)", vertex.getLabel(), vertex.getIpAddress());
new PingWindow(pingClient,
locations, ipAddresses,
defaultLocation, defaultIp,
caption)
.open();
}
代码示例来源:origin: org.opennms.features.topology/org.opennms.features.topology.app
private String createIconKey(Vertex vertex) {
return String.format("%s.%s", vertex.getNamespace(), vertex.getId());
}
代码示例来源:origin: org.opennms.features.topology/org.opennms.features.topology.netutils
/**
* Verifies that the provided vertex has a valid node assigned and the node has at least one ip address.
*
* @param vertex The vertex to check
* @return True if a node with at least one ip address is assigned, false otherwise.
*/
private boolean hasValidNodeId(Vertex vertex) {
return vertex.getNodeID() != null && getNodeIfAvailable(vertex).isPresent();
}
代码示例来源:origin: org.opennms.features.topology/org.opennms.features.topology.app
final Collection<Vertex> vertices = graph.getDisplayVertices();
for (Vertex vertex : vertices) {
PointEntity pointEntity = layoutEntity.getPosition(vertex.getNamespace(), vertex.getId());
layout.setLocation(vertex, new Point(pointEntity.getX(), pointEntity.getY()));
}).count();
final long noVertexLocationCount = vertices.stream().filter(v -> {
boolean hasNoX = v.getX() == null || v.getX().intValue() == 0;
boolean hasNoY = v.getY() == null || v.getY().intValue() == 0;
return hasNoX && hasNoY;
}).count();
layout.setLocation(vertex, new Point(vertex.getX(), vertex.getY()));
代码示例来源:origin: org.opennms.features.topology/org.opennms.features.topology.app
private static String getTooltipText(Vertex vertex) {
String tooltipText = vertex.getTooltipText();
// If the tooltip text is null, use the label
tooltipText = (tooltipText == null ? vertex.getLabel() : tooltipText);
// If the label is null, use a blank string
return (tooltipText == null ? "" : tooltipText);
}
代码示例来源:origin: org.opennms.features.topology/org.opennms.features.topology.app
@Override
public void visitVertex(Vertex vertex) throws PaintException {
boolean selected = isSelected(m_graphContainer.getSelectionManager(), vertex);
Point initialLocation = m_layout.getInitialLocation(vertex);
Point location = m_layout.getLocation(vertex);
SharedVertex v = new SharedVertex();
v.setKey(vertex.getKey());
//TODO cast to int for now
v.setInitialX((int)initialLocation.getX());
v.setInitialY((int)initialLocation.getY());
v.setX((int)location.getX());
v.setY((int) location.getY());
v.setSelected(selected);
v.setStatus(getStatus(vertex));
v.setStatusCount(getStatusCount(vertex));
v.setSVGIconId(getIconId(vertex));
v.setLabel(vertex.getLabel());
v.setTooltipText(getTooltipText(vertex));
v.setStyleName(getVertexStyle(vertex, selected));
v.setTargets(getTargets(vertex));
v.setEdgePathOffset(getEdgePathOffset(vertex));
m_vertices.add(v);
}
内容来源于网络,如有侵权,请联系作者删除!