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); } }