Package net.coobird.thumbnailator.makers
Class ThumbnailMaker
- java.lang.Object
-
- net.coobird.thumbnailator.makers.ThumbnailMaker
-
- Direct Known Subclasses:
FixedSizeThumbnailMaker,ScaledThumbnailMaker
public abstract class ThumbnailMaker extends java.lang.ObjectAn abstract class which provides support functionalities forThumbnailMakerimplementations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classThumbnailMaker.ReadinessTrackerClass which keeps track of the parameters being set for theThumbnailMaker.
-
Field Summary
Fields Modifier and Type Field Description private static intDEFAULT_IMAGE_TYPEDefault image type of the thumbnails created byThumbnailMaker.protected intimageTypeThe image type of the resulting thumbnail.private static java.lang.StringNOT_READY_FOR_MAKEString used for an exception message.private static java.lang.StringPARAM_IMAGE_TYPEUsed when determining whether the "imageType" parameter has been set already or not.private static java.lang.StringPARAM_RESIZERUsed when determining whether the "resizer" parameter has been set already or not.private static java.lang.StringPARAM_RESIZERFACTORYUsed when determining whether the "resizerFactory" parameter has been set already or not.protected ThumbnailMaker.ReadinessTrackerreadyObject used to keep track whether the required parameters for creating a thumbnail has been set.protected ResizerFactoryresizerFactoryTheResizerFactorywhich is used to obtain aResizerfor the resizing operation.
-
Constructor Summary
Constructors Constructor Description ThumbnailMaker()Creates and initializes an instance ofThumbnailMaker.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ThumbnailMakerdefaultImageType()Sets the type of theBufferedImageto be the default type.ThumbnailMakerdefaultResizer()ThumbnailMakerdefaultResizerFactory()Sets theResizerFactoryto useDefaultResizerFactory.ThumbnailMakerimageType(int imageType)Sets the type for theBufferedImageto produce.abstract java.awt.image.BufferedImagemake(java.awt.image.BufferedImage img)Makes a thumbnail.protected java.awt.image.BufferedImagemakeThumbnail(java.awt.image.BufferedImage img, int width, int height)Makes a thumbnail of the specified dimensions, from the specified source image.ThumbnailMakerresizer(Resizer resizer)Sets theResizerwhich is used for the resizing operation.ThumbnailMakerresizerFactory(ResizerFactory resizerFactory)Sets theResizerFactorywhich is used to obtain aResizerfor the resizing operation.
-
-
-
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.
-
DEFAULT_IMAGE_TYPE
private static final int DEFAULT_IMAGE_TYPE
Default image type of the thumbnails created byThumbnailMaker.- See Also:
- Constant Field Values
-
imageType
protected int imageType
The image type of the resulting thumbnail.
-
resizerFactory
protected ResizerFactory resizerFactory
TheResizerFactorywhich is used to obtain aResizerfor the resizing operation.By delaying the decision of picking the
Resizerto use until when the thumbnail is to be created could lead to a more suitableResizerbeing 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 ofThumbnailMaker.
-
-
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 theThumbnailMakeris 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 theBufferedImageto produce.- Parameters:
imageType- The type of theBufferedImage.- Returns:
- A reference to this object.
-
defaultImageType
public ThumbnailMaker defaultImageType()
Sets the type of theBufferedImageto be the default type.- Returns:
- A reference to this object.
-
resizer
public ThumbnailMaker resizer(Resizer resizer)
Sets theResizerwhich is used for the resizing operation.- Parameters:
resizer- TheResizerto use when resizing the image to create the thumbnail.- Returns:
- A reference to this object.
-
defaultResizer
public ThumbnailMaker defaultResizer()
- Returns:
- A reference to this object.
-
resizerFactory
public ThumbnailMaker resizerFactory(ResizerFactory resizerFactory)
Sets theResizerFactorywhich is used to obtain aResizerfor the resizing operation.- Parameters:
resizerFactory- TheResizerFactoryto obtain theResizerused when resizing the image to create the thumbnail.- Returns:
- A reference to this object.
- Since:
- 0.4.0
-
defaultResizerFactory
public ThumbnailMaker defaultResizerFactory()
Sets theResizerFactoryto useDefaultResizerFactory.- Returns:
- A reference to this object.
- Since:
- 0.4.0
-
-