summaryrefslogtreecommitdiff
path: root/NET/worlds/console/StatisticsWindow.java
blob: a206d6c59650cabd611af3bdc43ffb7a6f3f27de (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package NET.worlds.console;

import java.awt.Dimension;
import java.awt.Event;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.List;
import java.awt.Point;

public class StatisticsWindow extends Frame implements MainCallback, MainTerminalCallback, TreeCallback {
   private static final long serialVersionUID = 2184104724858956037L;
   Tree _tree = new Tree(this);
   List _list = new List(10, false);
   StatMan _lastStat;

   public StatisticsWindow(java.awt.Window parent) {
      super("Statistics Manager");
      GridBagLayout gbag = new GridBagLayout();
      this.setLayout(gbag);
      GridBagConstraints c = new GridBagConstraints();
      c.fill = 1;
      c.weightx = 0.4;
      c.weighty = 1.0;
      c.gridwidth = 1;
      c.gridheight = 0;
      gbag.setConstraints(this._tree, c);
      this.add(this._tree);
      c.weightx = 0.6;
      c.gridwidth = 0;
      gbag.setConstraints(this._list, c);
      this.add(this._list);
      this.pack();
      Point loc = parent.location();
      Dimension size = parent.getSize();
      this.reshape(loc.x + (size.width - 512) / 2, loc.y + (size.height - 240) / 2, 512, 240);
      this.show();
      StatisticsRoot root = StatisticsRoot.getNode();
      root.setTree(this._tree);
      StatTreeNode rootNode = new StatTreeNode(root, null);
      this._tree.change(rootNode, rootNode.getObject());
      StatMemNode.getNode();
      StatNetRefNode.getNode();
      this._tree.change(rootNode, StatRateNode.getNode());
      Main.register(this);
   }

   @Override
   public boolean handleEvent(Event ev) {
      switch (ev.id) {
         case 201:
            if (this._lastStat != null) {
               this._lastStat.releaseList(false);
            }

            this._lastStat = null;
            this.dispose();
            return true;
         default:
            return super.handleEvent(ev);
      }
   }

   @Override
   public void treeChange(Object obj) {
      if (this._lastStat != null) {
         this._lastStat.releaseList(false);
      }

      this._lastStat = (StatMan)obj;
      this._lastStat.grabList(this._list);
   }

   @Override
   public void treeFocusChanged(boolean hasFocus) {
   }

   @Override
   public void mainCallback() {
   }

   @Override
   public void terminalCallback() {
      if (this._lastStat != null) {
         this._lastStat.releaseList(true);
      }

      this._lastStat = null;
      Main.unregister(this);
   }
}