Here's a small Jung diagram in a NetBeans Platform application:
And the code, copied directly from the Jung 2.0 Tutorial:
public final class JungTopComponent extends TopComponent {
public JungTopComponent() {
initComponents();
setName(Bundle.CTL_JungTopComponent());
setToolTipText(Bundle.HINT_JungTopComponent());
setLayout(new BorderLayout());
Graph sgv = getGraph();
Layout<Integer, String> layout = new CircleLayout(sgv);
layout.setSize(new Dimension(300, 300));
BasicVisualizationServer<Integer, String> vv =
new BasicVisualizationServer<Integer, String>(layout);
vv.setPreferredSize(new Dimension(350, 350));
add(vv, BorderLayout.CENTER);
}
public Graph getGraph() {
Graph<Integer, String> g = new SparseMultigraph<Integer, String>();
g.addVertex((Integer) 1);
g.addVertex((Integer) 2);
g.addVertex((Integer) 3);
g.addEdge("Edge-A", 1, 2);
g.addEdge("Edge-B", 2, 3);
Graph<Integer, String> g2 = new SparseMultigraph<Integer, String>();
g2.addVertex((Integer) 1);
g2.addVertex((Integer) 2);
g2.addVertex((Integer) 3);
g2.addEdge("Edge-A", 1, 3);
g2.addEdge("Edge-B", 2, 3, EdgeType.DIRECTED);
g2.addEdge("Edge-C", 3, 2, EdgeType.DIRECTED);
g2.addEdge("Edge-P", 2, 3);
return g;
}
And here's what someone who attended a NetBeans Platform training course in Poland has done with Jung and the NetBeans Platform:
The source code for the above is on Git: git://gitorious.org/j2t/j2t.git