java 画树_java – 如何绘制代表连接节点图的树?
我想在Java GUI中顯示樹(shù),但我不知道如何.樹(shù)代表連接節(jié)點(diǎn)的圖形,如下所示:
我應(yīng)該說(shuō)我有自己的樹(shù)類:
public class BinaryTree
{
private BinaryNode root;
public BinaryTree( )
{
root = null;
}
public BinaryTree( Object rootItem )
{
root = new BinaryNode( rootItem, null, null );
}
public BinaryTree( Object rootItem,BinaryNode a,BinaryNode b )
{
root = new BinaryNode( rootItem, a, b );
}
public int leavesCount(){
return BinaryNode.leavesCount(root);
}
public boolean equal(BinaryTree a,BinaryTree b){
return BinaryNode.equal(a.root, b.root);
}
public void printPreOrder( )
{
if( root != null )
root.printPreOrder( );
}
public void printInOrder( )
{
if( root != null )
root.printInOrder( );
}
public void printPostOrder( )
{
if( root != null )
root.printPostOrder( );
}
public void makeEmpty( )
{
root = null;
}
public boolean isEmpty( )
{
return root == null;
}
public void merge( Object rootItem, BinaryTree t1, BinaryTree t2 ) throws MergeAbrot
{
if( t1.root == t2.root && t1.root != null )
{
throw new MergeAbrot("MergeAbrot");
}
root=new BinaryNode( rootItem, t1.root, t2.root );
if( this != t1 )
t1.root = null;
if( this != t2 )
t2.root = null;
}
public int size( )
{
return BinaryNode.size( root );
}
public int height( )
{
return BinaryNode.height( root );
}
}
我只想畫樹(shù).我應(yīng)該怎么做?
總結(jié)
以上是生活随笔為你收集整理的java 画树_java – 如何绘制代表连接节点图的树?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 40吨重的砼柱子高30m用多大的汽车吊
- 下一篇: Python二级笔记(10)