⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 btreenode.java

📁 一个可以以图形方式直观表示的树状二叉树算法程序,可以实现生成和遍历.
💻 JAVA
字号:
package binarytreetravel;import java.awt.Color;import java.awt.Rectangle;import java.util.Observable;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class BTreeNode extends Observable{  static final int RADIUS = 15;  //结点圆的直径  private String data;              //节点的存储内容  BTreeNode lchild;         //节点的左孩子  BTreeNode rchild;         //节点的右孩子  BTreeNode father;         //节点的父节点  Rectangle rect = new Rectangle();  public BTreeNode(String data) {    //新建一个结点必须改变视图    this.data = data;    this.father = null;    this.lchild = null;    this.rchild = null;  }  public BTreeNode(String data, BTreeNode lchild,                   BTreeNode rchild) {    this.data = data;    this.lchild = lchild;    this.rchild = rchild;  }  public BTreeNode(BTreeNode bn) {    this.data = bn.data;    this.lchild = bn.lchild;    this.rchild = bn.rchild;    this.father = bn.father;    this.rect = new Rectangle(bn.rect.x, bn.rect.y,                              bn.rect.width, bn.rect.height);  }  public void setData(String data) {    this.data = data;  }  public String getData() {    return this.data;  }  public void insertLChild(BTreeNode lchild) {    //插入左结点必须更新视图    lchild.father = this;    this.lchild = lchild;    setChanged();    notifyObservers();  }  public void insertRChild(BTreeNode rchild) {    //插入右结点必须更新视图    rchild.father = this;    this.rchild = rchild;    setChanged();    notifyObservers();  }  public void setBounds(Rectangle rect) {    this.rect = rect;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -