jdk/src/java.desktop/share/classes/javax/imageio/ImageWriter.java
author jdv
Tue, 19 Jan 2016 11:14:41 +0530
changeset 35679 e4b92165fa8d
parent 35667 ed476aba94de
child 36511 9d0388c6b336
permissions -rw-r--r--
8144744: ImageWriter.replacePixels() specification is incorrect regarding null ImageWriteParam Reviewed-by: prr, psadhukhan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 22260
diff changeset
     2
 * Copyright (c) 1999, 2014, 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.Dimension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.image.BufferedImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.image.RenderedImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.image.Raster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.Locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.util.MissingResourceException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.util.ResourceBundle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import javax.imageio.event.IIOWriteWarningListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import javax.imageio.event.IIOWriteProgressListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import javax.imageio.metadata.IIOMetadata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import javax.imageio.stream.ImageOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import javax.imageio.spi.ImageWriterSpi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * An abstract superclass for encoding and writing images.  This class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * must be subclassed by classes that write out images in the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * of the Java Image I/O framework.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    50
 * <p> {@code ImageWriter} objects are normally instantiated by
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * the service provider class for the specific format.  Service
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    52
 * provider classes are registered with the {@code IIORegistry},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * which uses them for format recognition and presentation of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * available format readers and writers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * @see ImageReader
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @see ImageWriteParam
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * @see javax.imageio.spi.IIORegistry
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * @see javax.imageio.spi.ImageWriterSpi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
public abstract class ImageWriter implements ImageTranscoder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    65
     * The {@code ImageWriterSpi} that instantiated this object,
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    66
     * or {@code null} if its identity is not known or none
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    67
     * exists.  By default it is initialized to {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    protected ImageWriterSpi originatingProvider = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    72
     * The {@code ImageOutputStream} or other {@code Object}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    73
     * set by {@code setOutput} and retrieved by
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    74
     * {@code getOutput}.  By default it is initialized to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    75
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    protected Object output = 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 array of {@code Locale}s that may be used to localize
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * warning messages and compression setting values, or
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    82
     * {@code null} if localization is not supported.  By default
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    83
     * it is initialized to {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    protected Locale[] availableLocales = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    88
     * The current {@code Locale} to be used for localization, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    89
     * {@code null} if none has been set.  By default it is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    90
     * initialized to {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    protected Locale locale = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    95
     * A {@code List} of currently registered
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    96
     * {@code IIOWriteWarningListener}s, initialized by default to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    97
     * {@code null}, which is synonymous with an empty
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    98
     * {@code List}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    protected List<IIOWriteWarningListener> warningListeners = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   103
     * A {@code List} of {@code Locale}s, one for each
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   104
     * element of {@code warningListeners}, initialized by default
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   105
     * {@code null}, which is synonymous with an empty
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   106
     * {@code List}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    protected List<Locale> warningLocales = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   111
     * A {@code List} of currently registered
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   112
     * {@code IIOWriteProgressListener}s, initialized by default
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   113
     * {@code null}, which is synonymous with an empty
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   114
     * {@code List}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    protected List<IIOWriteProgressListener> progressListeners = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   119
     * If {@code true}, the current write operation should be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * aborted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    private boolean abortFlag = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   125
     * Constructs an {@code ImageWriter} and sets its
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   126
     * {@code originatingProvider} instance variable to the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * supplied value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * <p> Subclasses that make use of extensions should provide a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   130
     * constructor with signature {@code (ImageWriterSpi, Object)}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   131
     * in order to retrieve the extension object.  If
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * the extension object is unsuitable, an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   133
     * {@code IllegalArgumentException} should be thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   135
     * @param originatingProvider the {@code ImageWriterSpi} that
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   136
     * is constructing this object, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    protected ImageWriter(ImageWriterSpi originatingProvider) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        this.originatingProvider = originatingProvider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   143
     * Returns the {@code ImageWriterSpi} object that created
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   144
     * this {@code ImageWriter}, or {@code null} if this
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   145
     * object was not created through the {@code IIORegistry}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * <p> The default implementation returns the value of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   148
     * {@code originatingProvider} instance variable.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   150
     * @return an {@code ImageWriterSpi}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @see ImageWriterSpi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    public ImageWriterSpi getOriginatingProvider() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        return originatingProvider;
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
     * Sets the destination to the given
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   160
     * {@code ImageOutputStream} or other {@code Object}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * The destination is assumed to be ready to accept data, and will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * not be closed at the end of each write. This allows distributed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * imaging applications to transmit a series of images over a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   164
     * single network connection.  If {@code output} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   165
     * {@code null}, any currently set output will be removed.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   167
     * <p> If {@code output} is an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   168
     * {@code ImageOutputStream}, calls to the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   169
     * {@code write}, {@code writeToSequence}, and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   170
     * {@code prepareWriteEmpty}/{@code endWriteEmpty}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * methods will preserve the existing contents of the stream.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   172
     * Other write methods, such as {@code writeInsert},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   173
     * {@code replaceStreamMetadata},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   174
     * {@code replaceImageMetadata}, {@code replacePixels},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   175
     * {@code prepareInsertEmpty}/{@code endInsertEmpty},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   176
     * and {@code endWriteSequence}, require the full contents
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * of the stream to be readable and writable, and may alter any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * portion of the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   180
     * <p> Use of a general {@code Object} other than an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   181
     * {@code ImageOutputStream} is intended for writers that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * interact directly with an output device or imaging protocol.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * The set of legal classes is advertised by the writer's service
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   184
     * provider's {@code getOutputTypes} method; most writers
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * will return a single-element array containing only
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   186
     * {@code ImageOutputStream.class} to indicate that they
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   187
     * accept only an {@code ImageOutputStream}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   189
     * <p> The default implementation sets the {@code output}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   190
     * instance variable to the value of {@code output} after
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   191
     * checking {@code output} against the set of classes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * advertised by the originating provider, if there is one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   194
     * @param output the {@code ImageOutputStream} or other
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   195
     * {@code Object} to use for future writing.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   197
     * @exception IllegalArgumentException if {@code output} is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * not an instance of one of the classes returned by the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   199
     * originating service provider's {@code getOutputTypes}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @see #getOutput
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    public void setOutput(Object output) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        if (output != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            ImageWriterSpi provider = getOriginatingProvider();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            if (provider != null) {
23313
f100f0d49e0b 8035487: Fix raw and unchecked lint warnings in javax.imageio.spi
henryjen
parents: 23306
diff changeset
   208
                Class<?>[] classes = provider.getOutputTypes();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                boolean found = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                for (int i = 0; i < classes.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                    if (classes[i].isInstance(output)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                        found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                if (!found) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                    throw new IllegalArgumentException("Illegal output type!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        this.output = output;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   226
     * Returns the {@code ImageOutputStream} or other
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   227
     * {@code Object} set by the most recent call to the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   228
     * {@code setOutput} method.  If no destination has been
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   229
     * set, {@code null} is returned.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * <p> The default implementation returns the value of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   232
     * {@code output} instance variable.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   234
     * @return the {@code Object} that was specified using
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   235
     * {@code setOutput}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * @see #setOutput
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    public Object getOutput() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        return output;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    // Localization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   246
     * Returns an array of {@code Locale}s that may be used to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * localize warning listeners and compression settings.  A return
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   248
     * value of {@code null} indicates that localization is not
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * <p> The default implementation returns a clone of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   252
     * {@code availableLocales} instance variable if it is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   253
     * non-{@code null}, or else returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   255
     * @return an array of {@code Locale}s that may be used as
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   256
     * arguments to {@code setLocale}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    public Locale[] getAvailableLocales() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        return (availableLocales == null) ?
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 22260
diff changeset
   260
            null : availableLocales.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   264
     * Sets the current {@code Locale} of this
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   265
     * {@code ImageWriter} to the given value.  A value of
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   266
     * {@code null} removes any previous setting, and indicates
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * that the writer should localize as it sees fit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   269
     * <p> The default implementation checks {@code locale}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * against the values returned by
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   271
     * {@code getAvailableLocales}, and sets the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   272
     * {@code locale} instance variable if it is found.  If
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   273
     * {@code locale} is {@code null}, the instance variable
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   274
     * is set to {@code null} without any checking.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   276
     * @param locale the desired {@code Locale}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   277
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   279
     * @exception IllegalArgumentException if {@code locale} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   280
     * non-{@code null} but is not one of the values returned by
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   281
     * {@code getAvailableLocales}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @see #getLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    public void setLocale(Locale locale) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        if (locale != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            Locale[] locales = getAvailableLocales();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            boolean found = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            if (locales != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                for (int i = 0; i < locales.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                    if (locale.equals(locales[i])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                        found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            if (!found) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                throw new IllegalArgumentException("Invalid locale!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        this.locale = locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   305
     * Returns the currently set {@code Locale}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   306
     * {@code null} if none has been set.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * <p> The default implementation returns the value of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   309
     * {@code locale} instance variable.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   311
     * @return the current {@code Locale}, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * @see #setLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    public Locale getLocale() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        return locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    // Write params
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   322
     * Returns a new {@code ImageWriteParam} object of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * appropriate type for this file format containing default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * values, that is, those values that would be used
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   325
     * if no {@code ImageWriteParam} object were specified.  This
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * is useful as a starting point for tweaking just a few parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * and otherwise leaving the default settings alone.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * <p> The default implementation constructs and returns a new
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   330
     * {@code ImageWriteParam} object that does not allow tiling,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * progressive encoding, or compression, and that will be
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   332
     * localized for the current {@code Locale} (<i>i.e.</i>,
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   333
     * what you would get by calling
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   334
     * {@code new ImageWriteParam(getLocale())}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * <p> Individual plug-ins may return an instance of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   337
     * {@code ImageWriteParam} with additional optional features
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * enabled, or they may return an instance of a plug-in specific
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   339
     * subclass of {@code ImageWriteParam}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   341
     * @return a new {@code ImageWriteParam} object containing
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * default values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    public ImageWriteParam getDefaultWriteParam() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        return new ImageWriteParam(getLocale());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    // Metadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   351
     * Returns an {@code IIOMetadata} object containing default
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * values for encoding a stream of images.  The contents of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * object may be manipulated using either the XML tree structure
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   354
     * returned by the {@code IIOMetadata.getAsTree} method, an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   355
     * {@code IIOMetadataController} object, or via plug-in
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * specific interfaces, and the resulting data supplied to one of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   357
     * the {@code write} methods that take a stream metadata
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   360
     * <p> An optional {@code ImageWriteParam} may be supplied
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * for cases where it may affect the structure of the stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * metadata.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   364
     * <p> If the supplied {@code ImageWriteParam} contains
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * optional setting values not supported by this writer (<i>e.g.</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * progressive encoding or any format-specific settings), they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * <p> Writers that do not make use of stream metadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * (<i>e.g.</i>, writers for single-image formats) should return
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   371
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   373
     * @param param an {@code ImageWriteParam} that will be used to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   374
     * encode the image, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   376
     * @return an {@code IIOMetadata} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    public abstract IIOMetadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        getDefaultStreamMetadata(ImageWriteParam param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   382
     * Returns an {@code IIOMetadata} object containing default
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * values for encoding an image of the given type.  The contents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * of the object may be manipulated using either the XML tree
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   385
     * structure returned by the {@code IIOMetadata.getAsTree}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   386
     * method, an {@code IIOMetadataController} object, or via
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * plug-in specific interfaces, and the resulting data supplied to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   388
     * one of the {@code write} methods that take a stream
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * metadata parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   391
     * <p> An optional {@code ImageWriteParam} may be supplied
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * for cases where it may affect the structure of the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * metadata.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   395
     * <p> If the supplied {@code ImageWriteParam} contains
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * optional setting values not supported by this writer (<i>e.g.</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * progressive encoding or any format-specific settings), they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   400
     * @param imageType an {@code ImageTypeSpecifier} indicating the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * format of the image to be written later.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   402
     * @param param an {@code ImageWriteParam} that will be used to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   403
     * encode the image, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   405
     * @return an {@code IIOMetadata} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    public abstract IIOMetadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        getDefaultImageMetadata(ImageTypeSpecifier imageType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                                ImageWriteParam param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    // comment inherited
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    public abstract IIOMetadata convertStreamMetadata(IIOMetadata inData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                                                      ImageWriteParam param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    // comment inherited
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    public abstract IIOMetadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        convertImageMetadata(IIOMetadata inData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                             ImageTypeSpecifier imageType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                             ImageWriteParam param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    // Thumbnails
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    /**
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 19168
diff changeset
   424
     * Returns the number of thumbnails supported by the format being
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * written, given the image type and any additional write
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * parameters and metadata objects that will be used during
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   427
     * encoding.  A return value of {@code -1} indicates that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * insufficient information is available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   430
     * <p> An {@code ImageWriteParam} may optionally be supplied
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * for cases where it may affect thumbnail handling.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   433
     * <p> If the supplied {@code ImageWriteParam} contains
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * optional setting values not supported by this writer (<i>e.g.</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * progressive encoding or any format-specific settings), they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * <p> The default implementation returns 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   440
     * @param imageType an {@code ImageTypeSpecifier} indicating
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   441
     * the type of image to be written, or {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   442
     * @param param the {@code ImageWriteParam} that will be used for
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   443
     * writing, or {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   444
     * @param streamMetadata an {@code IIOMetadata} object that will
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   445
     * be used for writing, or {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   446
     * @param imageMetadata an {@code IIOMetadata} object that will
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   447
     * be used for writing, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * @return the number of thumbnails that may be written given the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   450
     * supplied parameters, or {@code -1} if insufficient
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * information is available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    public int getNumThumbnailsSupported(ImageTypeSpecifier imageType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                                         ImageWriteParam param,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                                         IIOMetadata streamMetadata,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                                         IIOMetadata imageMetadata) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   461
     * Returns an array of {@code Dimension}s indicating the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * legal size ranges for thumbnail images as they will be encoded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * in the output file or stream.  This information is merely
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * advisory; the writer will resize any supplied thumbnails as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * <p> The information is returned as a set of pairs; the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * element of a pair contains an (inclusive) minimum width and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * height, and the second element contains an (inclusive) maximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * width and height.  Together, each pair defines a valid range of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * sizes.  To specify a fixed size, the same width and height will
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   472
     * appear for both elements.  A return value of {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * indicates that the size is arbitrary or unknown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   475
     * <p> An {@code ImageWriteParam} may optionally be supplied
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * for cases where it may affect thumbnail handling.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   478
     * <p> If the supplied {@code ImageWriteParam} contains
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * optional setting values not supported by this writer (<i>e.g.</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * progressive encoding or any format-specific settings), they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   483
     * <p> The default implementation returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   485
     * @param imageType an {@code ImageTypeSpecifier} indicating the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   486
     * type of image to be written, or {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   487
     * @param param the {@code ImageWriteParam} that will be used for
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   488
     * writing, or {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   489
     * @param streamMetadata an {@code IIOMetadata} object that will
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   490
     * be used for writing, or {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   491
     * @param imageMetadata an {@code IIOMetadata} object that will
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   492
     * be used for writing, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   494
     * @return an array of {@code Dimension}s with an even length
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   495
     * of at least two, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    public Dimension[] getPreferredThumbnailSizes(ImageTypeSpecifier imageType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                                                  ImageWriteParam param,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                                                  IIOMetadata streamMetadata,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                                                  IIOMetadata imageMetadata) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   505
     * Returns {@code true} if the methods that take an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   506
     * {@code IIOImage} parameter are capable of dealing with a
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   507
     * {@code Raster} (as opposed to {@code RenderedImage})
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   508
     * source image.  If this method returns {@code false}, then
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * those methods will throw an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   510
     * {@code UnsupportedOperationException} if supplied with an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   511
     * {@code IIOImage} containing a {@code Raster}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   513
     * <p> The default implementation returns {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   515
     * @return {@code true} if {@code Raster} sources are
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    public boolean canWriteRasters() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * Appends a complete image stream containing a single image and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * associated stream and image metadata and thumbnails to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * output.  Any necessary header information is included.  If the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   526
     * output is an {@code ImageOutputStream}, its existing
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * contents prior to the current seek position are not affected,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * and need not be readable or writable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * <p> The output must have been set beforehand using the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   531
     * {@code setOutput} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * <p> Stream metadata may optionally be supplied; if it is
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   534
     * {@code null}, default stream metadata will be used.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   536
     * <p> If {@code canWriteRasters} returns {@code true},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   537
     * the {@code IIOImage} may contain a {@code Raster}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * source.  Otherwise, it must contain a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   539
     * {@code RenderedImage} source.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * <p> The supplied thumbnails will be resized if needed, and any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * thumbnails in excess of the supported number will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * If the format requires additional thumbnails that are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * provided, the writer should generate them internally.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   546
     * <p>  An {@code ImageWriteParam} may
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * optionally be supplied to control the writing process.  If
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   548
     * {@code param} is {@code null}, a default write param
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   551
     * <p> If the supplied {@code ImageWriteParam} contains
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * optional setting values not supported by this writer (<i>e.g.</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * progressive encoding or any format-specific settings), they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   556
     * @param streamMetadata an {@code IIOMetadata} object representing
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   557
     * stream metadata, or {@code null} to use default values.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   558
     * @param image an {@code IIOImage} object containing an
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * image, thumbnails, and metadata to be written.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   560
     * @param param an {@code ImageWriteParam}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   561
     * {@code null} to use a default
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   562
     * {@code ImageWriteParam}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * been set.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   566
     * @exception UnsupportedOperationException if {@code image}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   567
     * contains a {@code Raster} and {@code canWriteRasters}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   568
     * returns {@code false}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   569
     * @exception IllegalArgumentException if {@code image} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   570
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * @exception IOException if an error occurs during writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    public abstract void write(IIOMetadata streamMetadata,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                               IIOImage image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                               ImageWriteParam param) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * Appends a complete image stream containing a single image with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * default metadata and thumbnails to the output.  This method is
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   580
     * a shorthand for {@code write(null, image, null)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   582
     * @param image an {@code IIOImage} object containing an
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * image, thumbnails, and metadata to be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * been set.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   587
     * @exception IllegalArgumentException if {@code image} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   588
     * {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   589
     * @exception UnsupportedOperationException if {@code image}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   590
     * contains a {@code Raster} and {@code canWriteRasters}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   591
     * returns {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * @exception IOException if an error occurs during writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    public void write(IIOImage image) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        write(null, image, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * Appends a complete image stream consisting of a single image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * with default metadata and thumbnails to the output.  This
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   601
     * method is a shorthand for
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   602
     * {@code write(null, new IIOImage(image, null, null), null)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   604
     * @param image a {@code RenderedImage} to be written.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * been set.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   608
     * @exception IllegalArgumentException if {@code image} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   609
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * @exception IOException if an error occurs during writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    public void write(RenderedImage image) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        write(null, new IIOImage(image, null, null), null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    // Check that the output has been set, then throw an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    // UnsupportedOperationException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    private void unsupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        if (getOutput() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
            throw new IllegalStateException("getOutput() == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        throw new UnsupportedOperationException("Unsupported write variant!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    // Sequence writes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   628
     * Returns {@code true} if the writer is able to append an
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * image to an image stream that already contains header
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * information and possibly prior images.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   632
     * <p> If {@code canWriteSequence} returns {@code false},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   633
     * {@code writeToSequence} and {@code endWriteSequence}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   634
     * will throw an {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   636
     * <p> The default implementation returns {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   638
     * @return {@code true} if images may be appended sequentially.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    public boolean canWriteSequence() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * Prepares a stream to accept a series of subsequent
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   646
     * {@code writeToSequence} calls, using the provided stream
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * metadata object.  The metadata will be written to the stream if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   648
     * it should precede the image data.  If the argument is {@code null},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * default stream metadata is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   651
     * <p> If the output is an {@code ImageOutputStream}, the existing
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * contents of the output prior to the current seek position are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     * flushed, and need not be readable or writable.  If the format
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   654
     * requires that {@code endWriteSequence} be able to rewind to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * patch up the header information, such as for a sequence of images
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * in a single TIFF file, then the metadata written by this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * must remain in a writable portion of the stream.  Other formats
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * may flush the stream after this method and after each image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   660
     * <p> If {@code canWriteSequence} returns {@code false},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     * this method will throw an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   662
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * <p> The output must have been set beforehand using either
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   665
     * the {@code setOutput} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   668
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   669
     * {@code null}, and otherwise throws an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   670
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   672
     * @param streamMetadata A stream metadata object, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * @exception UnsupportedOperationException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   677
     * {@code canWriteSequence} returns {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * @exception IOException if an error occurs writing the stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * metadata.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    public void prepareWriteSequence(IIOMetadata streamMetadata)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        unsupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * Appends a single image and possibly associated metadata and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * thumbnails, to the output.  If the output is an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   689
     * {@code ImageOutputStream}, the existing contents of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * output prior to the current seek position may be flushed, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * need not be readable or writable, unless the plug-in needs to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * be able to patch up the header information when
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   693
     * {@code endWriteSequence} is called (<i>e.g.</i> TIFF).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   695
     * <p> If {@code canWriteSequence} returns {@code false},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     * this method will throw an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   697
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * <p> The output must have been set beforehand using
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   700
     * the {@code setOutput} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   702
     * <p> {@code prepareWriteSequence} must have been called
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   703
     * beforehand, or an {@code IllegalStateException} is thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   705
     * <p> If {@code canWriteRasters} returns {@code true},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   706
     * the {@code IIOImage} may contain a {@code Raster}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * source.  Otherwise, it must contain a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   708
     * {@code RenderedImage} source.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     * <p> The supplied thumbnails will be resized if needed, and any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * thumbnails in excess of the supported number will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     * If the format requires additional thumbnails that are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     * provided, the writer will generate them internally.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   715
     * <p> An {@code ImageWriteParam} may optionally be supplied
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   716
     * to control the writing process.  If {@code param} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   717
     * {@code null}, a default write param will be used.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   719
     * <p> If the supplied {@code ImageWriteParam} contains
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * optional setting values not supported by this writer (<i>e.g.</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * progressive encoding or any format-specific settings), they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   725
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   726
     * {@code null}, and otherwise throws an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   727
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   729
     * @param image an {@code IIOImage} object containing an
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * image, thumbnails, and metadata to be written.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   731
     * @param param an {@code ImageWriteParam}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   732
     * {@code null} to use a default
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   733
     * {@code ImageWriteParam}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     * @exception IllegalStateException if the output has not
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   736
     * been set, or {@code prepareWriteSequence} has not been called.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
     * @exception UnsupportedOperationException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   738
     * {@code canWriteSequence} returns {@code false}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   739
     * @exception IllegalArgumentException if {@code image} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   740
     * {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   741
     * @exception UnsupportedOperationException if {@code image}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   742
     * contains a {@code Raster} and {@code canWriteRasters}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   743
     * returns {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * @exception IOException if an error occurs during writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
    public void writeToSequence(IIOImage image, ImageWriteParam param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        unsupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     * Completes the writing of a sequence of images begun with
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   753
     * {@code prepareWriteSequence}.  Any stream metadata that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     * should come at the end of the sequence of images is written out,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     * and any header information at the beginning of the sequence is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     * patched up if necessary.  If the output is an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   757
     * {@code ImageOutputStream}, data through the stream metadata
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     * at the end of the sequence are flushed and need not be readable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
     * or writable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   761
     * <p> If {@code canWriteSequence} returns {@code false},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
     * this method will throw an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   763
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   766
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   767
     * {@code null}, and otherwise throws an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   768
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * @exception IllegalStateException if the output has not
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   771
     * been set, or {@code prepareWriteSequence} has not been called.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * @exception UnsupportedOperationException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   773
     * {@code canWriteSequence} returns {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * @exception IOException if an error occurs during writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
    public void endWriteSequence() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        unsupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    // Metadata replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   783
     * Returns {@code true} if it is possible to replace the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     * stream metadata already present in the output.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   787
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   788
     * {@code null}, and otherwise returns {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   790
     * @return {@code true} if replacement of stream metadata is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     * allowed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     * @exception IOException if an I/O error occurs during the query.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    public boolean canReplaceStreamMetadata() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        if (getOutput() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
            throw new IllegalStateException("getOutput() == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * Replaces the stream metadata in the output with new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     * information.  If the output is an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   807
     * {@code ImageOutputStream}, the prior contents of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     * stream are examined and possibly edited to make room for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     * new data.  All of the prior contents of the output must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     * available for reading and writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   812
     * <p> If {@code canReplaceStreamMetadata} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   813
     * {@code false}, an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   814
     * {@code UnsupportedOperationException} will be thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   817
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   818
     * {@code null}, and otherwise throws an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   819
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   821
     * @param streamMetadata an {@code IIOMetadata} object representing
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   822
     * stream metadata, or {@code null} to use default values.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
     * @exception UnsupportedOperationException if the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   827
     * {@code canReplaceStreamMetadata} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   828
     * {@code false}.  modes do not include
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * @exception IOException if an error occurs during writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    public void replaceStreamMetadata(IIOMetadata streamMetadata)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        unsupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   837
     * Returns {@code true} if it is possible to replace the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * image metadata associated with an existing image with index
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   839
     * {@code imageIndex}.  If this method returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   840
     * {@code false}, a call to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   841
     * {@code replaceImageMetadata(imageIndex)} will throw an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   842
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     * <p> A writer that does not support any image metadata
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   845
     * replacement may return {@code false} without performing
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     * bounds checking on the index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   849
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   850
     * {@code null}, and otherwise returns {@code false}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   851
     * without checking the value of {@code imageIndex}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
     * @param imageIndex the index of the image whose metadata is to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
     * be replaced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   856
     * @return {@code true} if the image metadata of the given
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
     * image can be replaced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
     * @exception IndexOutOfBoundsException if the writer supports
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
     * image metadata replacement in general, but
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   863
     * {@code imageIndex} is less than 0 or greater than the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
     * largest available index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     * @exception IOException if an I/O error occurs during the query.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    public boolean canReplaceImageMetadata(int imageIndex)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
        if (getOutput() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
            throw new IllegalStateException("getOutput() == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
     * Replaces the image metadata associated with an existing image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   878
     * <p> If {@code canReplaceImageMetadata(imageIndex)} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   879
     * {@code false}, an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   880
     * {@code UnsupportedOperationException} will be thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   883
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   884
     * {@code null}, and otherwise throws an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   885
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
     * @param imageIndex the index of the image whose metadata is to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
     * be replaced.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   889
     * @param imageMetadata an {@code IIOMetadata} object
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   890
     * representing image metadata, or {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
     * @exception IllegalStateException if the output has not been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
     * set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
     * @exception UnsupportedOperationException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   895
     * {@code canReplaceImageMetadata} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   896
     * {@code false}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   897
     * @exception IndexOutOfBoundsException if {@code imageIndex}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     * is less than 0 or greater than the largest available index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     * @exception IOException if an error occurs during writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
    public void replaceImageMetadata(int imageIndex,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
                                     IIOMetadata imageMetadata)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
        unsupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    // Image insertion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   910
     * Returns {@code true} if the writer supports the insertion
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
     * of a new image at the given index.  Existing images with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
     * indices greater than or equal to the insertion index will have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
     * their indices increased by 1.  A value for
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   914
     * {@code imageIndex} of {@code -1} may be used to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
     * signify an index one larger than the current largest index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
     * <p> A writer that does not support any image insertion may
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   918
     * return {@code false} without performing bounds checking on
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
     * the index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   922
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   923
     * {@code null}, and otherwise returns {@code false}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   924
     * without checking the value of {@code imageIndex}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     * @param imageIndex the index at which the image is to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
     * inserted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   929
     * @return {@code true} if an image may be inserted at the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
     * given index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
     * @exception IndexOutOfBoundsException if the writer supports
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   935
     * image insertion in general, but {@code imageIndex} is less
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
     * than -1 or greater than the largest available index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
     * @exception IOException if an I/O error occurs during the query.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
    public boolean canInsertImage(int imageIndex) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
        if (getOutput() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
            throw new IllegalStateException("getOutput() == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
     * Inserts a new image into an existing image stream.  Existing
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   948
     * images with an index greater than {@code imageIndex} are
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     * preserved, and their indices are each increased by 1.  A value
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   950
     * for {@code imageIndex} of -1 may be used to signify an
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     * index one larger than the previous largest index; that is, it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     * will cause the image to be logically appended to the end of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   953
     * sequence.  If the output is an {@code ImageOutputStream},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
     * the entirety of the stream must be both readable and writeable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   956
     * <p> If {@code canInsertImage(imageIndex)} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   957
     * {@code false}, an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   958
     * {@code UnsupportedOperationException} will be thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   960
     * <p> An {@code ImageWriteParam} may optionally be supplied
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   961
     * to control the writing process.  If {@code param} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   962
     * {@code null}, a default write param will be used.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   964
     * <p> If the supplied {@code ImageWriteParam} contains
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
     * optional setting values not supported by this writer (<i>e.g.</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
     * progressive encoding or any format-specific settings), they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
     * will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   970
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   971
     * {@code null}, and otherwise throws an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   972
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
     * @param imageIndex the index at which to write the image.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   975
     * @param image an {@code IIOImage} object containing an
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
     * image, thumbnails, and metadata to be written.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   977
     * @param param an {@code ImageWriteParam}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   978
     * {@code null} to use a default
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   979
     * {@code ImageWriteParam}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
     * @exception UnsupportedOperationException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   984
     * {@code canInsertImage(imageIndex)} returns {@code false}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   985
     * @exception IllegalArgumentException if {@code image} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   986
     * {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   987
     * @exception IndexOutOfBoundsException if {@code imageIndex}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     * is less than -1 or greater than the largest available index.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   989
     * @exception UnsupportedOperationException if {@code image}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   990
     * contains a {@code Raster} and {@code canWriteRasters}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   991
     * returns {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
     * @exception IOException if an error occurs during writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
    public void writeInsert(int imageIndex,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
                            IIOImage image,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
                            ImageWriteParam param) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
        unsupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
    // Image removal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1003
     * Returns {@code true} if the writer supports the removal
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
     * of an existing image at the given index.  Existing images with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
     * indices greater than the insertion index will have
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
     * their indices decreased by 1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
     * <p> A writer that does not support any image removal may
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1009
     * return {@code false} without performing bounds checking on
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
     * the index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1013
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1014
     * {@code null}, and otherwise returns {@code false}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1015
     * without checking the value of {@code imageIndex}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
     * @param imageIndex the index of the image to be removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1019
     * @return {@code true} if it is possible to remove the given
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
     * image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     * @exception IndexOutOfBoundsException if the writer supports
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1025
     * image removal in general, but {@code imageIndex} is less
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
     * than 0 or greater than the largest available index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
     * @exception IOException if an I/O error occurs during the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     * query.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
    public boolean canRemoveImage(int imageIndex) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
        if (getOutput() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
            throw new IllegalStateException("getOutput() == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
     * Removes an image from the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1040
     * <p> If {@code canRemoveImage(imageIndex)} returns false,
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1041
     * an {@code UnsupportedOperationException} will be thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
     * <p> The removal may or may not cause a reduction in the actual
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
     * file size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1047
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1048
     * {@code null}, and otherwise throws an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1049
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
     * @param imageIndex the index of the image to be removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
     * @exception UnsupportedOperationException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1056
     * {@code canRemoveImage(imageIndex)} returns {@code false}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1057
     * @exception IndexOutOfBoundsException if {@code imageIndex}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
     * is less than 0 or greater than the largest available index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
     * @exception IOException if an I/O error occurs during the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
     * removal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
    public void removeImage(int imageIndex) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
        unsupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
    // Empty images
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1069
     * Returns {@code true} if the writer supports the writing of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
     * a complete image stream consisting of a single image with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
     * undefined pixel values and associated metadata and thumbnails
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
     * to the output.  The pixel values may be defined by future
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1073
     * calls to the {@code replacePixels} methods.  If the output
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1074
     * is an {@code ImageOutputStream}, its existing contents
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
     * prior to the current seek position are not affected, and need
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
     * not be readable or writable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1079
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1080
     * {@code null}, and otherwise returns {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1082
     * @return {@code true} if the writing of complete image
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
     * stream with contents to be defined later is supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
     * @exception IllegalStateException if the output has not been
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
     * set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
     * @exception IOException if an I/O error occurs during the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
     * query.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
    public boolean canWriteEmpty() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
        if (getOutput() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
            throw new IllegalStateException("getOutput() == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
     * Begins the writing of a complete image stream, consisting of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
     * single image with undefined pixel values and associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
     * metadata and thumbnails, to the output.  The pixel values will
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1101
     * be defined by future calls to the {@code replacePixels}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1102
     * methods.  If the output is an {@code ImageOutputStream},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
     * its existing contents prior to the current seek position are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
     * not affected, and need not be readable or writable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
     * <p> The writing is not complete until a call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1107
     * {@code endWriteEmpty} occurs.  Calls to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1108
     * {@code prepareReplacePixels}, {@code replacePixels},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1109
     * and {@code endReplacePixels} may occur between calls to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1110
     * {@code prepareWriteEmpty} and {@code endWriteEmpty}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1111
     * However, calls to {@code prepareWriteEmpty} cannot be
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1112
     * nested, and calls to {@code prepareWriteEmpty} and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1113
     * {@code prepareInsertEmpty} may not be interspersed.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1115
     * <p> If {@code canWriteEmpty} returns {@code false},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1116
     * an {@code UnsupportedOperationException} will be thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1118
     * <p> An {@code ImageWriteParam} may optionally be supplied
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1119
     * to control the writing process.  If {@code param} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1120
     * {@code null}, a default write param will be used.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1122
     * <p> If the supplied {@code ImageWriteParam} contains
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
     * optional setting values not supported by this writer (<i>e.g.</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
     * progressive encoding or any format-specific settings), they
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
     * will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1128
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1129
     * {@code null}, and otherwise throws an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1130
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1132
     * @param streamMetadata an {@code IIOMetadata} object representing
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1133
     * stream metadata, or {@code null} to use default values.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1134
     * @param imageType an {@code ImageTypeSpecifier} describing
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
     * the layout of the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
     * @param width the width of the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
     * @param height the height of the image.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1138
     * @param imageMetadata an {@code IIOMetadata} object
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1139
     * representing image metadata, or {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1140
     * @param thumbnails a {@code List} of
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1141
     * {@code BufferedImage} thumbnails for this image, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1142
     * {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1143
     * @param param an {@code ImageWriteParam}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1144
     * {@code null} to use a default
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1145
     * {@code ImageWriteParam}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
     * @exception UnsupportedOperationException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1150
     * {@code canWriteEmpty} returns {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
     * @exception IllegalStateException if a previous call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1152
     * {@code prepareWriteEmpty} has been made without a
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1153
     * corresponding call to {@code endWriteEmpty}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
     * @exception IllegalStateException if a previous call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1155
     * {@code prepareInsertEmpty} has been made without a
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1156
     * corresponding call to {@code endInsertEmpty}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1157
     * @exception IllegalArgumentException if {@code imageType}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1158
     * is {@code null} or {@code thumbnails} contains
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1159
     * {@code null} references or objects other than
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1160
     * {@code BufferedImage}s.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
     * @exception IllegalArgumentException if width or height are less
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
     * than 1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
     * @exception IOException if an I/O error occurs during writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
    public void prepareWriteEmpty(IIOMetadata streamMetadata,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
                                  ImageTypeSpecifier imageType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
                                  int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
                                  IIOMetadata imageMetadata,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
                                  List<? extends BufferedImage> thumbnails,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
                                  ImageWriteParam param) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
        unsupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
     * Completes the writing of a new image that was begun with a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1176
     * prior call to {@code prepareWriteEmpty}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1178
     * <p> If {@code canWriteEmpty()} returns {@code false},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1179
     * an {@code UnsupportedOperationException} will be thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1182
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1183
     * {@code null}, and otherwise throws an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1184
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
     * @exception UnsupportedOperationException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1189
     * {@code canWriteEmpty(imageIndex)} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1190
     * {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
     * @exception IllegalStateException if a previous call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1192
     * {@code prepareWriteEmpty} without a corresponding call to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1193
     * {@code endWriteEmpty} has not been made.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
     * @exception IllegalStateException if a previous call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1195
     * {@code prepareInsertEmpty} without a corresponding call to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1196
     * {@code endInsertEmpty} has been made.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
     * @exception IllegalStateException if a call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1198
     * {@code prepareReiplacePixels} has been made without a
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1199
     * matching call to {@code endReplacePixels}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
     * @exception IOException if an I/O error occurs during writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
    public void endWriteEmpty() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
        if (getOutput() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
            throw new IllegalStateException("getOutput() == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
        throw new IllegalStateException("No call to prepareWriteEmpty!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1210
     * Returns {@code true} if the writer supports the insertion
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
     * of a new, empty image at the given index.  The pixel values of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
     * the image are undefined, and may be specified in pieces using
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1213
     * the {@code replacePixels} methods.  Existing images with
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
     * indices greater than or equal to the insertion index will have
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
     * their indices increased by 1.  A value for
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1216
     * {@code imageIndex} of {@code -1} may be used to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
     * signify an index one larger than the current largest index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
     * <p> A writer that does not support insertion of empty images
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1220
     * may return {@code false} without performing bounds
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
     * checking on the index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1224
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1225
     * {@code null}, and otherwise returns {@code false}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1226
     * without checking the value of {@code imageIndex}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
     * @param imageIndex the index at which the image is to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
     * inserted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1231
     * @return {@code true} if an empty image may be inserted at
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
     * the given index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
     * @exception IllegalStateException if the output has not been
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
     * set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
     * @exception IndexOutOfBoundsException if the writer supports
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1237
     * empty image insertion in general, but {@code imageIndex}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
     * is less than -1 or greater than the largest available index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
     * @exception IOException if an I/O error occurs during the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
     * query.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
    public boolean canInsertEmpty(int imageIndex) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
        if (getOutput() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
            throw new IllegalStateException("getOutput() == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
     * Begins the insertion of a new image with undefined pixel values
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
     * into an existing image stream.  Existing images with an index
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1252
     * greater than {@code imageIndex} are preserved, and their
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
     * indices are each increased by 1.  A value for
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1254
     * {@code imageIndex} of -1 may be used to signify an index
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
     * one larger than the previous largest index; that is, it will
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
     * cause the image to be logically appended to the end of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1257
     * sequence.  If the output is an {@code ImageOutputStream},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
     * the entirety of the stream must be both readable and writeable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
     * <p> The image contents may be
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1261
     * supplied later using the {@code replacePixels} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
     * The insertion is not complete until a call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1263
     * {@code endInsertEmpty} occurs.  Calls to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1264
     * {@code prepareReplacePixels}, {@code replacePixels},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1265
     * and {@code endReplacePixels} may occur between calls to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1266
     * {@code prepareInsertEmpty} and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1267
     * {@code endInsertEmpty}.  However, calls to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1268
     * {@code prepareInsertEmpty} cannot be nested, and calls to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1269
     * {@code prepareWriteEmpty} and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1270
     * {@code prepareInsertEmpty} may not be interspersed.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1272
     * <p> If {@code canInsertEmpty(imageIndex)} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1273
     * {@code false}, an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1274
     * {@code UnsupportedOperationException} will be thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1276
     * <p> An {@code ImageWriteParam} may optionally be supplied
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1277
     * to control the writing process.  If {@code param} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1278
     * {@code null}, a default write param will be used.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1280
     * <p> If the supplied {@code ImageWriteParam} contains
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
     * optional setting values not supported by this writer (<i>e.g.</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
     * progressive encoding or any format-specific settings), they
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
     * will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1286
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1287
     * {@code null}, and otherwise throws an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1288
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
     * @param imageIndex the index at which to write the image.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1291
     * @param imageType an {@code ImageTypeSpecifier} describing
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
     * the layout of the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
     * @param width the width of the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
     * @param height the height of the image.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1295
     * @param imageMetadata an {@code IIOMetadata} object
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1296
     * representing image metadata, or {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1297
     * @param thumbnails a {@code List} of
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1298
     * {@code BufferedImage} thumbnails for this image, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1299
     * {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1300
     * @param param an {@code ImageWriteParam}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1301
     * {@code null} to use a default
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1302
     * {@code ImageWriteParam}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
     * @exception UnsupportedOperationException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1307
     * {@code canInsertEmpty(imageIndex)} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1308
     * {@code false}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1309
     * @exception IndexOutOfBoundsException if {@code imageIndex}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
     * is less than -1 or greater than the largest available index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
     * @exception IllegalStateException if a previous call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1312
     * {@code prepareInsertEmpty} has been made without a
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1313
     * corresponding call to {@code endInsertEmpty}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
     * @exception IllegalStateException if a previous call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1315
     * {@code prepareWriteEmpty} has been made without a
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1316
     * corresponding call to {@code endWriteEmpty}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1317
     * @exception IllegalArgumentException if {@code imageType}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1318
     * is {@code null} or {@code thumbnails} contains
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1319
     * {@code null} references or objects other than
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1320
     * {@code BufferedImage}s.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
     * @exception IllegalArgumentException if width or height are less
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
     * than 1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
     * @exception IOException if an I/O error occurs during writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
    public void prepareInsertEmpty(int imageIndex,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
                                   ImageTypeSpecifier imageType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
                                   int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
                                   IIOMetadata imageMetadata,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
                                   List<? extends BufferedImage> thumbnails,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
                                   ImageWriteParam param) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
        unsupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
     * Completes the insertion of a new image that was begun with a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1336
     * prior call to {@code prepareInsertEmpty}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1339
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1340
     * {@code null}, and otherwise throws an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1341
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
     * @exception UnsupportedOperationException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1346
     * {@code canInsertEmpty(imageIndex)} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1347
     * {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
     * @exception IllegalStateException if a previous call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1349
     * {@code prepareInsertEmpty} without a corresponding call to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1350
     * {@code endInsertEmpty} has not been made.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
     * @exception IllegalStateException if a previous call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1352
     * {@code prepareWriteEmpty} without a corresponding call to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1353
     * {@code endWriteEmpty} has been made.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
     * @exception IllegalStateException if a call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1355
     * {@code prepareReplacePixels} has been made without a
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1356
     * matching call to {@code endReplacePixels}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
     * @exception IOException if an I/O error occurs during writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
    public void endInsertEmpty() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
        unsupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
    // Pixel replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1366
     * Returns {@code true} if the writer allows pixels of the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1367
     * given image to be replaced using the {@code replacePixels}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
     * methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
     * <p> A writer that does not support any pixel replacement may
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1371
     * return {@code false} without performing bounds checking on
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
     * the index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1375
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1376
     * {@code null}, and otherwise returns {@code false}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1377
     * without checking the value of {@code imageIndex}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
     * @param imageIndex the index of the image whose pixels are to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
     * replaced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1382
     * @return {@code true} if the pixels of the given
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
     * image can be replaced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
     * @exception IllegalStateException if the output has not been
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
     * set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
     * @exception IndexOutOfBoundsException if the writer supports
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1388
     * pixel replacement in general, but {@code imageIndex} is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
     * less than 0 or greater than the largest available index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
     * @exception IOException if an I/O error occurs during the query.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
    public boolean canReplacePixels(int imageIndex) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
        if (getOutput() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
            throw new IllegalStateException("getOutput() == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
     * Prepares the writer to handle a series of calls to the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1401
     * {@code replacePixels} methods.  The affected pixel area
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
     * will be clipped against the supplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1404
     * <p> If {@code canReplacePixels} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1405
     * {@code false}, and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1406
     * {@code UnsupportedOperationException} will be thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1409
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1410
     * {@code null}, and otherwise throws an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1411
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
     * @param imageIndex the index of the image whose pixels are to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
     * replaced.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1415
     * @param region a {@code Rectangle} that will be used to clip
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
     * future pixel regions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
     * @exception UnsupportedOperationException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1421
     * {@code canReplacePixels(imageIndex)} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1422
     * {@code false}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1423
     * @exception IndexOutOfBoundsException if {@code imageIndex}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
     * is less than 0 or greater than the largest available index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
     * @exception IllegalStateException if there is a previous call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1426
     * {@code prepareReplacePixels} without a matching call to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1427
     * {@code endReplacePixels} (<i>i.e.</i>, nesting is not
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
     * allowed).
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1429
     * @exception IllegalArgumentException if {@code region} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1430
     * {@code null} or has a width or height less than 1.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
     * @exception IOException if an I/O error occurs during the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
     * preparation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
    public void prepareReplacePixels(int imageIndex,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
                                     Rectangle region)  throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
        unsupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
     * Replaces a portion of an image already present in the output
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
     * with a portion of the given image.  The image data must match,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
     * or be convertible to, the image layout of the existing image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
     * <p> The destination region is specified in the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1445
     * {@code param} argument, and will be clipped to the image
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
     * boundaries and the region supplied to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1447
     * {@code prepareReplacePixels}.  At least one pixel of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
     * source must not be clipped, or an exception is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1450
     * <p> An {@code ImageWriteParam} may optionally be supplied
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1451
     * to control the writing process.  If {@code param} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1452
     * {@code null}, a default write param will be used.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1454
     * <p> If the supplied {@code ImageWriteParam} contains
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
     * optional setting values not supported by this writer (<i>e.g.</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
     * progressive encoding or any format-specific settings), they
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
     * will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
     * <p> This method may only be called after a call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1460
     * {@code prepareReplacePixels}, or else an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1461
     * {@code IllegalStateException} will be thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1464
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1465
     * {@code null}, and otherwise throws an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1466
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1468
     * @param image a {@code RenderedImage} containing source
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
     * pixels.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1470
     * @param param an {@code ImageWriteParam}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1471
     * {@code null} to use a default
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1472
     * {@code ImageWriteParam}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
     * @exception UnsupportedOperationException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1477
     * {@code canReplacePixels(imageIndex)} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1478
     * {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
     * @exception IllegalStateException if there is no previous call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1480
     * {@code prepareReplacePixels} without a matching call to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1481
     * {@code endReplacePixels}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
     * @exception IllegalArgumentException if any of the following are true:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
     * <ul>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1484
     * <li> {@code image} is {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
     * <li> the intersected region does not contain at least one pixel.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1486
     * <li> the layout of {@code image} does not match, or this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
     * writer cannot convert it to, the existing image layout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
     * @exception IOException if an I/O error occurs during writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
    public void replacePixels(RenderedImage image, ImageWriteParam param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
        unsupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
     * Replaces a portion of an image already present in the output
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1498
     * with a portion of the given {@code Raster}.  The image
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
     * data must match, or be convertible to, the image layout of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
     * existing image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1502
     * <p> An {@code ImageWriteParam} may optionally be supplied
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1503
     * to control the writing process.  If {@code param} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1504
     * {@code null}, a default write param will be used.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
     * <p> The destination region is specified in the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1507
     * {@code param} argument, and will be clipped to the image
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
     * boundaries and the region supplied to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1509
     * {@code prepareReplacePixels}.  At least one pixel of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
     * source must not be clipped, or an exception is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1512
     * <p> If the supplied {@code ImageWriteParam} contains
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
     * optional setting values not supported by this writer (<i>e.g.</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
     * progressive encoding or any format-specific settings), they
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
     * will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
     * <p> This method may only be called after a call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1518
     * {@code prepareReplacePixels}, or else an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1519
     * {@code IllegalStateException} will be thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1522
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1523
     * {@code null}, and otherwise throws an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1524
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1526
     * @param raster a {@code Raster} containing source
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
     * pixels.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1528
     * @param param an {@code ImageWriteParam}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1529
     * {@code null} to use a default
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1530
     * {@code ImageWriteParam}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
     * @exception UnsupportedOperationException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1535
     * {@code canReplacePixels(imageIndex)} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1536
     * {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
     * @exception IllegalStateException if there is no previous call to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1538
     * {@code prepareReplacePixels} without a matching call to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1539
     * {@code endReplacePixels}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
     * @exception UnsupportedOperationException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1541
     * {@code canWriteRasters} returns {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
     * @exception IllegalArgumentException if any of the following are true:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
     * <ul>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1544
     * <li> {@code raster} is {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
     * <li> the intersected region does not contain at least one pixel.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1546
     * <li> the layout of {@code raster} does not match, or this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
     * writer cannot convert it to, the existing image layout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
     * @exception IOException if an I/O error occurs during writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
    public void replacePixels(Raster raster, ImageWriteParam param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
        unsupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1557
     * Terminates a sequence of calls to {@code replacePixels}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1559
     * <p> If {@code canReplacePixels} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1560
     * {@code false}, and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1561
     * {@code UnsupportedOperationException} will be thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
     * <p> The default implementation throws an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1564
     * {@code IllegalStateException} if the output is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1565
     * {@code null}, and otherwise throws an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1566
     * {@code UnsupportedOperationException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
     * @exception IllegalStateException if the output has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
     * been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
     * @exception UnsupportedOperationException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1571
     * {@code canReplacePixels(imageIndex)} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1572
     * {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
     * @exception IllegalStateException if there is no previous call
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1574
     * to {@code prepareReplacePixels} without a matching call to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1575
     * {@code endReplacePixels}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
     * @exception IOException if an I/O error occurs during writing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
    public void endReplacePixels() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
        unsupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
    // Abort
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
     * Requests that any current write operation be aborted.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
     * contents of the output following the abort will be undefined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1588
     * <p> Writers should call {@code clearAbortRequest} at the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
     * beginning of each write operation, and poll the value of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1590
     * {@code abortRequested} regularly during the write.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
    public synchronized void abort() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
        this.abortFlag = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1597
     * Returns {@code true} if a request to abort the current
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
     * write operation has been made since the writer was instantiated or
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1599
     * {@code clearAbortRequest} was called.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1601
     * @return {@code true} if the current write operation should
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
     * be aborted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
     * @see #abort
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
     * @see #clearAbortRequest
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
    protected synchronized boolean abortRequested() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
        return this.abortFlag;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
     * Clears any previous abort request.  After this method has been
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1613
     * called, {@code abortRequested} will return
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1614
     * {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
     * @see #abort
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
     * @see #abortRequested
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
    protected synchronized void clearAbortRequest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
        this.abortFlag = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
    // Listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1626
     * Adds an {@code IIOWriteWarningListener} to the list of
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1627
     * registered warning listeners.  If {@code listener} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1628
     * {@code null}, no exception will be thrown and no action
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
     * will be taken.  Messages sent to the given listener will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
     * localized, if possible, to match the current
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1631
     * {@code Locale}.  If no {@code Locale} has been set,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
     * warning messages may be localized as the writer sees fit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1634
     * @param listener an {@code IIOWriteWarningListener} to be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
     * registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
     * @see #removeIIOWriteWarningListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
    public void addIIOWriteWarningListener(IIOWriteWarningListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
        if (listener == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
        warningListeners = ImageReader.addToList(warningListeners, listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
        warningLocales = ImageReader.addToList(warningLocales, getLocale());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1648
     * Removes an {@code IIOWriteWarningListener} from the list
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
     * of registered warning listeners.  If the listener was not
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1650
     * previously registered, or if {@code listener} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1651
     * {@code null}, no exception will be thrown and no action
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
     * will be taken.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1654
     * @param listener an {@code IIOWriteWarningListener} to be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
     * deregistered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
     * @see #addIIOWriteWarningListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
    public
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
        void removeIIOWriteWarningListener(IIOWriteWarningListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
        if (listener == null || warningListeners == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
        int index = warningListeners.indexOf(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
        if (index != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
            warningListeners.remove(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
            warningLocales.remove(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
            if (warningListeners.size() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
                warningListeners = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
                warningLocales = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
     * Removes all currently registered
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1677
     * {@code IIOWriteWarningListener} objects.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
     * <p> The default implementation sets the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1680
     * {@code warningListeners} and {@code warningLocales}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1681
     * instance variables to {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
    public void removeAllIIOWriteWarningListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
        this.warningListeners = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
        this.warningLocales = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1689
     * Adds an {@code IIOWriteProgressListener} to the list of
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1690
     * registered progress listeners.  If {@code listener} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1691
     * {@code null}, no exception will be thrown and no action
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
     * will be taken.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1694
     * @param listener an {@code IIOWriteProgressListener} to be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
     * registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
     * @see #removeIIOWriteProgressListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
    public void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
        addIIOWriteProgressListener(IIOWriteProgressListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
        if (listener == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
        progressListeners = ImageReader.addToList(progressListeners, listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1708
     * Removes an {@code IIOWriteProgressListener} from the list
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
     * of registered progress listeners.  If the listener was not
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1710
     * previously registered, or if {@code listener} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1711
     * {@code null}, no exception will be thrown and no action
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
     * will be taken.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1714
     * @param listener an {@code IIOWriteProgressListener} to be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
     * deregistered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1717
     * @see #addIIOWriteProgressListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
    public void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
        removeIIOWriteProgressListener(IIOWriteProgressListener listener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
        if (listener == null || progressListeners == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
        progressListeners =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
            ImageReader.removeFromList(progressListeners, listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
     * Removes all currently registered
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1730
     * {@code IIOWriteProgressListener} objects.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
     * <p> The default implementation sets the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1733
     * {@code progressListeners} instance variable to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1734
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
    public void removeAllIIOWriteProgressListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
        this.progressListeners = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
     * Broadcasts the start of an image write to all registered
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1742
     * {@code IIOWriteProgressListener}s by calling their
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1743
     * {@code imageStarted} method.  Subclasses may use this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1744
     * method as a convenience.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1746
     * @param imageIndex the index of the image about to be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
    protected void processImageStarted(int imageIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
        if (progressListeners == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
        int numListeners = progressListeners.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
        for (int i = 0; i < numListeners; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
            IIOWriteProgressListener listener =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 22260
diff changeset
  1755
                progressListeners.get(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
            listener.imageStarted(this, imageIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
     * Broadcasts the current percentage of image completion to all
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1762
     * registered {@code IIOWriteProgressListener}s by calling
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1763
     * their {@code imageProgress} method.  Subclasses may use
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
     * this method as a convenience.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
     * @param percentageDone the current percentage of completion,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1767
     * as a {@code float}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
    protected void processImageProgress(float percentageDone) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
        if (progressListeners == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
        int numListeners = progressListeners.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
        for (int i = 0; i < numListeners; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1775
            IIOWriteProgressListener listener =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 22260
diff changeset
  1776
                progressListeners.get(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
            listener.imageProgress(this, percentageDone);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1780
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1781
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1782
     * Broadcasts the completion of an image write to all registered
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1783
     * {@code IIOWriteProgressListener}s by calling their
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1784
     * {@code imageComplete} method.  Subclasses may use this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1785
     * method as a convenience.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1786
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1787
    protected void processImageComplete() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
        if (progressListeners == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1789
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
        int numListeners = progressListeners.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1792
        for (int i = 0; i < numListeners; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
            IIOWriteProgressListener listener =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 22260
diff changeset
  1794
                progressListeners.get(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1795
            listener.imageComplete(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1796
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1797
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1799
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1800
     * Broadcasts the start of a thumbnail write to all registered
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1801
     * {@code IIOWriteProgressListener}s by calling their
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1802
     * {@code thumbnailStarted} method.  Subclasses may use this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1803
     * method as a convenience.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1804
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1805
     * @param imageIndex the index of the image associated with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1806
     * thumbnail.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1807
     * @param thumbnailIndex the index of the thumbnail.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1808
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1809
    protected void processThumbnailStarted(int imageIndex,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1810
                                           int thumbnailIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1811
        if (progressListeners == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1812
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1813
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
        int numListeners = progressListeners.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1815
        for (int i = 0; i < numListeners; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1816
            IIOWriteProgressListener listener =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 22260
diff changeset
  1817
                progressListeners.get(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1818
            listener.thumbnailStarted(this, imageIndex, thumbnailIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1819
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1820
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1821
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1822
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1823
     * Broadcasts the current percentage of thumbnail completion to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1824
     * all registered {@code IIOWriteProgressListener}s by calling
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1825
     * their {@code thumbnailProgress} method.  Subclasses may
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1826
     * use this method as a convenience.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1827
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1828
     * @param percentageDone the current percentage of completion,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1829
     * as a {@code float}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1830
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1831
    protected void processThumbnailProgress(float percentageDone) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1832
        if (progressListeners == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1833
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1835
        int numListeners = progressListeners.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1836
        for (int i = 0; i < numListeners; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1837
            IIOWriteProgressListener listener =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 22260
diff changeset
  1838
                progressListeners.get(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1839
            listener.thumbnailProgress(this, percentageDone);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1840
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1841
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1842
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1843
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1844
     * Broadcasts the completion of a thumbnail write to all registered
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1845
     * {@code IIOWriteProgressListener}s by calling their
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1846
     * {@code thumbnailComplete} method.  Subclasses may use this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1847
     * method as a convenience.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1848
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1849
    protected void processThumbnailComplete() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1850
        if (progressListeners == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1851
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1852
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1853
        int numListeners = progressListeners.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1854
        for (int i = 0; i < numListeners; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1855
            IIOWriteProgressListener listener =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 22260
diff changeset
  1856
                progressListeners.get(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1857
            listener.thumbnailComplete(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1858
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1859
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1860
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1861
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1862
     * Broadcasts that the write has been aborted to all registered
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1863
     * {@code IIOWriteProgressListener}s by calling their
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1864
     * {@code writeAborted} method.  Subclasses may use this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1865
     * method as a convenience.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1866
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1867
    protected void processWriteAborted() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1868
        if (progressListeners == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1869
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1870
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1871
        int numListeners = progressListeners.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1872
        for (int i = 0; i < numListeners; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1873
            IIOWriteProgressListener listener =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 22260
diff changeset
  1874
                progressListeners.get(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1875
            listener.writeAborted(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1876
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1877
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1878
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1879
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1880
     * Broadcasts a warning message to all registered
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1881
     * {@code IIOWriteWarningListener}s by calling their
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1882
     * {@code warningOccurred} method.  Subclasses may use this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1883
     * method as a convenience.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1884
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1885
     * @param imageIndex the index of the image on which the warning
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1886
     * occurred.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1887
     * @param warning the warning message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1888
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1889
     * @exception IllegalArgumentException if {@code warning}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1890
     * is {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1891
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1892
    protected void processWarningOccurred(int imageIndex,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1893
                                          String warning) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1894
        if (warningListeners == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1895
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1896
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1897
        if (warning == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1898
            throw new IllegalArgumentException("warning == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1899
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1900
        int numListeners = warningListeners.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1901
        for (int i = 0; i < numListeners; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1902
            IIOWriteWarningListener listener =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 22260
diff changeset
  1903
                warningListeners.get(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1904
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1905
            listener.warningOccurred(this, imageIndex, warning);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1906
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1907
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1908
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1909
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1910
     * Broadcasts a localized warning message to all registered
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1911
     * {@code IIOWriteWarningListener}s by calling their
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1912
     * {@code warningOccurred} method with a string taken
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1913
     * from a {@code ResourceBundle}.  Subclasses may use this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1914
     * method as a convenience.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1915
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1916
     * @param imageIndex the index of the image on which the warning
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1917
     * occurred.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1918
     * @param baseName the base name of a set of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1919
     * {@code ResourceBundle}s containing localized warning
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1920
     * messages.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1921
     * @param keyword the keyword used to index the warning message
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1922
     * within the set of {@code ResourceBundle}s.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1923
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1924
     * @exception IllegalArgumentException if {@code baseName}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1925
     * is {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1926
     * @exception IllegalArgumentException if {@code keyword}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1927
     * is {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1928
     * @exception IllegalArgumentException if no appropriate
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1929
     * {@code ResourceBundle} may be located.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1930
     * @exception IllegalArgumentException if the named resource is
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1931
     * not found in the located {@code ResourceBundle}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1932
     * @exception IllegalArgumentException if the object retrieved
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1933
     * from the {@code ResourceBundle} is not a
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  1934
     * {@code String}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1935
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1936
    protected void processWarningOccurred(int imageIndex,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1937
                                          String baseName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1938
                                          String keyword) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1939
        if (warningListeners == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1940
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1941
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1942
        if (baseName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1943
            throw new IllegalArgumentException("baseName == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1944
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1945
        if (keyword == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1946
            throw new IllegalArgumentException("keyword == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1947
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1948
        int numListeners = warningListeners.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1949
        for (int i = 0; i < numListeners; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1950
            IIOWriteWarningListener listener =
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 22260
diff changeset
  1951
                warningListeners.get(i);
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 22260
diff changeset
  1952
            Locale locale = warningLocales.get(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1953
            if (locale == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1954
                locale = Locale.getDefault();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1955
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1956
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1957
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1958
             * If an applet supplies an implementation of ImageWriter and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1959
             * resource bundles, then the resource bundle will need to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1960
             * accessed via the applet class loader. So first try the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1961
             * class loader to locate the resource bundle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1962
             * If that throws MissingResourceException, then try the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1963
             * system class loader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1964
             */
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22584
diff changeset
  1965
            ClassLoader loader =
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1966
                java.security.AccessController.doPrivileged(
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22584
diff changeset
  1967
                   new java.security.PrivilegedAction<ClassLoader>() {
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22584
diff changeset
  1968
                      public ClassLoader run() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1969
                        return Thread.currentThread().getContextClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1970
                      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1971
                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1972
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1973
            ResourceBundle bundle = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1974
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1975
                bundle = ResourceBundle.getBundle(baseName, locale, loader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1976
            } catch (MissingResourceException mre) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1977
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1978
                    bundle = ResourceBundle.getBundle(baseName, locale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1979
                } catch (MissingResourceException mre1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1980
                    throw new IllegalArgumentException("Bundle not found!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1981
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1982
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1983
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1984
            String warning = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1985
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1986
                warning = bundle.getString(keyword);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1987
            } catch (ClassCastException cce) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1988
                throw new IllegalArgumentException("Resource is not a String!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1989
            } catch (MissingResourceException mre) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1990
                throw new IllegalArgumentException("Resource is missing!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1991
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1992
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1993
            listener.warningOccurred(this, imageIndex, warning);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1994
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1995
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1996
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1997
    // State management
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1998
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1999
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  2000
     * Restores the {@code ImageWriter} to its initial state.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2001
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2002
     * <p> The default implementation calls
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  2003
     * {@code setOutput(null)}, {@code setLocale(null)},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  2004
     * {@code removeAllIIOWriteWarningListeners()},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  2005
     * {@code removeAllIIOWriteProgressListeners()}, and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  2006
     * {@code clearAbortRequest}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2007
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2008
    public void reset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2009
        setOutput(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2010
        setLocale(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2011
        removeAllIIOWriteWarningListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2012
        removeAllIIOWriteProgressListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2013
        clearAbortRequest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2014
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2015
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2016
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2017
     * Allows any resources held by this object to be released.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2018
     * result of calling any other method (other than
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  2019
     * {@code finalize}) subsequent to a call to this method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2020
     * is undefined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2021
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2022
     * <p>It is important for applications to call this method when they
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
  2023
     * know they will no longer be using this {@code ImageWriter}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2024
     * Otherwise, the writer may continue to hold on to resources
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2025
     * indefinitely.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2026
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2027
     * <p>The default implementation of this method in the superclass does
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2028
     * nothing.  Subclass implementations should ensure that all resources,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2029
     * especially native resources, are released.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2030
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2031
    public void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2032
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2033
}