Ejemplo n.º 1
0
  /*
   * Top Level is 0
   */
  public int getLevel() {
    int level = 0;

    TongrenTree parent = getParent();
    while (parent != null) {
      level++;
      parent = parent.getParent();
    }
    return level;
  }
Ejemplo n.º 2
0
  private TongrenTree findAt(AtomicInteger p, boolean intoCollapsed) {
    if (p.get() == 0) return this;
    if (mChildren == null) return null;
    if (!intoCollapsed && isCollapsed()) return null;

    TongrenTree target = null;
    for (TongrenTree n : mChildren) {
      p.decrementAndGet();
      target = n.findAt(p, intoCollapsed);
      if (target != null) {
        break;
      }
    }
    return target;
  }
Ejemplo n.º 3
0
  public int getNodeCount(boolean intoCollapsed) {
    int count = 1;

    if (!intoCollapsed && isCollapsed()) {
      return count;
    }

    if (mChildren == null || mChildren.isEmpty()) {
      return count;
    }

    for (TongrenTree n : mChildren) {
      count += n.getNodeCount(intoCollapsed);
    }
    return count;
  }
Ejemplo n.º 4
0
 public TongrenTree(String id, String name, TongrenTree parent) {
   mId = id;
   mName = name;
   mParent = parent;
   if (parent != null) {
     parent.addChild(this);
   }
 }