use of edu.uci.ics.jung.graph.SparseGraph 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 edu.uci.ics.jung.graph.SparseGraph 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 edu.uci.ics.jung.graph.SparseGraph 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)));
}
}
use of edu.uci.ics.jung.graph.SparseGraph in project opennms by OpenNMS.
the class RealUltimateLayoutAlgorithm method updateLayout.
@Override
public void updateLayout(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());
}
Dimension size = selectLayoutSize(graph);
Dimension paddedSize = new Dimension((int) (size.getWidth() * .75), (int) (size.getHeight() * .75));
doISOMLayout(graphLayout, jungGraph, size);
doSpringLayout(graphLayout, jungGraph, size, SPRING_LAYOUT_REPULSION);
doFRLayout(graphLayout, jungGraph, paddedSize, (int) (size.getWidth() / 8.0), (int) (size.getHeight() / 8.0));
doSpringLayout(graphLayout, jungGraph, size, SPRING_LAYOUT_REPULSION);
}
use of edu.uci.ics.jung.graph.SparseGraph in project opennms by OpenNMS.
the class TopoFRLayoutAlgorithm 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());
}
TopoFRLayout<VertexRef, EdgeRef> layout = new TopoFRLayout<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)));
}
}
Aggregations