Search in sources :

Example 6 with IIOReadProgressListener

use of javax.imageio.event.IIOReadProgressListener in project jdk8u_jdk by JetBrains.

the class ImageReader method processImageProgress.

/**
     * Broadcasts the current percentage of image completion to all
     * registered <code>IIOReadProgressListener</code>s by calling
     * their <code>imageProgress</code> method.  Subclasses may use
     * this method as a convenience.
     *
     * @param percentageDone the current percentage of completion,
     * as a <code>float</code>.
     */
protected void processImageProgress(float percentageDone) {
    if (progressListeners == null) {
        return;
    }
    int numListeners = progressListeners.size();
    for (int i = 0; i < numListeners; i++) {
        IIOReadProgressListener listener = (IIOReadProgressListener) progressListeners.get(i);
        listener.imageProgress(this, percentageDone);
    }
}
Also used : IIOReadProgressListener(javax.imageio.event.IIOReadProgressListener) Point(java.awt.Point)

Example 7 with IIOReadProgressListener

use of javax.imageio.event.IIOReadProgressListener in project jdk8u_jdk by JetBrains.

the class ImageReader method processImageComplete.

/**
     * Broadcasts the completion of an image read to all registered
     * <code>IIOReadProgressListener</code>s by calling their
     * <code>imageComplete</code> method.  Subclasses may use this
     * method as a convenience.
     */
protected void processImageComplete() {
    if (progressListeners == null) {
        return;
    }
    int numListeners = progressListeners.size();
    for (int i = 0; i < numListeners; i++) {
        IIOReadProgressListener listener = (IIOReadProgressListener) progressListeners.get(i);
        listener.imageComplete(this);
    }
}
Also used : IIOReadProgressListener(javax.imageio.event.IIOReadProgressListener) Point(java.awt.Point)

Example 8 with IIOReadProgressListener

use of javax.imageio.event.IIOReadProgressListener in project jdk8u_jdk by JetBrains.

the class ImageReader method processThumbnailStarted.

/**
     * Broadcasts the start of a thumbnail read to all registered
     * <code>IIOReadProgressListener</code>s by calling their
     * <code>thumbnailStarted</code> method.  Subclasses may use this
     * method as a convenience.
     *
     * @param imageIndex the index of the image associated with the
     * thumbnail.
     * @param thumbnailIndex the index of the thumbnail.
     */
protected void processThumbnailStarted(int imageIndex, int thumbnailIndex) {
    if (progressListeners == null) {
        return;
    }
    int numListeners = progressListeners.size();
    for (int i = 0; i < numListeners; i++) {
        IIOReadProgressListener listener = (IIOReadProgressListener) progressListeners.get(i);
        listener.thumbnailStarted(this, imageIndex, thumbnailIndex);
    }
}
Also used : IIOReadProgressListener(javax.imageio.event.IIOReadProgressListener) Point(java.awt.Point)

Example 9 with IIOReadProgressListener

use of javax.imageio.event.IIOReadProgressListener in project jdk8u_jdk by JetBrains.

the class ImageReader method processReadAborted.

/**
     * Broadcasts that the read has been aborted to all registered
     * <code>IIOReadProgressListener</code>s by calling their
     * <code>readAborted</code> method.  Subclasses may use this
     * method as a convenience.
     */
protected void processReadAborted() {
    if (progressListeners == null) {
        return;
    }
    int numListeners = progressListeners.size();
    for (int i = 0; i < numListeners; i++) {
        IIOReadProgressListener listener = (IIOReadProgressListener) progressListeners.get(i);
        listener.readAborted(this);
    }
}
Also used : IIOReadProgressListener(javax.imageio.event.IIOReadProgressListener) Point(java.awt.Point)

Example 10 with IIOReadProgressListener

use of javax.imageio.event.IIOReadProgressListener in project imageio-ext by geosolutions-it.

the class ImageReadMTCRIF method getImageReader.

/**
 * Get the <code>ImageReader</code> and set its input and metadata flag.
 * The input set on the reader might not be the same object as the input
 * passed in if the latter was replaced by getImageInputStream().
 */
static ImageReader getImageReader(ParameterBlock pb) {
    // Get the input.
    Object input = pb.getObjectParameter(0);
    // Get the reader parameter.
    ImageReader reader = (ImageReader) pb.getObjectParameter(8);
    // Attempt to create an ImageInputStream from the input.
    ImageInputStream stream = getImageInputStream(input);
    // If no reader passed in, try to find one.
    if (reader == null) {
        // Get all compatible readers.
        Iterator readers = ImageIO.getImageReaders(stream != null ? stream : input);
        // service provider indicates that it can decode the input.
        if (readers != null && readers.hasNext()) {
            do {
                ImageReader tmpReader = (ImageReader) readers.next();
                ImageReaderSpi readerSpi = tmpReader.getOriginatingProvider();
                try {
                    if (readerSpi.canDecodeInput(stream != null ? stream : input)) {
                        reader = tmpReader;
                    }
                } catch (IOException ioe) {
                // XXX Ignore it?
                }
            } while (reader == null && readers.hasNext());
        }
    }
    // If reader found, set its input and metadata flag.
    if (reader != null) {
        // Get the locale parameter and set on the reader.
        Locale locale = (Locale) pb.getObjectParameter(6);
        if (locale != null) {
            reader.setLocale(locale);
        }
        // Get the listeners parameter and set on the reader.
        EventListener[] listeners = (EventListener[]) pb.getObjectParameter(5);
        if (listeners != null) {
            for (int i = 0; i < listeners.length; i++) {
                EventListener listener = listeners[i];
                if (listener instanceof IIOReadProgressListener) {
                    reader.addIIOReadProgressListener((IIOReadProgressListener) listener);
                }
                if (listener instanceof IIOReadUpdateListener) {
                    reader.addIIOReadUpdateListener((IIOReadUpdateListener) listener);
                }
                if (listener instanceof IIOReadWarningListener) {
                    reader.addIIOReadWarningListener((IIOReadWarningListener) listener);
                }
            }
        }
        // Get the metadata reading flag.
        boolean readMetadata = ((Boolean) pb.getObjectParameter(2)).booleanValue();
        // Set the input and indicate metadata reading state.
        // seekForwardOnly
        reader.setInput(// seekForwardOnly
        stream != null ? stream : input, // seekForwardOnly
        false, // ignoreMetadata
        !readMetadata);
    }
    return reader;
}
Also used : Locale(java.util.Locale) IIOReadWarningListener(javax.imageio.event.IIOReadWarningListener) ImageInputStream(javax.imageio.stream.ImageInputStream) IIOReadProgressListener(javax.imageio.event.IIOReadProgressListener) IOException(java.io.IOException) IIOReadUpdateListener(javax.imageio.event.IIOReadUpdateListener) ImageReaderSpi(javax.imageio.spi.ImageReaderSpi) Iterator(java.util.Iterator) EventListener(java.util.EventListener) ImageReader(javax.imageio.ImageReader)

Aggregations

IIOReadProgressListener (javax.imageio.event.IIOReadProgressListener)10 Point (java.awt.Point)9 IOException (java.io.IOException)1 EventListener (java.util.EventListener)1 Iterator (java.util.Iterator)1 Locale (java.util.Locale)1 ImageReader (javax.imageio.ImageReader)1 IIOReadUpdateListener (javax.imageio.event.IIOReadUpdateListener)1 IIOReadWarningListener (javax.imageio.event.IIOReadWarningListener)1 ImageReaderSpi (javax.imageio.spi.ImageReaderSpi)1 ImageInputStream (javax.imageio.stream.ImageInputStream)1