home *** CD-ROM | disk | FTP | other *** search
- package sun.awt.image;
-
- import java.awt.Image;
- import java.awt.image.ImageObserver;
- import java.util.Enumeration;
- import java.util.NoSuchElementException;
- import java.util.Vector;
-
- public class ImageWatched {
- protected Vector watchers;
-
- public synchronized void addWatcher(ImageObserver iw) {
- if (iw != null && !this.isWatcher(iw)) {
- if (this.watchers == null) {
- this.watchers = new Vector();
- }
-
- this.watchers.addElement(iw);
- }
-
- }
-
- public synchronized boolean isWatcher(ImageObserver iw) {
- return this.watchers != null && iw != null && this.watchers.contains(iw);
- }
-
- public synchronized void removeWatcher(ImageObserver iw) {
- if (iw != null && this.watchers != null) {
- this.watchers.removeElement(iw);
- if (this.watchers.size() == 0) {
- this.watchers = null;
- }
- }
-
- }
-
- public void newInfo(Image img, int info, int x, int y, int w, int h) {
- if (this.watchers != null) {
- Enumeration enum = this.watchers.elements();
- Vector uninterested = null;
-
- while(enum.hasMoreElements()) {
- ImageObserver iw;
- try {
- iw = (ImageObserver)enum.nextElement();
- } catch (NoSuchElementException var10) {
- break;
- }
-
- if (!iw.imageUpdate(img, info, x, y, w, h)) {
- if (uninterested == null) {
- uninterested = new Vector();
- }
-
- uninterested.addElement(iw);
- }
- }
-
- if (uninterested != null) {
- enum = uninterested.elements();
-
- while(enum.hasMoreElements()) {
- ImageObserver iw = (ImageObserver)enum.nextElement();
- this.removeWatcher(iw);
- }
- }
- }
-
- }
- }
-