I have been working on a displaying AVL Tree operations graphically using JUNG2 (without any animations)
I am using OrderedKAryTree
for the same. But there is some problem with the rendering. All the edges appear from root to the upper left corner of the frame. As shown in this
screenshot
Here's my visualizer code
vv = new VisualizationViewer<Integer, Integer>(
new TreeLayout<Integer, Integer>(graph),
new Dimension(500, 400));
vv.setBackground(Color.white);
vv.getRenderContext().setEdgeShapeTransformer(
new EdgeShape.Line<Integer, Integer>());
vv.getRenderContext().setVertexLabelTransformer(
new ToStringLabeller<Integer>());
frame.getContentPane().add(vv, BorderLayout.CENTER);
frame.getContentPane().validate();
I have not been able to figure out why this is happening. Also, the same code works perfectly if I use DelegateTree
although the ordering is not achieved.
Please help. Thanks in advance!
Found out the solution. Instead of using
OrderedKAryTree
useDelegateTree
withDirectedOrderedSparceGraph
Here is how the graph should be initialized:
V and E can be any
Object
.This does not solve the problem of
OrderedKAryTree
getting rendered incorrectly but it can surely help you display a binary search tree.