0

Good evening, I ask for advice on how to make a dynamic legend for creating some graphs using the Library Jung2 Java.

Each graph I realized that the program is different and has nodes, edges and unique features.

Thank you in advance for your help.

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);
Alfader
  • 11
  • 2
  • What did you mean by dynamic legend? Is your question similar to [mine](http://stackoverflow.com/questions/26013733/jung-add-legends-to-the-frame) ? – 2c00L Oct 30 '14 at 21:11
  • hello, thanks for your interest. Practically I need to generate a series of graphs, each one with its legend containing the parameters passed by the single analysis, not an image. – Alfader Oct 30 '14 at 21:57
  • Hmm. Interesting. I do something similar. I run an optimization problem multiple times. For each simulation run I generate 3 different graphs. Each graph has its own legend. I created the legends in a JPanel with the paintComponent() method. Afterwards I stick it into the Virtualization Viewer. Then I exported those graphs to a PDF. I avoided the images as legends since they degrade the picture quality. – 2c00L Oct 30 '14 at 22:12

0 Answers0