Class ThumbnailMaker

    • Field Detail

      • NOT_READY_FOR_MAKE

        private static final java.lang.String NOT_READY_FOR_MAKE
        String used for an exception message.
        See Also:
        Constant Field Values
      • PARAM_IMAGE_TYPE

        private static final java.lang.String PARAM_IMAGE_TYPE
        Used when determining whether the "imageType" parameter has been set already or not.
        See Also:
        Constant Field Values
      • PARAM_RESIZER

        private static final java.lang.String PARAM_RESIZER
        Used when determining whether the "resizer" parameter has been set already or not.
        See Also:
        Constant Field Values
      • PARAM_RESIZERFACTORY

        private static final java.lang.String PARAM_RESIZERFACTORY
        Used when determining whether the "resizerFactory" parameter has been set already or not.
        See Also:
        Constant Field Values
      • ready

        protected final ThumbnailMaker.ReadinessTracker ready
        Object used to keep track whether the required parameters for creating a thumbnail has been set.
      • imageType

        protected int imageType
        The image type of the resulting thumbnail.
      • resizerFactory

        protected ResizerFactory resizerFactory
        The ResizerFactory which is used to obtain a Resizer for the resizing operation.

        By delaying the decision of picking the Resizer to use until when the thumbnail is to be created could lead to a more suitable Resizer being picked, as the dimensions for the source and destination images are known at that time.

    • Constructor Detail

      • ThumbnailMaker

        public ThumbnailMaker()
        Creates and initializes an instance of ThumbnailMaker.
    • Method Detail

      • make

        public abstract java.awt.image.BufferedImage make​(java.awt.image.BufferedImage img)
        Makes a thumbnail.
        Parameters:
        img - The source image.
        Returns:
        The thumbnail created from the source image, using the parameters set by the ThumbnailMaker.
      • makeThumbnail

        protected java.awt.image.BufferedImage makeThumbnail​(java.awt.image.BufferedImage img,
                                                             int width,
                                                             int height)
        Makes a thumbnail of the specified dimensions, from the specified source image.
        Parameters:
        img - The source image.
        width - The target width of the thumbnail.
        height - The target height of the thumbnail.
        Returns:
        The thumbnail image.
        Throws:
        java.lang.IllegalStateException - If the ThumbnailMaker is not ready to create thumbnails.
        java.lang.IllegalArgumentException - If the width and/or height is less than or equal to zero.
      • imageType

        public ThumbnailMaker imageType​(int imageType)
        Sets the type for the BufferedImage to produce.
        Parameters:
        imageType - The type of the BufferedImage.
        Returns:
        A reference to this object.
      • defaultImageType

        public ThumbnailMaker defaultImageType()
        Sets the type of the BufferedImage to be the default type.
        Returns:
        A reference to this object.
      • resizer

        public ThumbnailMaker resizer​(Resizer resizer)
        Sets the Resizer which is used for the resizing operation.
        Parameters:
        resizer - The Resizer to use when resizing the image to create the thumbnail.
        Returns:
        A reference to this object.
      • resizerFactory

        public ThumbnailMaker resizerFactory​(ResizerFactory resizerFactory)
        Sets the ResizerFactory which is used to obtain a Resizer for the resizing operation.
        Parameters:
        resizerFactory - The ResizerFactory to obtain the Resizer used when resizing the image to create the thumbnail.
        Returns:
        A reference to this object.
        Since:
        0.4.0