Esempio n. 1
0
 public void trav(ArrayList nodes, node cur) {
   node temp;
   while (!nodes.isEmpty()) {
     temp = (node) nodes.get(0);
     if (temp.getLevel() - 1 == cur.getLevel()) {
       nodes.remove(0);
       cur.addChild(temp);
       trav(nodes, temp);
     } else {
       return;
     }
   }
 }
Esempio n. 2
0
  public void draw(node leaf, Graphics2D g, int px, int py) {
    int lvl = leaf.getLevel();
    double l = lvl;
    counts[lvl]++;

    double xfraq = counts[lvl] / (spacing[lvl] + 1);
    double yfraq = l / depth;
    int x = new Double(1600 * xfraq).intValue();
    int y = new Double(1200 * yfraq).intValue() + 10;

    if (leaf.getAttr() != null) {
      g.drawString(leaf.getAttr(), x - 20, y);
    }
    if (leaf.getCrit() != null) {
      g.drawString(leaf.getCrit(), x - 20, y + 10);
    }
    if (leaf.getResult() != null) {
      g.drawString(leaf.getResult(), x - 20, y + 10);
    }
    g.drawLine(x, y, px, py);
    // g.fillRect(x,y,20,20);
    ArrayList children = leaf.getChildren();
    while (!children.isEmpty()) {
      draw((node) children.remove(0), g, x, y);
    }
  }
Esempio n. 3
0
 public void levelCount(ArrayList nodes) {
   System.out.println("Doing level counts");
   spacing = new double[depth];
   for (int i = 0; i < depth; i++) {
     spacing[i] = 0;
   }
   spacing[0]++;
   node leaf;
   for (int i = 0; i < nodes.size(); i++) {
     leaf = (node) nodes.get(i);
     spacing[leaf.getLevel()]++;
   }
   max = 0;
   for (int i = 0; i < depth; i++) {
     if (spacing[i] > max) {
       max = spacing[i];
     }
     // System.out.println("Level "+i+" has "+spacing[i]+" nodes");
   }
 }