KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > sqlprofiler > gui > AbstractChartModel


1 package org.jahia.sqlprofiler.gui;
2
3 import javax.swing.event.EventListenerList JavaDoc;
4
5 /**
6  * <p>Title: </p>
7  * <p>Description: </p>
8  * <p>Copyright: Copyright (c) 2003</p>
9  * <p>Company: Jahia Ltd</p>
10  * @author not attributable
11  * @version 1.0
12  */

13
14 public abstract class AbstractChartModel implements ChartModel {
15
16     protected EventListenerList JavaDoc listenerList = new EventListenerList JavaDoc();
17     ChartModelEvent chartModelEvent = null;
18
19     public void addChartModelListener(ChartModelListener l) {
20         listenerList.add(ChartModelListener.class, l);
21     }
22
23     public void removeChartModelListener(ChartModelListener l) {
24         listenerList.remove(ChartModelListener.class, l);
25     }
26
27     // Notify all listeners that have registered interest for
28
// notification on this event type. The event instance
29
// is lazily created using the parameters passed into
30
// the fire method.
31

32     protected void fireChartDataChanged() {
33
34         // Guaranteed to return a non-null array
35
Object JavaDoc[] listeners = listenerList.getListenerList();
36         // Process the listeners last to first, notifying
37
// those that are interested in this event
38
for (int i = listeners.length - 2; i >= 0; i -= 2) {
39             if (listeners[i] == ChartModelListener.class) {
40                 // Lazily create the event:
41
if (chartModelEvent == null)
42                     chartModelEvent = new ChartModelEvent(this);
43                 ( (ChartModelListener) listeners[i + 1]).chartDataChanged(chartModelEvent);
44             }
45         }
46
47
48     }
49 }
Popular Tags