use of edu.uci.ics.jung.algorithms.layout.CircleLayout 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.algorithms.layout.CircleLayout in project titan.EclipsePlug-ins by eclipse.
the class ClusterTransformer method groupCluster.
/**
* Calculate positions for one cluster
*
* @param vertices
* : the set of vertices inside the cluster
*/
protected void groupCluster(final Set<NodeDescriptor> vertices) {
if (vertices.size() < mainLayout.getGraph().getVertexCount()) {
final Point2D center = mainLayout.apply(vertices.iterator().next());
final DirectedSparseGraph<NodeDescriptor, EdgeDescriptor> subGraph = new DirectedSparseGraph<NodeDescriptor, EdgeDescriptor>();
for (final NodeDescriptor v : vertices) {
subGraph.addVertex(v);
}
final Layout<NodeDescriptor, EdgeDescriptor> subLayout = new CircleLayout<NodeDescriptor, EdgeDescriptor>(subGraph);
subLayout.setInitializer(mainLayout);
// TODO Could we calculate the needed space for one cluster?
final Dimension canvasSize = new Dimension(100, 100);
subLayout.setSize(canvasSize);
mainLayout.put(subLayout, center);
}
}
Aggregations