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; }
public void initialize() { Dimension d = getSize(); if (d != null) { if (vertex_ordered_list == null) setVertexOrder(new ArrayList<V>(getGraph().getVertices())); double height = d.getHeight(); double width = d.getWidth(); if (radius <= 0) { radius = 0.45 * (height < width ? height : width); } int i = 0; for (V v : vertex_ordered_list) { Point2D coord = transform(v); double angle = (2 * Math.PI * i) / vertex_ordered_list.size(); coord.setLocation(Math.cos(angle) * radius + width / 2, Math.sin(angle) * radius + height / 2); CircleVertexData data = getCircleData(v); data.setAngle(angle); i++; } } }
public void reset() { initialize(); }
public void initialize() { Dimension d = getSize(); if (d != null) { if (vertex_ordered_list == null) setVertexOrder(new ArrayList<V>(getGraph().getVertices())); double height = d.getHeight(); double width = d.getWidth(); if (radius <= 0) { radius = 0.45 * (height < width ? height : width); } int i = 0; for (V v : vertex_ordered_list) { Point2D coord = apply(v); double angle = (2 * Math.PI * i) / vertex_ordered_list.size(); coord.setLocation(Math.cos(angle) * radius + width / 2, Math.sin(angle) * radius + height / 2); CircleVertexData data = getCircleData(v); data.setAngle(angle); i++; } } }
private Layout<Node, Edge> newLayout(final Diagram diagram) { final Layout<Node, Edge> diagramLayout; if (layout != null && layout.startsWith("spring")) { diagramLayout = new SpringLayout<Node, Edge>(diagram, new ConstantTransformer(Integer.parseInt(config("spring", "100")))); } else if (layout != null && layout.startsWith("kk")) { Distance<Node> distance = new DijkstraDistance<Node, Edge>(diagram); if (layout.endsWith("unweight")) { distance = new UnweightedShortestPath<Node, Edge>(diagram); } diagramLayout = new KKLayout<Node, Edge>(diagram, distance); } else if (layout != null && layout.equalsIgnoreCase("circle")) { diagramLayout = new CircleLayout<Node, Edge>(diagram); } else if (layout != null && layout.equalsIgnoreCase("fr")) { diagramLayout = new FRLayout<Node, Edge>(diagram); } else { final LevelLayout levelLayout = new LevelLayout(diagram); levelLayout.adjust = adjust; diagramLayout = levelLayout; } return diagramLayout; }
@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))); } }
/** * 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); } }
/** * Initialize with random locations . */ public void setSize(Dimension size) { setInitializer(new RandomLocationTransformer(size)); super.setSize(size); } }
/** * Sets the order of the vertices in the layout according to the ordering * specified by {@code comparator}. */ public void setVertexOrder(Comparator<V> comparator) { if (vertex_ordered_list == null) vertex_ordered_list = new ArrayList<V>(getGraph().getVertices()); Collections.sort(vertex_ordered_list, comparator); }
private void groupCluster(AggregateLayout<Number,Number> layout, Set<Number> vertices) { if(vertices.size() < layout.getGraph().getVertexCount()) { Point2D center = layout.apply(vertices.iterator().next()); Graph<Number,Number> subGraph = SparseMultigraph.<Number,Number>getFactory().get(); for(Number v : vertices) { subGraph.addVertex(v); } Layout<Number,Number> subLayout = new CircleLayout<Number,Number>(subGraph); subLayout.setInitializer(vv.getGraphLayout()); subLayout.setSize(new Dimension(40,40)); layout.put(subLayout,center); vv.repaint(); } } }
@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))); } }
/** * Sets the order of the vertices in the layout according to the ordering * of {@code vertex_list}. */ public void setVertexOrder(List<V> vertex_list) { if (!vertex_list.containsAll(getGraph().getVertices())) throw new IllegalArgumentException("Supplied list must include " + "all vertices of the graph"); this.vertex_ordered_list = vertex_list; }
createEdges(v); Layout<Integer,Number> layout = new CircleLayout<Integer,Number>(graph); vv = new VisualizationViewer<Integer,Number>(layout, new Dimension(600,400)); vv.setBackground(Color.white);
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; }
/** * Sets the order of the vertices in the layout according to the ordering * specified by {@code comparator}. * @param comparator the comparator to use to order the vertices */ public void setVertexOrder(Comparator<V> comparator) { if (vertex_ordered_list == null) vertex_ordered_list = new ArrayList<V>(getGraph().getVertices()); Collections.sort(vertex_ordered_list, comparator); }
public void reset() { initialize(); }
@Override public void actionPerformed(ActionEvent e) { final GraphViewerPanel viewerPanel = (GraphViewerPanel) frame.getTabbedPane().getSelectedComponent(); CircleLayout circleLayout = new CircleLayout<String, String>(viewerPanel.getCurrentGraph()); MyVisualizationViewer vv = (MyVisualizationViewer) viewerPanel.getVisualizationViewer(); vv.setGraphLayout(circleLayout); vv.repaint(); } }
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; }
/** * Sets the order of the vertices in the layout according to the ordering * of {@code vertex_list}. * @param vertex_list a list specifying the ordering of the vertices */ public void setVertexOrder(List<V> vertex_list) { if (!vertex_list.containsAll(getGraph().getVertices())) throw new IllegalArgumentException("Supplied list must include " + "all vertices of the graph"); this.vertex_ordered_list = vertex_list; }
Layout<String, String> layout = new CircleLayout<String, String>(graph); layout.setSize(new Dimension(900, 600));