< prev index next >

src/java.desktop/share/classes/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java

Print this page




 120     public static final void removeListener(AccelDeviceEventListener l) {
 121         getInstance(true).remove(l);
 122     }
 123 
 124     private final void add(AccelDeviceEventListener theListener, int screen) {
 125         listeners.put(theListener, screen);
 126     }
 127     private final void remove(AccelDeviceEventListener theListener) {
 128         listeners.remove(theListener);
 129     }
 130 
 131     /**
 132      * Notifies the listeners associated with the screen's device about the
 133      * event.
 134      *
 135      * Implementation note: the current list of listeners is first duplicated
 136      * which allows the listeners to remove themselves during the iteration.
 137      *
 138      * @param screen a screen number with which the device which is a source of
 139      * the event is associated with
 140      * @param eventType a type of the event
 141      * @see #DEVICE_DISPOSED
 142      * @see #DEVICE_RESET
 143      */
 144     private final void notifyListeners(int deviceEventType, int screen) {
 145         HashMap<AccelDeviceEventListener, Integer> listClone;
 146         Set<AccelDeviceEventListener> cloneSet;
 147 
 148         synchronized(listeners) {
 149             listClone =
 150                 new HashMap<AccelDeviceEventListener, Integer>(listeners);
 151         }
 152 
 153         cloneSet = listClone.keySet();
 154         Iterator<AccelDeviceEventListener> itr = cloneSet.iterator();
 155         while (itr.hasNext()) {
 156             AccelDeviceEventListener current = itr.next();
 157             Integer i = listClone.get(current);
 158             // only notify listeners which are interested in this device
 159             if (i != null && i.intValue() != screen) {
 160                 continue;


 120     public static final void removeListener(AccelDeviceEventListener l) {
 121         getInstance(true).remove(l);
 122     }
 123 
 124     private final void add(AccelDeviceEventListener theListener, int screen) {
 125         listeners.put(theListener, screen);
 126     }
 127     private final void remove(AccelDeviceEventListener theListener) {
 128         listeners.remove(theListener);
 129     }
 130 
 131     /**
 132      * Notifies the listeners associated with the screen's device about the
 133      * event.
 134      *
 135      * Implementation note: the current list of listeners is first duplicated
 136      * which allows the listeners to remove themselves during the iteration.
 137      *
 138      * @param screen a screen number with which the device which is a source of
 139      * the event is associated with
 140      * @param deviceEventType a type of the event
 141      * @see #DEVICE_DISPOSED
 142      * @see #DEVICE_RESET
 143      */
 144     private final void notifyListeners(int deviceEventType, int screen) {
 145         HashMap<AccelDeviceEventListener, Integer> listClone;
 146         Set<AccelDeviceEventListener> cloneSet;
 147 
 148         synchronized(listeners) {
 149             listClone =
 150                 new HashMap<AccelDeviceEventListener, Integer>(listeners);
 151         }
 152 
 153         cloneSet = listClone.keySet();
 154         Iterator<AccelDeviceEventListener> itr = cloneSet.iterator();
 155         while (itr.hasNext()) {
 156             AccelDeviceEventListener current = itr.next();
 157             Integer i = listClone.get(current);
 158             // only notify listeners which are interested in this device
 159             if (i != null && i.intValue() != screen) {
 160                 continue;
< prev index next >