Package net.coobird.thumbnailator.tasks
Class ThumbnailTask<S,D>
- java.lang.Object
-
- net.coobird.thumbnailator.tasks.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.ObjectThis class is used byThumbnailTaskimplementations which is used when creating thumbnails from external sources and destinations.If the image handled by a
ThumbnailTaskcontains multiple images, only the first image will be read by theread()method. Any subsequent images will be ignored.
-
-
Field Summary
Fields Modifier and Type Field Description protected static intFIRST_IMAGE_INDEXConstant used to obtain the first image when reading an image file.protected java.lang.StringinputFormatNameString indicating the image format of the input image.protected ThumbnailParameterparamThe parameters to use when creating a thumbnail.
-
Constructor Summary
Constructors Modifier Constructor Description protectedThumbnailTask(ThumbnailParameter param)Instantiates aThumbnailTaskwith the parameters to use when creating thumbnails.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract DgetDestination()Returns the destination to which the thumbnail is stored or written.ThumbnailParametergetParam()Returns theThumbnailParameterfor thisThumbnailTask, used when performing a thumbnail generation operation.abstract SgetSource()Returns the source from which the source image is retrieved or read.abstract java.awt.image.BufferedImageread()Reads a source image.abstract voidwrite(java.awt.image.BufferedImage img)Writes the thumbnail to the destination.
-
-
-
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 aThumbnailTaskwith the parameters to use when creating thumbnails.- Parameters:
param- The parameters to use when creating thumbnails.- Throws:
java.lang.NullPointerException- If the parameter isnull.
-
-
Method Detail
-
read
public abstract java.awt.image.BufferedImage read() throws java.io.IOExceptionReads 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.IOExceptionWrites 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.
-
getParam
public ThumbnailParameter getParam()
Returns theThumbnailParameterfor thisThumbnailTask, used when performing a thumbnail generation operation.- Returns:
- The parameters to use when generating thumbnails.
-
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.
-
-