Help converting Swing applet to Vaadin

Hello again everyone,

I’m stuck on this problem and hopefully someone can shed some light. I’ve looked over the forums and the AppletIntegration code, but I can’t immediately see how it applies to this situation.

I have some working code example that creates an applet and shows the applet in a JFrame, and I want to implement this functionality into our Vaadin application. Basically, the applet takes a tree structure, builds a JUNG graph with interactivity, and adds that graph’s visualization to a JFrame. The applet is not packaged as a jar, but rather implemented as an inner class.

Can someone point me in the right direction on how this might be implemented in Vaadin? I’ve included some code to show you how the JFrame is created to kick start some discussion and included an example image of what is produced by the code.

Thanks for your help!
Chris

...
    TreeApplet applet = new TreeApplet(rdpNodes);
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = frame.getContentPane();
    content.add(applet);
    frame.pack();
    frame.setVisible(true);
}

private class TreeApplet extends JApplet {

    private TreeApplet(ArrayList<RdpEntry> rdpNodes) {
        Forest<RdpEntry, Integer> graph = new DelegateForest<RdpEntry, Integer>();
        int i = 0;
        for (RdpEntry r : rdpNodes) {
            if (r.hasChildren()) {
                graph.addVertex(r);
                for (RdpEntry child : r.getChildren()) {
                    graph.addEdge(i, r, child);
                    i++;
                }
            }
        }
        RadialTreeLayout<RdpEntry, Integer> radialLayout = new RadialTreeLayout<RdpEntry, Integer>(graph);
        radialLayout.setSize(new Dimension(800, 800));
        VisualizationViewer<RdpEntry, Integer> vv = new VisualizationViewer<RdpEntry, Integer>(radialLayout, new Dimension(800, 800));
        RadialTreeRings rings = new RadialTreeRings(graph, radialLayout, vv);
        vv.addPreRenderPaintable(rings);
        vv.setBackground(Color.white);
        vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
        vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<RdpEntry>());
        vv.setVertexToolTipTransformer(new ToStringLabeller());
        vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
        vv.setGraphMouse(new DefaultModalGraphMouse());
        GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
        Container content = getContentPane();
        content.add(panel);
}    

11381.png

If you want it to be interactive, it would require an awful lot of work, unless you find a suitable GWT library.
If it doesn’t have to be interactive, the easiest way will be to render images using JUNG and display them using Embedded component.

Thanks Michal. Unfortunately, as you can see from the example image, they can be sort of unwieldy and large and almost requires the ability, given by the applet, to zoom and navigate. I’ll look around for another way to do this, but it would be a huge bummer if this was impossible.

Take a look at these gwt libraries:
http://code.google.com/p/gwt-graph/
http://code.google.com/p/gwt-jsviz/

They are both wrappers around javascript graph visualisation frameworks
Examples for first one look promising: http://thejit.org/demos/
Wrapper projects are very young, but you may try to evolve it and create comprehensive vaadin component.

Also, you could use processingJS (http://vaadin.com/directory#addon/processingjs)
Processing is very powerfull tool for visualisations, but i don’t know of any existing graph framework for it.


These demos
really look amazing. I hope someone would create a Vaadin wrapper for these :)

If I ever want to finish my PhD, I’d probably not have time to do this myself. Would a good starting point be
here
?