晚上好,我就如何使用 Library Jung2 Java创建一些图表制作动态图例提出建议。
每个图表我都意识到程序是不同的,具有节点,边缘和独特的功能。
提前感谢您的帮助。
UndirectedGraph graphStruct = new UndirectedSparseMultigraph();
Hashtable<String, NodeData> nodeCollection = new Hashtable<String, NodeData>();
Hashtable<String, EdgeData> edgeCollection = new Hashtable<String, EdgeData>();
...
...
...
edgeCollection.put(""+edge, new EdgeClass(edge, "Id+"+edge));
...
...
...
VisualizationViewer<String, String> vv = new VisualizationViewer<String, String>(new FRLayout<String, String>(graphStruct));
vv.getRenderContext().setVertexFillPaintTransformer(new VertexColor(nodeCollection));
vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<String>());
vv.getRenderContext().setVertexLabelTransformer(new NodeId(nodeCollection));
JLabel label = new JLabel();
label.setOpaque(true);
label.setText("Graph");
vv.add(label);
PluggableGraphMouse inter = new PluggableGraphMouse();
inter.add(new TranslatingGraphMousePlugin(MouseEvent.BUTTON3_MASK));
inter.add(new PickingGraphMousePlugin());
inter.add(new ScalingGraphMousePlugin(new CrossoverScalingControl(), 0, 2 / 1.2f, 1.2f));
vv.setGraphMouse(inter);
vv.setPreferredSize(new Dimension(1600,1000));
vv.setLocation(500, 500);
vv.setGraphLayout(new CircleLayout(graphStruct));
final JFrame frame = new JFrame();
frame.setTitle("Graph Rappresentation");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(vv);
frame.pack();
frame.setVisible(true);