Jung Meets the NetBeans Platform

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

Comments:

There is now integration between Visual Library and Jung available: http://timboudreau.com/blog/NetBeans_Visual_Library_Meets_JUNG/read

Posted by Tim Boudreau on October 10, 2013 at 11:28 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today