?? treenode.java
字號(hào):
package toocom.graphdrawing;
import java.util.LinkedList;
import java.awt.Graphics;
import java.awt.Dimension;
import javax.swing.tree.DefaultTreeModel;
import toocom.ocgl.ConceptualPrimitive;
import toocom.ocgl.ConceptType;
import toocom.ocgl.RelationType;
import toocom.ocgl.Language;
/**
* This class contains the tree structure to display.
*
* @author Stefan Petrik,Matthieu
* @version 23/12/2003
*/
public class TreeNode extends javax.swing.tree.DefaultMutableTreeNode{
private Graphics g;
private Language lang;
private boolean isALeaf = false;
private Dimension BoxSize;
//Les variables suivantes sont utilis閑s par l'algorthme de WALKER
protected int ordonnee;
protected double prelim;
protected double mod;
protected double shift;
protected double change;
protected TreeNode thread;
protected TreeNode ancestor;
public TreeNode(final Object userObject, Graphics g, Language lang){
super(userObject);
this.g = g;
this.lang = lang;
if (userObject instanceof ConceptType){
this.BoxSize = ((((ConceptType)userObject).getBounds(g, lang)).getBounds()).getSize();
}
else if (userObject instanceof RelationType){
this.BoxSize = ((((RelationType)userObject).getBounds(g, lang)).getBounds()).getSize();
}
//Initialise valeurs pour WALKER
mod = 0;
thread = null;
ancestor = this;
//Initialise l'ordonn閑
ordonnee = 0;
}
public Dimension getBoxSize(){
return BoxSize;
}
public boolean isALeaf(){
return isALeaf;
}
public synchronized void explore(final DefaultTreeModel model){
// Perform a breadth-first search:
//
// Idea: construct the tree with the help of a linked list
//
// Impl: start at the root, append immediate children at the end of the list
// remove first list item
// repeat until the list is empty (= all nodes are visited)
//
// Perf: linear O(n)
TreeNode n;//noeud courant
LinkedList leaves = new LinkedList();//liste des noeuds
//commence par ins閞er le noeud racine dans la liste
leaves.add(this);
do {
//prend le premier 閘閙ent de la liste
n = (TreeNode)leaves.getFirst();
//prend la liste des enfants du noeud courant
ConceptualPrimitive cp = (ConceptualPrimitive)n.getUserObject();
final Object[] children = (cp.getChildren()).toArray();
if (children.length > 0) {
//pour chaque enfant, construit un nouveau noeud, l'ajoute
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -