@SuppressWarnings({ "rawtypes", "unchecked" }) public static void main(String[] args) throws IOException { JFrame jf = new JFrame(); Graph g = getGraph(); VisualizationViewer vv = new VisualizationViewer(new FRLayout(g)); jf.getContentPane().add(vv); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.pack(); jf.setVisible(true); }
public MyVisualizationViewer(TopologyViewerConfType viewerConfig, Graph<String, String> graph, Map<String, GraphMLMetadata<String>> vertexMetadatas, Map<String, GraphMLMetadata<String>> edgeMetadatas, Map<String, Icon> iconMap, Map<String, Stroke> edgesStrokeMap, Map<String, Color> edgesColorMap) { // RadialTreeLayout<String,Integer> radialLayout; super(new MyPersistentLayoutImpl(new FRLayout<String,String>(graph))); // super(new PersistentLayoutImpl(new RadialTreeLayout(<String,Integer>(graph))); this.viewerConfig = viewerConfig; this.vertexMetadatas = vertexMetadatas; this.edgeMetadatas = edgeMetadatas; this.iconMap = iconMap; this.edgesStrokeMap = edgesStrokeMap; this.edgesColorMap = edgesColorMap; createGraphViewer(); }
new PersistentLayoutImpl<String,Number>(new FRLayout<String,Number>(graph));
public void actionPerformed(ActionEvent ae) { Dimension d = new Dimension(600,600); if (switchLayout.getText().indexOf("Spring") > 0) { switchLayout.setText("Switch to FRLayout"); layout = new SpringLayout<Number,Number>(g, Functions.<Integer>constant(EDGE_LENGTH)); layout.setSize(d); vv.getModel().setGraphLayout(layout, d); } else { switchLayout.setText("Switch to SpringLayout"); layout = new FRLayout<Number,Number>(g, d); vv.getModel().setGraphLayout(layout, d); } } });
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; }
createGraph(VERTEX_COUNT); FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph); layout.setMaxIterations(100); vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400,400));
FRLayout frLayout = new FRLayout<String, String>(graph); frLayout.setRepulsionMultiplier(repultion); frLayout.setAttractionMultiplier(attraction);
private static AbstractLayout<Vertex, Edge> getLayout(GraphJung<Graph> graph, String layoutName) { switch (layoutName) { case "KKLayout": return new KKLayout<>(graph); case "CircleLayout": return new CircleLayout<>(graph); case "FRLayout": return new FRLayout<>(graph); case "FRLayout2": return new FRLayout2<>(graph); case "ISOMLayout": return new ISOMLayout<>(graph); case "SpringLayout": return new SpringLayout<>(graph); default: return new KKLayout<>(graph); } }
Layout<BoostedNode, String> layout = new FRLayout<BoostedNode, String>( graph);
private static void doFRLayout(final Layout graphLayout, SparseGraph<VertexRef, EdgeRef> jungGraph, Dimension size, final int xOffset, final int yOffset) { FRLayout<VertexRef, EdgeRef> layout = new FRLayout<VertexRef, EdgeRef>(jungGraph); layout.setInitializer(initializer(graphLayout, xOffset, yOffset)); layout.setSize(size); while(!layout.done()) { layout.step(); } for(VertexRef v : jungGraph.getVertices()) { graphLayout.setLocation(v, new Point(layout.getX(v)+xOffset, layout.getY(v)+yOffset)); } }
@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))); } }
private static void doFRLayout(final Layout graphLayout, SparseGraph<VertexRef, EdgeRef> jungGraph, Dimension size, final int xOffset, final int yOffset) { FRLayout<VertexRef, EdgeRef> layout = new FRLayout<VertexRef, EdgeRef>(jungGraph); layout.setInitializer(initializer(graphLayout, xOffset, yOffset)); layout.setSize(size); while(!layout.done()) { layout.step(); } for(VertexRef v : jungGraph.getVertices()) { graphLayout.setLocation(v, new Point(layout.getX(v)+xOffset, layout.getY(v)+yOffset)); } }
private static VisualizationViewer<String, Edge> createVisualizationViewer( Graph<String, Edge> graph) { FRLayout<String, Edge> layout = new FRLayout<String, Edge>(graph, new Dimension(800, 600)); while (!layout.done()) layout.step();
@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))); } }
layout = new FRLayout<Number,Number>(g, d); layout.setSize(d); Relaxer relaxer = new VisRunner((IterativeContext)layout);
setBackground(Color.WHITE); final Layout<String,Number> layout = new FRLayout<String,Number>(mGraph); final VisualizationViewer<String,Number> vv = new VisualizationViewer<String,Number>(layout); vv.setBackground(Color.WHITE);
break; case FRLayout: layout = new FRLayout<N, EdgeWrapper<E>>(graph); break; case ISOMLayout:
break; case FRLayout: layout = new FRLayout<N, EdgeWrapper<E>>(graph); break; case ISOMLayout:
layout = new FRLayout<N, EdgeWrapper<E>>(graph); } else { layout = new ISOMLayout<N, EdgeWrapper<E>>(graph);
layout = new FRLayout<N, EdgeWrapper<E>>(graph); } else { layout = new ISOMLayout<N, EdgeWrapper<E>>(graph);