/* * Top Level is 0 */ public int getLevel() { int level = 0; TongrenTree parent = getParent(); while (parent != null) { level++; parent = parent.getParent(); } return level; }
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; }
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; }
public TongrenTree(String id, String name, TongrenTree parent) { mId = id; mName = name; mParent = parent; if (parent != null) { parent.addChild(this); } }