1 package JSci.awt; 2 3 import javax.swing.event.EventListenerList ; 4 5 11 public abstract class AbstractGraphModel extends Object { 12 private final EventListenerList listenerList = new EventListenerList (); 13 private final GraphDataEvent dataChangedEvent = new GraphDataEvent(this); 14 15 18 protected final void fireGraphDataChanged() { 19 fireGraphChanged(dataChangedEvent); 20 } 21 24 protected final void fireGraphSeriesUpdated(int series) { 25 final GraphDataEvent event = new GraphDataEvent(this, series); 26 fireGraphChanged(event); 27 } 28 31 protected final void fireGraphChanged(GraphDataEvent event) { 32 final Object listeners[] = listenerList.getListenerList(); 33 for(int i=listeners.length-2; i>=0; i-=2) { 34 if(listeners[i] == GraphDataListener.class) 35 ((GraphDataListener)listeners[i+1]).dataChanged(event); 36 } 37 } 38 41 public final void addGraphDataListener(GraphDataListener l) { 42 listenerList.add(GraphDataListener.class, l); 43 } 44 47 public final void removeGraphDataListener(GraphDataListener l) { 48 listenerList.remove(GraphDataListener.class, l); 49 } 50 } 51 52 | Popular Tags |