01: package org.jahia.sqlprofiler.gui;
02:
03: import javax.swing.event.EventListenerList;
04:
05: /**
06: * <p>Title: </p>
07: * <p>Description: </p>
08: * <p>Copyright: Copyright (c) 2003</p>
09: * <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 listenerList = new EventListenerList();
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[] 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])
44: .chartDataChanged(chartModelEvent);
45: }
46: }
47:
48: }
49: }
|