jdk/src/java.desktop/share/classes/javax/imageio/IIOImage.java
author alanb
Fri, 07 Apr 2017 08:05:54 +0000
changeset 44545 83b611b88ac8
parent 35667 ed476aba94de
permissions -rw-r--r--
8177530: Module system implementation refresh (4/2017) Reviewed-by: mchung, alanb Contributed-by: alan.bateman@oracle.com, mandy.chung@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.imageio;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.image.BufferedImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.image.Raster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.image.RenderedImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.imageio.metadata.IIOMetadata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * A simple container class to aggregate an image, a set of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * thumbnail (preview) images, and an object representing metadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * associated with the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <p> The image data may take the form of either a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    40
 * {@code RenderedImage}, or a {@code Raster}.  Reader
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    41
 * methods that return an {@code IIOImage} will always return a
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    42
 * {@code BufferedImage} using the {@code RenderedImage}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    43
 * reference.  Writer methods that accept an {@code IIOImage}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    44
 * will always accept a {@code RenderedImage}, and may optionally
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    45
 * accept a {@code Raster}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    47
 * <p> Exactly one of {@code getRenderedImage} and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    48
 * {@code getRaster} will return a non-{@code null} value.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * Subclasses are responsible for ensuring this behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * @see ImageReader#readAll(int, ImageReadParam)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * @see ImageReader#readAll(java.util.Iterator)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * @see ImageWriter#write(javax.imageio.metadata.IIOMetadata,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *                        IIOImage, ImageWriteParam)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * @see ImageWriter#write(IIOImage)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * @see ImageWriter#writeToSequence(IIOImage, ImageWriteParam)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @see ImageWriter#writeInsert(int, IIOImage, ImageWriteParam)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
public class IIOImage {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    63
     * The {@code RenderedImage} being referenced.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    protected RenderedImage image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    68
     * The {@code Raster} being referenced.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    protected Raster raster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    73
     * A {@code List} of {@code BufferedImage} thumbnails,
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    74
     * or {@code null}.  Non-{@code BufferedImage} objects
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    75
     * must not be stored in this {@code List}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    protected List<? extends BufferedImage> thumbnails = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    80
     * An {@code IIOMetadata} object containing metadata
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * associated with the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    protected IIOMetadata metadata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    86
     * Constructs an {@code IIOImage} containing a
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    87
     * {@code RenderedImage}, and thumbnails and metadata
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * associated with it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * <p> All parameters are stored by reference.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    92
     * <p> The {@code thumbnails} argument must either be
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    93
     * {@code null} or contain only {@code BufferedImage}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    96
     * @param image a {@code RenderedImage}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    97
     * @param thumbnails a {@code List} of {@code BufferedImage}s,
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    98
     * or {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    99
     * @param metadata an {@code IIOMetadata} object, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   100
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   102
     * @exception IllegalArgumentException if {@code image} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   103
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    public IIOImage(RenderedImage image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                    List<? extends BufferedImage> thumbnails,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                    IIOMetadata metadata) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        if (image == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            throw new IllegalArgumentException("image == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        this.image = image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        this.raster = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        this.thumbnails = thumbnails;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        this.metadata = metadata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   118
     * Constructs an {@code IIOImage} containing a
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   119
     * {@code Raster}, and thumbnails and metadata
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * associated with it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * <p> All parameters are stored by reference.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   124
     * @param raster a {@code Raster}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   125
     * @param thumbnails a {@code List} of {@code BufferedImage}s,
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   126
     * or {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   127
     * @param metadata an {@code IIOMetadata} object, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   128
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   130
     * @exception IllegalArgumentException if {@code raster} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   131
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    public IIOImage(Raster raster,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                    List<? extends BufferedImage> thumbnails,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                    IIOMetadata metadata) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        if (raster == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            throw new IllegalArgumentException("raster == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        this.raster = raster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        this.image = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        this.thumbnails = thumbnails;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        this.metadata = metadata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   146
     * Returns the currently set {@code RenderedImage}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   147
     * {@code null} if only a {@code Raster} is available.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   149
     * @return a {@code RenderedImage}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @see #setRenderedImage
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    public RenderedImage getRenderedImage() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            return image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   160
     * Sets the current {@code RenderedImage}.  The value is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   161
     * stored by reference.  Any existing {@code Raster} is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * discarded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   164
     * @param image a {@code RenderedImage}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   166
     * @exception IllegalArgumentException if {@code image} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   167
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @see #getRenderedImage
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    public void setRenderedImage(RenderedImage image) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            if (image == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                throw new IllegalArgumentException("image == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            this.image = image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            this.raster = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   182
     * Returns {@code true} if this {@code IIOImage} stores
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   183
     * a {@code Raster} rather than a {@code RenderedImage}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   185
     * @return {@code true} if a {@code Raster} is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    public boolean hasRaster() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            return (raster != null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   195
     * Returns the currently set {@code Raster}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   196
     * {@code null} if only a {@code RenderedImage} is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   199
     * @return a {@code Raster}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @see #setRaster
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    public Raster getRaster() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            return raster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   210
     * Sets the current {@code Raster}.  The value is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   211
     * stored by reference.  Any existing {@code RenderedImage} is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * discarded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   214
     * @param raster a {@code Raster}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   216
     * @exception IllegalArgumentException if {@code raster} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   217
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * @see #getRaster
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    public void setRaster(Raster raster) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            if (raster == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                throw new IllegalArgumentException("raster == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            this.raster = raster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            this.image = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * Returns the number of thumbnails stored in this
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   233
     * {@code IIOImage}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   235
     * @return the number of thumbnails, as an {@code int}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    public int getNumThumbnails() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        return thumbnails == null ? 0 : thumbnails.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * Returns a thumbnail associated with the main image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @param index the index of the desired thumbnail image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   246
     * @return a thumbnail image, as a {@code BufferedImage}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @exception IndexOutOfBoundsException if the supplied index is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * negative or larger than the largest valid index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * @exception ClassCastException if a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   251
     * non-{@code BufferedImage} object is encountered in the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * list of thumbnails at the given index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @see #getThumbnails
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * @see #setThumbnails
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    public BufferedImage getThumbnail(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        if (thumbnails == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            throw new IndexOutOfBoundsException("No thumbnails available!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        return (BufferedImage)thumbnails.get(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   265
     * Returns the current {@code List} of thumbnail
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   266
     * {@code BufferedImage}s, or {@code null} if none is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * set.  A live reference is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   269
     * @return the current {@code List} of
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   270
     * {@code BufferedImage} thumbnails, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * @see #getThumbnail(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * @see #setThumbnails
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    public List<? extends BufferedImage> getThumbnails() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        return thumbnails;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   280
     * Sets the list of thumbnails to a new {@code List} of
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   281
     * {@code BufferedImage}s, or to {@code null}.  The
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   282
     * reference to the previous {@code List} is discarded.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   284
     * <p> The {@code thumbnails} argument must either be
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   285
     * {@code null} or contain only {@code BufferedImage}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   288
     * @param thumbnails a {@code List} of
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   289
     * {@code BufferedImage} thumbnails, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @see #getThumbnail(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * @see #getThumbnails
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    public void setThumbnails(List<? extends BufferedImage> thumbnails) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        this.thumbnails = thumbnails;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   299
     * Returns a reference to the current {@code IIOMetadata}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   300
     * object, or {@code null} is none is set.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   302
     * @return an {@code IIOMetadata} object, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * @see #setMetadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    public IIOMetadata getMetadata() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        return metadata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   311
     * Sets the {@code IIOMetadata} to a new object, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   312
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   314
     * @param metadata an {@code IIOMetadata} object, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   315
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * @see #getMetadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    public void setMetadata(IIOMetadata metadata) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        this.metadata = metadata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
}