summaryrefslogtreecommitdiff
path: root/NET/worlds/console/StatMan.java
blob: f8567bcffb58505ecac0244928c79f11a1cfe5e1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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();
      }
   }
}