Пример #1
0
  /*
   * Top Level is 0
   */
  public int getLevel() {
    int level = 0;

    TongrenTree parent = getParent();
    while (parent != null) {
      level++;
      parent = parent.getParent();
    }
    return level;
  }
Пример #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;
  }
Пример #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;
  }
Пример #4
0
 public TongrenTree(String id, String name, TongrenTree parent) {
   mId = id;
   mName = name;
   mParent = parent;
   if (parent != null) {
     parent.addChild(this);
   }
 }