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

📄 treenode.java

📁 toocom源代码,主要应用在本体匹配方面!
💻 JAVA
字号:
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 

⌨️ 快捷键说明

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