src/share/classes/sun/awt/image/ToolkitImage.java

Print this page
rev 9830 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by: darcy, prr


  62 
  63     /**
  64      * Construct an image from an ImageProducer object.
  65      */
  66     public ToolkitImage(ImageProducer is) {
  67         source = is;
  68         if (is instanceof InputStreamImageSource) {
  69             src = (InputStreamImageSource) is;
  70         }
  71     }
  72 
  73     public ImageProducer getSource() {
  74         if (src != null) {
  75             src.checkSecurity(null, false);
  76         }
  77         return source;
  78     }
  79 
  80     private int width = -1;
  81     private int height = -1;
  82     private Hashtable properties;
  83 
  84     private int availinfo;
  85 
  86     /**
  87      * Return the width of the original image source.
  88      * If the width isn't known, then the image is reconstructed.
  89      */
  90     public int getWidth() {
  91         if (src != null) {
  92             src.checkSecurity(null, false);
  93         }
  94         if ((availinfo & ImageObserver.WIDTH) == 0) {
  95             reconstruct(ImageObserver.WIDTH);
  96         }
  97         return width;
  98     }
  99 
 100     /**
 101      * Return the width of the original image source.
 102      * If the width isn't known, then the ImageObserver object will be


 237                     return;
 238                 }
 239                 if ((availinfo & ImageObserver.ERROR) != 0) {
 240                     return;
 241                 }
 242             }
 243         }
 244     }
 245 
 246     synchronized void addInfo(int newinfo) {
 247         availinfo |= newinfo;
 248         notifyAll();
 249     }
 250 
 251     void setDimensions(int w, int h) {
 252         width = w;
 253         height = h;
 254         addInfo(ImageObserver.WIDTH | ImageObserver.HEIGHT);
 255     }
 256 
 257     void setProperties(Hashtable props) {
 258         if (props == null) {
 259             props = new Hashtable();
 260         }
 261         properties = props;
 262         addInfo(ImageObserver.PROPERTIES);
 263     }
 264 
 265     synchronized void infoDone(int status) {
 266         if (status == ImageConsumer.IMAGEERROR ||
 267             ((~availinfo) & (ImageObserver.WIDTH |
 268                              ImageObserver.HEIGHT)) != 0) {
 269             addInfo(ImageObserver.ERROR);
 270         } else if ((availinfo & ImageObserver.PROPERTIES) == 0) {
 271             setProperties(null);
 272         }
 273     }
 274 
 275     public void flush() {
 276         if (src != null) {
 277             src.checkSecurity(null, false);
 278         }
 279 




  62 
  63     /**
  64      * Construct an image from an ImageProducer object.
  65      */
  66     public ToolkitImage(ImageProducer is) {
  67         source = is;
  68         if (is instanceof InputStreamImageSource) {
  69             src = (InputStreamImageSource) is;
  70         }
  71     }
  72 
  73     public ImageProducer getSource() {
  74         if (src != null) {
  75             src.checkSecurity(null, false);
  76         }
  77         return source;
  78     }
  79 
  80     private int width = -1;
  81     private int height = -1;
  82     private Hashtable<?, ?> properties;
  83 
  84     private int availinfo;
  85 
  86     /**
  87      * Return the width of the original image source.
  88      * If the width isn't known, then the image is reconstructed.
  89      */
  90     public int getWidth() {
  91         if (src != null) {
  92             src.checkSecurity(null, false);
  93         }
  94         if ((availinfo & ImageObserver.WIDTH) == 0) {
  95             reconstruct(ImageObserver.WIDTH);
  96         }
  97         return width;
  98     }
  99 
 100     /**
 101      * Return the width of the original image source.
 102      * If the width isn't known, then the ImageObserver object will be


 237                     return;
 238                 }
 239                 if ((availinfo & ImageObserver.ERROR) != 0) {
 240                     return;
 241                 }
 242             }
 243         }
 244     }
 245 
 246     synchronized void addInfo(int newinfo) {
 247         availinfo |= newinfo;
 248         notifyAll();
 249     }
 250 
 251     void setDimensions(int w, int h) {
 252         width = w;
 253         height = h;
 254         addInfo(ImageObserver.WIDTH | ImageObserver.HEIGHT);
 255     }
 256 
 257     void setProperties(Hashtable<?, ?> props) {
 258         if (props == null) {
 259             props = new Hashtable<String, Object>();
 260         }
 261         properties = props;
 262         addInfo(ImageObserver.PROPERTIES);
 263     }
 264 
 265     synchronized void infoDone(int status) {
 266         if (status == ImageConsumer.IMAGEERROR ||
 267             ((~availinfo) & (ImageObserver.WIDTH |
 268                              ImageObserver.HEIGHT)) != 0) {
 269             addInfo(ImageObserver.ERROR);
 270         } else if ((availinfo & ImageObserver.PROPERTIES) == 0) {
 271             setProperties(null);
 272         }
 273     }
 274 
 275     public void flush() {
 276         if (src != null) {
 277             src.checkSecurity(null, false);
 278         }
 279