1 7 8 package javax.imageio; 9 10 import java.awt.image.BufferedImage ; 11 import java.awt.image.Raster ; 12 import java.awt.image.RenderedImage ; 13 import java.util.List ; 14 import javax.imageio.metadata.IIOMetadata ; 15 16 43 public class IIOImage { 44 45 48 protected RenderedImage image; 49 50 53 protected Raster raster; 54 55 60 protected List <? extends BufferedImage > thumbnails = null; 61 62 66 protected IIOMetadata metadata; 67 68 88 public IIOImage(RenderedImage image, 89 List <? extends BufferedImage > thumbnails, 90 IIOMetadata metadata) { 91 if (image == null) { 92 throw new IllegalArgumentException ("image == null!"); 93 } 94 this.image = image; 95 this.raster = null; 96 this.thumbnails = thumbnails; 97 this.metadata = metadata; 98 } 99 100 116 public IIOImage(Raster raster, 117 List <? extends BufferedImage > thumbnails, 118 IIOMetadata metadata) { 119 if (raster == null) { 120 throw new IllegalArgumentException ("raster == null!"); 121 } 122 this.raster = raster; 123 this.image = null; 124 this.thumbnails = thumbnails; 125 this.metadata = metadata; 126 } 127 128 136 public RenderedImage getRenderedImage() { 137 synchronized(this) { 138 return image; 139 } 140 } 141 142 154 public void setRenderedImage(RenderedImage image) { 155 synchronized(this) { 156 if (image == null) { 157 throw new IllegalArgumentException ("image == null!"); 158 } 159 this.image = image; 160 this.raster = null; 161 } 162 } 163 164 171 public boolean hasRaster() { 172 synchronized(this) { 173 return (raster != null); 174 } 175 } 176 177 186 public Raster getRaster() { 187 synchronized(this) { 188 return raster; 189 } 190 } 191 192 204 public void setRaster(Raster raster) { 205 synchronized(this) { 206 if (raster == null) { 207 throw new IllegalArgumentException ("raster == null!"); 208 } 209 this.raster = raster; 210 this.image = null; 211 } 212 } 213 214 220 public int getNumThumbnails() { 221 return thumbnails == null ? 0 : thumbnails.size(); 222 } 223 224 240 public BufferedImage getThumbnail(int index) { 241 if (thumbnails == null) { 242 throw new IndexOutOfBoundsException ("No thumbnails available!"); 243 } 244 return (BufferedImage )thumbnails.get(index); 245 } 246 247 258 public List <? extends BufferedImage > getThumbnails() { 259 return thumbnails; 260 } 261 262 277 public void setThumbnails(List <? extends BufferedImage > thumbnails) { 278 this.thumbnails = thumbnails; 279 } 280 281 289 public IIOMetadata getMetadata() { 290 return metadata; 291 } 292 293 302 public void setMetadata(IIOMetadata metadata) { 303 this.metadata = metadata; 304 } 305 } 306 | Popular Tags |