private Layout<ElementName, Dependency> circleLayout( final DirectedGraph<ElementName, Dependency> g, final Dimension d) { final CircleLayout<ElementName, Dependency> l = new CircleLayout<ElementName, Dependency>( g); l.setSize(new Dimension(d.width - 100, d.height - 60)); shift(l, 60, 50); return l; }
private Layout<ElementName, Dependency> circleLayout( final DirectedGraph<ElementName, Dependency> g, final Dimension d) { final CircleLayout<ElementName, Dependency> l = new CircleLayout<ElementName, Dependency>( g); l.setSize(new Dimension(d.width - 100, d.height - 60)); shift(l, 60, 50); return l; }
private Layout<ElementName, Dependency> circleLayout( final DirectedGraph<ElementName, Dependency> g, final Dimension d) { final CircleLayout<ElementName, Dependency> l = new CircleLayout<ElementName, Dependency>( g); l.setSize(new Dimension(d.width - 100, d.height - 60)); shift(l, 60, 50); return l; }
/** * Initialize with random locations . */ public void setSize(Dimension size) { setInitializer(new RandomLocationTransformer(size)); super.setSize(size); } }
/** * Re-position nodes in circular layout */ private void repositionTopology(String containerName) { Graph<String, String> graph = new SparseMultigraph<String, String>(); metaCache.get(containerName).clear(); metaCache.get(containerName).putAll(stagedNodes); metaCache.get(containerName).putAll(newNodes); for (Map<String, Object> on : metaCache.get(containerName).values()) { graph.addVertex(on.toString()); List<Map<String, Object>> adjacencies = (List<Map<String, Object>>) on.get("adjacencies"); for (Map<String, Object> adj : adjacencies) { graph.addEdge( adj.toString(), adj.get("nodeFrom").toString(), adj.get("nodeTo").toString() ); } } CircleLayout<String, String> layout = new CircleLayout<String, String>(graph); layout.setSize(new Dimension(1200, 365)); for (Map.Entry<String, Map<String, Object>> v : newNodes.entrySet()) { Double x = layout.transform(v.getKey()).getX(); Double y = layout.transform(v.getKey()).getY(); Map<String, String> nodeData = (HashMap<String, String>) v.getValue().get("data"); nodeData.put("$x", (x - 600) + ""); nodeData.put("$y", (y - 225) + ""); newNodes.get(v.getKey()).put("data", nodeData); } }
@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))); } }
@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))); } }