Example usage for javafx.scene.image Image getException

List of usage examples for javafx.scene.image Image getException

Introduction

In this page you can find the example usage for javafx.scene.image Image getException.

Prototype

public final Exception getException() 

Source Link

Usage

From source file:org.sleuthkit.autopsy.imageanalyzer.ThumbnailCache.java

/**
 * generate a new thumbnail for the given file and save it to the disk cache
 *
 * @param file/*from   w w w  .  j a  v  a2  s. com*/
 *
 * @return the newly generated thumbnail {@link Image}, or {@code null} if a
 *         thumbnail could not be generated
 */
private Image generateAndSaveThumbnail(final DrawableFile<?> file) {
    //create a buffered input stream for the underlying Abstractfile
    try (InputStream inputStream = new BufferedInputStream(
            new ReadContentInputStream(file.getAbstractFile()))) {
        final Image thumbnail = new Image(inputStream, MAX_ICON_SIZE, MAX_ICON_SIZE, true, true);
        if (thumbnail.isError()) { //if there was an error loading the image via JFX, fall back on Swing
            LOGGER.log(Level.WARNING, "problem loading image: " + file.getName() + " .",
                    thumbnail.getException());
            return fallbackToSwingImage(file);
        } else { //if the load went successfully, save the thumbnail to disk on a background thread
            imageSaver.execute(() -> {
                saveIcon(file, thumbnail);
            });
            return thumbnail;
        }
    } catch (IOException ex) {
        //if the JX load throws an exception fall back to Swing
        return fallbackToSwingImage(file);
    }
}