diff options
Diffstat (limited to 'NET/worlds/console/StatMan.java')
| -rw-r--r-- | NET/worlds/console/StatMan.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/NET/worlds/console/StatMan.java b/NET/worlds/console/StatMan.java new file mode 100644 index 0000000..f8567bc --- /dev/null +++ b/NET/worlds/console/StatMan.java @@ -0,0 +1,58 @@ +package NET.worlds.console; + +import java.awt.List; +import java.util.Vector; + +abstract class StatMan { + protected Vector<Object> _children; + protected List _grabbedList; + protected Tree _tree; + + void createList() { + this.updateList(); + } + + abstract void updateList(); + + void releaseList(boolean terminalCallback) { + this._grabbedList = null; + } + + void grabList(List list) { + assert this._grabbedList == null; + + this._grabbedList = list; + this._grabbedList.removeAll(); + this.createList(); + } + + void setTree(Tree tree) { + this._tree = tree; + if (this._children != null) { + for (int i = this._children.size() - 1; i >= 0; i--) { + StatMan child = (StatMan)this._children.elementAt(i); + child.setTree(this._tree); + } + } + } + + Vector<Object> getChildren() { + return this._children; + } + + void addChild(StatMan child) { + assert child != null; + + if (this._children == null) { + this._children = new Vector<Object>(); + } + + assert this._children.indexOf(child) == -1; + + this._children.addElement(child); + if (this._tree != null) { + child.setTree(this._tree); + this._tree.update(); + } + } +} |