use of org.opennms.features.topology.api.Point in project opennms by OpenNMS.
the class HierarchyLayoutAlgorithm method applyLayoutPositions.
private void applyLayoutPositions(final Collection<? extends Vertex> vertices, final HierarchyLayout<VertexRef, Edge> layout, final Layout graphLayout) {
final List<VertexRef> displayVertices = vertices.stream().map(v -> (VertexRef) v).collect(Collectors.toList());
layout.horizontalSqueeze(displayVertices);
for (VertexRef v : displayVertices) {
Point2D p = layout.transform(v);
graphLayout.setLocation(v, new Point(p.getX(), p.getY()));
}
}
use of org.opennms.features.topology.api.Point in project opennms by OpenNMS.
the class RealUltimateLayoutAlgorithm method doSpringLayout.
private static void doSpringLayout(final Layout graphLayout, SparseGraph<VertexRef, EdgeRef> jungGraph, Dimension size, int repulsion) {
SpringLayout<VertexRef, EdgeRef> layout = new SpringLayout<VertexRef, EdgeRef>(jungGraph);
layout.setForceMultiplier(SPRING_FORCE_MULTIPLIER);
layout.setRepulsionRange(repulsion);
layout.setInitializer(initializer(graphLayout));
layout.setSize(size);
int count = 0;
while (!layout.done() && count < 700) {
layout.step();
count++;
}
for (VertexRef v : jungGraph.getVertices()) {
graphLayout.setLocation(v, new Point(layout.getX(v), layout.getY(v)));
}
}
use of org.opennms.features.topology.api.Point in project opennms by OpenNMS.
the class SpringLayoutAlgorithm method updateLayout.
@Override
public void updateLayout(final Graph graph) {
final Layout graphLayout = graph.getLayout();
SparseGraph<VertexRef, EdgeRef> jungGraph = new SparseGraph<VertexRef, EdgeRef>();
Collection<? extends Vertex> vertices = graph.getDisplayVertices();
for (VertexRef v : vertices) {
jungGraph.addVertex(v);
}
Collection<? extends Edge> edges = graph.getDisplayEdges();
for (Edge e : edges) {
jungGraph.addEdge(e, e.getSource().getVertex(), e.getTarget().getVertex());
}
SpringLayout<VertexRef, EdgeRef> layout = new SpringLayout<VertexRef, EdgeRef>(jungGraph);
layout.setForceMultiplier(SPRING_FORCE_MULTIPLIER);
layout.setRepulsionRange(SPRING_LAYOUT_REPULSION);
layout.setInitializer(initializer(graphLayout));
layout.setSize(selectLayoutSize(graph));
int count = 0;
while (!layout.done() && count < 700) {
layout.step();
count++;
}
for (VertexRef v : vertices) {
graphLayout.setLocation(v, new Point(layout.getX(v), layout.getY(v)));
}
}
use of org.opennms.features.topology.api.Point in project opennms by OpenNMS.
the class ISOMLayoutAlgorithm method updateLayout.
@Override
public void updateLayout(final Graph graph) {
final Layout graphLayout = graph.getLayout();
SparseGraph<VertexRef, EdgeRef> jungGraph = new SparseGraph<VertexRef, EdgeRef>();
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());
}
NonStupidISOMLayout layout = new NonStupidISOMLayout(jungGraph, graphLayout);
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)));
}
}
use of org.opennms.features.topology.api.Point 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)));
}
}
Aggregations