EMMA Coverage Report (generated Mon Mar 20 21:34:30 PST 2006)
[all classes][com.moesol.util]

COVERAGE SUMMARY FOR SOURCE FILE [SystemStatsDialog.java]

nameclass, %method, %block, %line, %
SystemStatsDialog.java0%   (0/5)0%   (0/22)0%   (0/420)0%   (0/103)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SystemStatsDialog0%   (0/1)0%   (0/11)0%   (0/368)0%   (0/85)
SystemStatsDialog (): void 0%   (0/1)0%   (0/108)0%   (0/21)
connectGcButton (Container): void 0%   (0/1)0%   (0/22)0%   (0/7)
connectUi (): void 0%   (0/1)0%   (0/18)0%   (0/5)
connectUi (Container): void 0%   (0/1)0%   (0/47)0%   (0/9)
connectUiPair (Container, JComponent, JComponent): void 0%   (0/1)0%   (0/32)0%   (0/9)
main (String []): void 0%   (0/1)0%   (0/8)0%   (0/3)
onGcPushed (): void 0%   (0/1)0%   (0/5)0%   (0/3)
onHidden (): void 0%   (0/1)0%   (0/7)0%   (0/3)
onResized (): void 0%   (0/1)0%   (0/37)0%   (0/11)
onShown (): void 0%   (0/1)0%   (0/9)0%   (0/4)
onUpdateUi (): void 0%   (0/1)0%   (0/75)0%   (0/10)
     
class SystemStatsDialog$10%   (0/1)0%   (0/2)0%   (0/10)0%   (0/3)
SystemStatsDialog$1 (SystemStatsDialog): void 0%   (0/1)0%   (0/6)0%   (0/1)
actionPerformed (ActionEvent): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class SystemStatsDialog$20%   (0/1)0%   (0/4)0%   (0/18)0%   (0/7)
SystemStatsDialog$2 (SystemStatsDialog): void 0%   (0/1)0%   (0/6)0%   (0/1)
componentHidden (ComponentEvent): void 0%   (0/1)0%   (0/4)0%   (0/2)
componentResized (ComponentEvent): void 0%   (0/1)0%   (0/4)0%   (0/2)
componentShown (ComponentEvent): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class SystemStatsDialog$30%   (0/1)0%   (0/3)0%   (0/14)0%   (0/5)
SystemStatsDialog$3 (SystemStatsDialog): void 0%   (0/1)0%   (0/6)0%   (0/1)
windowDeiconified (WindowEvent): void 0%   (0/1)0%   (0/4)0%   (0/2)
windowIconified (WindowEvent): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class SystemStatsDialog$40%   (0/1)0%   (0/2)0%   (0/10)0%   (0/3)
SystemStatsDialog$4 (SystemStatsDialog): void 0%   (0/1)0%   (0/6)0%   (0/1)
actionPerformed (ActionEvent): void 0%   (0/1)0%   (0/4)0%   (0/2)

1/*
2 * $Id: SystemStatsDialog.java,v 1.3 2005/12/03 07:52:34 hastings Exp $
3 *
4 * (c) Copyright, Moebius Solutions, Inc., 2004
5 *
6 *                       All Rights Reserved
7 *
8 * This material may be reproduced by or for the U. S. Government
9 * pursuant to the copyright license under the clause at
10 * DFARS 252.227-7014 (OCT 2001).
11 */
12 
13package com.moesol.util;
14 
15import java.awt.Container;
16import java.awt.Dimension;
17import java.awt.GridBagConstraints;
18import java.awt.GridBagLayout;
19import java.awt.event.ActionEvent;
20import java.awt.event.ActionListener;
21import java.awt.event.ComponentAdapter;
22import java.awt.event.ComponentEvent;
23import java.awt.event.WindowAdapter;
24import java.awt.event.WindowEvent;
25 
26import javax.swing.JButton;
27import javax.swing.JComponent;
28import javax.swing.JFrame;
29import javax.swing.JLabel;
30 
31import com.moesol.bindings.platform_sdk.component_services.COM;
32 
33 
34/**
35 * @author robert
36 */
37public class SystemStatsDialog extends JFrame {
38        public SystemStatsDialog() {
39                setTitle("System Stats");
40                connectUi();
41                pack();
42                m_min_size = getSize();
43        }
44        public void connectUi() {
45                connectUi(getContentPane());
46                addComponentListener(m_component_listener);
47                addWindowListener(m_window_listener);
48                m_gc_button.addActionListener(m_gc_action);
49        }
50        private void connectUi(Container pane) {
51                setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
52                pane.setLayout(new GridBagLayout());
53                
54                connectUiPair(pane, m_coheap_label, m_coheap_value);
55                connectUiPair(pane, m_iunks_label, m_iunks_value);
56                connectUiPair(pane, m_heap_label, m_heap_value);
57                connectUiPair(pane, m_total_label, m_total_value);
58                connectUiPair(pane, m_free_label, m_free_value);
59                connectGcButton(pane);
60        }
61        private void connectUiPair(Container pane, JComponent label, JComponent value) {
62                GridBagConstraints c = new GridBagConstraints();
63 
64                c.weightx = 1.0;
65                c.anchor = GridBagConstraints.LINE_END;
66                pane.add(label, c);
67                
68                c.gridwidth = GridBagConstraints.REMAINDER;
69                c.anchor = GridBagConstraints.LINE_START;
70                value.setMinimumSize(new Dimension(100,100));
71                pane.add(value, c);
72                
73        }
74        private void connectGcButton(Container pane) {
75                GridBagConstraints c = new GridBagConstraints();
76                c.weightx = 1.0;
77                c.gridx = 1;
78                c.gridwidth = GridBagConstraints.REMAINDER;
79                c.anchor = GridBagConstraints.LINE_START;
80                
81                pane.add(m_gc_button, c);
82        }
83    public void onUpdateUi() {
84                System.out.println("onUpdateUi");
85        long total_memory = Runtime.getRuntime().totalMemory();
86        long free_memory = Runtime.getRuntime().freeMemory();
87        long heap_memory = total_memory - free_memory;
88        
89        m_coheap_value.setText(
90            com.moesol.bindings.platform_sdk.component_services.MallocSpy.getAllocatedBytes() + " bytes");
91        m_iunks_value.setText(
92            COM.getUnreleasedCount() + " inst");
93        m_heap_value.setText((heap_memory / (1024 * 1024)) + " M");
94        m_total_value.setText((total_memory / (1024 * 1024)) + "M");
95        m_free_value.setText((free_memory / (1024 * 1024)) + "M");
96    }
97    public void onHidden() {
98            System.out.println("onHidden");
99            m_update_ui.stop();
100    }
101    public void onShown() {
102                System.out.println("onShown");
103                onUpdateUi();
104            m_update_ui.start();
105    }
106    public void onResized() {
107            boolean need_set_size = false;
108            Dimension size = getSize();
109            if (size.width < m_min_size.width) {
110                    size.width = m_min_size.width;
111                        need_set_size = true;
112            }
113            if (size.height < m_min_size.height) {
114                    size.height = m_min_size.height;
115                        need_set_size = true;
116            }
117            if (need_set_size) {
118                        setSize(size);
119            }
120    }
121    public void onGcPushed() {
122            System.out.println("gc");
123            System.gc();
124    }
125    
126        public static void main(String[] args) {
127                SystemStatsDialog frame = new SystemStatsDialog();
128                frame.setVisible(true);
129        }
130 
131        private JLabel m_coheap_label = new JLabel("coheap: ");
132        private JLabel m_coheap_value = new JLabel("000000");
133        private JLabel m_iunks_label = new JLabel("iunks: ");
134        private JLabel m_iunks_value = new JLabel("000000");
135        private JLabel m_heap_label = new JLabel("heap: ");
136        private JLabel m_heap_value = new JLabel("000000");
137        private JLabel m_total_label = new JLabel("total: ");
138        private JLabel m_total_value = new JLabel("000000");
139        private JLabel m_free_label = new JLabel("free: ");
140        private JLabel m_free_value = new JLabel("000000");
141        private JButton m_gc_button = new JButton("GC");
142        private Dimension m_min_size;
143 
144    private javax.swing.Timer m_update_ui =
145        new javax.swing.Timer(1000, new ActionListener() {
146        public void actionPerformed(ActionEvent e) {
147            onUpdateUi();
148        }
149    });
150    private ComponentAdapter m_component_listener = new ComponentAdapter() {
151        public void componentResized(ComponentEvent e) {
152                onResized();
153        }
154        public void componentShown(ComponentEvent e) {
155                onShown();
156        }
157        public void componentHidden(ComponentEvent e) {
158                onHidden();
159        }
160    };
161    private WindowAdapter m_window_listener = new WindowAdapter() {
162                public void windowDeiconified(WindowEvent e) {
163                        onShown(); 
164                }
165                 public void windowIconified(WindowEvent e) {
166                        onHidden(); 
167                }
168    };
169    private ActionListener m_gc_action = new ActionListener() {
170            public void actionPerformed(ActionEvent e) {
171                    onGcPushed();
172            }
173    };
174}

[all classes][com.moesol.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov