This GraphLayout implementation uses the
abego TreeLayout library to create a
more compact tree layout than provided by the standard
GraphLayout
code.
E.g.
Comparison abego TreeLayout and NetBeans GraphLayout
| AbegoTreeLayoutForNetbeans |
Default NetBeans Layout |
 |
 |
Usage
Assume you already have added the tree elements (nodes and edges) to a
GraphScene
scene and the root node is stored in
root. Then
you may use code similar to the following to layout the tree and display it
in a dialog:
// layout the tree
AbegoTreeLayoutForNetbeans graphLayout = new AbegoTreeLayoutForNetbeans(root,
100, 100, 50, 50, true);
SceneLayout sceneLayout = LayoutFactory.createSceneGraphLayout(scene,
graphLayout);
sceneLayout.invokeLayoutImmediately();
// display the tree in a dialog
JScrollPane panel = new JScrollPane(scene.createView());
JDialog dialog = new JDialog();
dialog.setModal(true);
dialog.setTitle(title);
dialog.add(panel, BorderLayout.CENTER);
dialog.setSize(800, 600);
dialog.setVisible(true);
dialog.dispose();
Documentation
For details, especially on the Configuration parameter, see the abego
TreeLayout documentation.
Examples
In the "demo" package you will find an example using the
AbegoTreeLayoutForNetbeans.