KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > admin > dso > CacheActivityPanel


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.admin.dso;
5
6 import org.jfree.chart.JFreeChart;
7 import org.jfree.data.time.TimeSeries;
8
9 import com.tc.admin.AdminClient;
10 import com.tc.admin.AdminClientContext;
11 import com.tc.admin.ConnectionContext;
12 import com.tc.admin.common.DemoChartFactory;
13 import com.tc.admin.common.MultiStatisticPanel;
14 import com.tc.admin.common.Poller;
15 import com.tc.admin.common.XContainer;
16
17 import java.awt.BorderLayout JavaDoc;
18
19 import javax.management.ObjectName JavaDoc;
20
21 public class CacheActivityPanel extends XContainer implements Poller {
22   private MultiStatisticPanel m_panel;
23
24   public CacheActivityPanel(ConnectionContext cc, ObjectName JavaDoc bean, int orientation) {
25     super(new BorderLayout JavaDoc());
26
27     AdminClientContext acc = AdminClient.getContext();
28
29     String JavaDoc[] stats = {
30       "ObjectFlushRate",
31       "ObjectFaultRate",
32     };
33
34     String JavaDoc[] names = {
35       acc.getMessage("dso.object.flush.rate"),
36       acc.getMessage("dso.object.fault.rate")
37     };
38
39     String JavaDoc header = acc.getMessage("dso.cache.activity");
40     String JavaDoc xAxis = null;
41     String JavaDoc yAxis = acc.getMessage("dso.cache.rate.range.label");
42     
43     m_panel = new MultiStatisticPanel(cc, bean, stats, names, header, xAxis, yAxis, orientation) {
44       public JFreeChart createChart(TimeSeries series) {
45         return DemoChartFactory.getXYLineChart("", "", "", series);
46       }
47     };
48     add(m_panel);
49   }
50
51   public boolean isRunning() {
52     return m_panel != null && m_panel.isRunning();
53   }
54   
55   public void stop() {
56     if(isRunning())
57       m_panel.stop();
58   }
59
60   public void start() {
61     if(!isRunning())
62       m_panel.start();
63   }
64   
65   public void tearDown() {
66     if(isRunning())
67       m_panel.stop();
68
69     super.tearDown();
70     m_panel = null;
71   }
72 }
73
Popular Tags