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);
}
