Class ThumbnailTask<S,​D>

  • Type Parameters:
    S - The class from which the image is retrieved or read.
    D - The class to which the thumbnail is stored or written.
    Direct Known Subclasses:
    FileThumbnailTask, SourceSinkThumbnailTask, StreamThumbnailTask

    public abstract class ThumbnailTask<S,​D>
    extends java.lang.Object
    This class is used by ThumbnailTask implementations which is used when creating thumbnails from external sources and destinations.

    If the image handled by a ThumbnailTask contains multiple images, only the first image will be read by the read() method. Any subsequent images will be ignored.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static int FIRST_IMAGE_INDEX
      Constant used to obtain the first image when reading an image file.
      protected java.lang.String inputFormatName
      String indicating the image format of the input image.
      protected ThumbnailParameter param
      The parameters to use when creating a thumbnail.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract D getDestination()
      Returns the destination to which the thumbnail is stored or written.
      ThumbnailParameter getParam()
      Returns the ThumbnailParameter for this ThumbnailTask, used when performing a thumbnail generation operation.
      abstract S getSource()
      Returns the source from which the source image is retrieved or read.
      abstract java.awt.image.BufferedImage read()
      Reads a source image.
      abstract void write​(java.awt.image.BufferedImage img)
      Writes the thumbnail to the destination.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • param

        protected final ThumbnailParameter param
        The parameters to use when creating a thumbnail.
      • inputFormatName

        protected java.lang.String inputFormatName
        String indicating the image format of the input image.

        To be used for situtions where the output image format should be the same as the input image format.

      • FIRST_IMAGE_INDEX

        protected static final int FIRST_IMAGE_INDEX
        Constant used to obtain the first image when reading an image file.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ThumbnailTask

        protected ThumbnailTask​(ThumbnailParameter param)
        Instantiates a ThumbnailTask with the parameters to use when creating thumbnails.
        Parameters:
        param - The parameters to use when creating thumbnails.
        Throws:
        java.lang.NullPointerException - If the parameter is null.
    • Method Detail

      • read

        public abstract java.awt.image.BufferedImage read()
                                                   throws java.io.IOException
        Reads a source image.
        Returns:
        The image which was obtained from the source.
        Throws:
        java.io.IOException - Thrown when an I/O problem occurs when reading from the image source.
      • write

        public abstract void write​(java.awt.image.BufferedImage img)
                            throws java.io.IOException
        Writes the thumbnail to the destination.
        Parameters:
        img - The image to write.
        Throws:
        UnsupportedFormatException - When an image file which is to be read or written is unsupported.
        java.io.IOException - Thrown when an I/O problem occurs when writing the image.
      • getSource

        public abstract S getSource()
        Returns the source from which the source image is retrieved or read.
        Returns:
        The source.
      • getDestination

        public abstract D getDestination()
        Returns the destination to which the thumbnail is stored or written.
        Returns:
        The destination.