I have a jung tree displayed in a JPanel. The constructor of my tree looks like this:
Forest<String, Integer> graph = new DelegateForest<String, Integer>();
static GraphZoomScrollPane panel = null;
static DefaultModalGraphMouse graphMouse = null;
static JComboBox modeBox = null;
static ScalingControl scaler;
public PanelTree(List<Cluster> clist) {
setBounds(215, 10, 550, 550);
updateData(clist); // adds vertex and edges to graph
treeLayout = new TreeLayout<String, Integer>(graph);
vv = new VisualizationViewer<String, Integer>(treeLayout, new Dimension(500, 500));
vv.setBackground(Color.white);
vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
// add a listener for ToolTips
vv.setVertexToolTipTransformer(new ToStringLabeller());
vv.getRenderContext()
.setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
panel = new GraphZoomScrollPane(vv);
add(panel);
graphMouse = new DefaultModalGraphMouse();
vv.setGraphMouse(graphMouse);
modeBox = graphMouse.getModeComboBox();
modeBox.addItemListener(graphMouse.getModeListener());
graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
scaler = new CrossoverScalingControl();
}
But the tree is quite large. So I want to know is there is a way to either automatically zoom out so the tree fits in the windows, and otherwise just set a default zoom that is less than the default one. How can I do that ?