use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class NodeMapsApplication method init.
@Override
protected void init(final VaadinRequest vaadinRequest) {
m_request = vaadinRequest;
LOG.debug("initializing");
final VaadinApplicationContextImpl context = new VaadinApplicationContextImpl();
final UI currentUI = UI.getCurrent();
context.setSessionId(currentUI.getSession().getSession().getId());
context.setUiId(currentUI.getUIId());
context.setUsername(vaadinRequest.getRemoteUser());
Assert.notNull(m_alarmTable);
Assert.notNull(m_nodeTable);
final String searchString = vaadinRequest.getParameter("search");
final Integer maxClusterRadius = Integer.getInteger("gwt.maxClusterRadius", 350);
LOG.info("Starting search string: {}, max cluster radius: {}", searchString, maxClusterRadius);
m_alarmTable.setVaadinApplicationContext(context);
final EventProxy eventProxy = new EventProxy() {
@Override
public <T> void fireEvent(final T eventObject) {
LOG.debug("got event: {}", eventObject);
if (eventObject instanceof VerticesUpdateEvent) {
final VerticesUpdateEvent event = (VerticesUpdateEvent) eventObject;
final List<Integer> nodeIds = new ArrayList<Integer>();
for (final VertexRef ref : event.getVertexRefs()) {
if ("nodes".equals(ref.getNamespace()) && ref.getId() != null) {
nodeIds.add(Integer.valueOf(ref.getId()));
}
}
m_nodeMapComponent.setSelectedNodes(nodeIds);
return;
}
LOG.warn("Unsure how to deal with event: {}", eventObject);
}
@Override
public <T> void addPossibleEventConsumer(final T possibleEventConsumer) {
LOG.debug("(ignoring) add consumer: {}", possibleEventConsumer);
/* throw new UnsupportedOperationException("Not yet implemented!"); */
}
};
m_alarmTable.setEventProxy(eventProxy);
m_nodeTable.setEventProxy(eventProxy);
createMapPanel(searchString, maxClusterRadius);
createRootLayout();
addRefresher();
// Notify the user if no tileserver url or options are set
if (!configuration.isValid()) {
new InvalidConfigurationWindow(configuration).open();
}
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class FRLayoutAlgorithm method updateLayout.
@Override
public void updateLayout(final Graph graph) {
final Layout graphLayout = graph.getLayout();
SparseGraph<VertexRef, EdgeRef> jungGraph = new SparseGraph<VertexRef, EdgeRef>();
Collection<Vertex> vertices = graph.getDisplayVertices();
for (Vertex v : vertices) {
jungGraph.addVertex(v);
}
Collection<Edge> edges = graph.getDisplayEdges();
for (Edge e : edges) {
jungGraph.addEdge(e, e.getSource().getVertex(), e.getTarget().getVertex());
}
FRLayout<VertexRef, EdgeRef> layout = new FRLayout<VertexRef, EdgeRef>(jungGraph);
// Initialize the vertex positions to the last known positions from the layout
Dimension size = selectLayoutSize(graph);
layout.setInitializer(initializer(graphLayout, (int) size.getWidth() / 2, (int) size.getHeight() / 2));
// Resize the graph to accommodate the number of vertices
layout.setSize(size);
while (!layout.done()) {
layout.step();
}
// Store the new positions in the layout
for (Vertex v : vertices) {
graphLayout.setLocation(v, new Point(layout.getX(v) - (size.getWidth() / 2), (int) layout.getY(v) - (size.getHeight() / 2)));
}
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class CircleLayoutAlgorithm method updateLayout.
@Override
public void updateLayout(final Graph graph) {
final Layout graphLayout = graph.getLayout();
SparseGraph<VertexRef, Edge> jungGraph = new SparseGraph<VertexRef, Edge>();
Collection<? extends Vertex> vertices = graph.getDisplayVertices();
for (VertexRef v : vertices) {
jungGraph.addVertex(v);
}
for (Edge e : graph.getDisplayEdges()) {
jungGraph.addEdge(e, e.getSource().getVertex(), e.getTarget().getVertex());
}
CircleLayout<VertexRef, Edge> layout = new CircleLayout<VertexRef, Edge>(jungGraph);
layout.setInitializer(initializer(graphLayout));
layout.setSize(selectLayoutSize(graph));
for (VertexRef v : vertices) {
graphLayout.setLocation(v, new Point(layout.getX(v), layout.getY(v)));
}
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class RealUltimateLayoutAlgorithm method doFRLayout.
private static void doFRLayout(final Layout graphLayout, SparseGraph<VertexRef, EdgeRef> jungGraph, Dimension size, final int xOffset, final int yOffset) {
FRLayout<VertexRef, EdgeRef> layout = new FRLayout<VertexRef, EdgeRef>(jungGraph);
layout.setInitializer(initializer(graphLayout, xOffset, yOffset));
layout.setSize(size);
while (!layout.done()) {
layout.step();
}
for (VertexRef v : jungGraph.getVertices()) {
graphLayout.setLocation(v, new Point(layout.getX(v) + xOffset, layout.getY(v) + yOffset));
}
}
use of org.opennms.features.topology.api.topo.VertexRef in project opennms by OpenNMS.
the class KKLayoutAlgorithm method updateLayout.
@Override
public void updateLayout(final Graph graph) {
final Layout graphLayout = graph.getLayout();
SparseGraph<VertexRef, Edge> jungGraph = new SparseGraph<VertexRef, Edge>();
Collection<? extends Vertex> vertices = graph.getDisplayVertices();
for (Vertex v : vertices) {
jungGraph.addVertex(v);
}
Collection<? extends Edge> edges = graph.getDisplayEdges();
for (Edge e : edges) {
jungGraph.addEdge(e, e.getSource().getVertex(), e.getTarget().getVertex());
}
KKLayout<VertexRef, Edge> layout = new KKLayout<VertexRef, Edge>(jungGraph);
layout.setInitializer(initializer(graphLayout));
layout.setSize(selectLayoutSize(graph));
while (!layout.done()) {
layout.step();
}
for (Vertex v : vertices) {
graphLayout.setLocation(v, new Point(layout.getX(v), layout.getY(v)));
}
}
Aggregations