001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Rustem V. Rafikov
019: * @version $Revision: 1.3 $
020: */package javax.imageio;
021:
022: import javax.imageio.metadata.IIOMetadata;
023: import java.awt.image.RenderedImage;
024: import java.awt.image.Raster;
025: import java.awt.image.BufferedImage;
026: import java.util.List;
027:
028: public class IIOImage {
029:
030: protected RenderedImage image;
031: protected Raster raster;
032: protected List<? extends BufferedImage> thumbnails;
033: protected IIOMetadata metadata;
034:
035: public IIOImage(RenderedImage image,
036: List<? extends BufferedImage> thumbnails,
037: IIOMetadata metadata) {
038: if (image == null) {
039: throw new IllegalArgumentException(
040: "image should not be NULL");
041: }
042: this .raster = null;
043: this .image = image;
044: this .thumbnails = thumbnails;
045: this .metadata = metadata;
046: }
047:
048: public IIOImage(Raster raster,
049: List<? extends BufferedImage> thumbnails,
050: IIOMetadata metadata) {
051: if (raster == null) {
052: throw new IllegalArgumentException(
053: "raster should not be NULL");
054: }
055: this .image = null;
056: this .raster = raster;
057: this .thumbnails = thumbnails;
058: this .metadata = metadata;
059: }
060:
061: public RenderedImage getRenderedImage() {
062: return image;
063: }
064:
065: public void setRenderedImage(RenderedImage image) {
066: if (image == null) {
067: throw new IllegalArgumentException(
068: "image should not be NULL");
069: }
070: raster = null;
071: this .image = image;
072: }
073:
074: public boolean hasRaster() {
075: return raster != null;
076: }
077:
078: public Raster getRaster() {
079: return raster;
080: }
081:
082: public void setRaster(Raster raster) {
083: if (raster == null) {
084: throw new IllegalArgumentException(
085: "raster should not be NULL");
086: }
087: image = null;
088: this .raster = raster;
089: }
090:
091: public int getNumThumbnails() {
092: return thumbnails != null ? thumbnails.size() : 0;
093: }
094:
095: public BufferedImage getThumbnail(int index) {
096: if (thumbnails != null) {
097: return thumbnails.get(index);
098: }
099: throw new IndexOutOfBoundsException("no thumbnails were set");
100: }
101:
102: public List<? extends BufferedImage> getThumbnails() {
103: return thumbnails;
104: }
105:
106: public void setThumbnails(List<? extends BufferedImage> thumbnails) {
107: this .thumbnails = thumbnails;
108: }
109:
110: public IIOMetadata getMetadata() {
111: return metadata;
112: }
113:
114: public void setMetadata(IIOMetadata metadata) {
115: this.metadata = metadata;
116: }
117: }
|