net.coobird.thumbnailator.resizers
Class DefaultResizerFactory

java.lang.Object
  extended by net.coobird.thumbnailator.resizers.DefaultResizerFactory
All Implemented Interfaces:
ResizerFactory

public class DefaultResizerFactory
extends Object
implements ResizerFactory

This class provides factory methods which provides suitable Resizers for a given situation.

Resizers returned by this ResizerFactory:
The Resizers returned by this ResizerFactory depends upon the size of the source and destination images. The conditions and the Resizers returned are as follows:
Usage:
The following example code demonstrates how to use DefaultResizerFactory in order to obtain the optimal Resizer, and using that in order to perform the resizing operation.

BufferedImage sourceImage = new BufferedImageBuilder(400, 400).build();
BufferedImage destImage = new BufferedImageBuilder(200, 200).build();

Dimension sourceSize = new Dimension(sourceImage.getWidth(), sourceImage.getHeight());
Dimension destSize = new Dimension(destImage.getWidth(), destImage.getHeight());

// Obtain the optimal Resizer for this resizing operation.
Resizer resizer = DefaultResizerFactory.getInstance().getResizer(sourceSize, destSize);

// Perform the resizing using the Resizer obtained from the ResizerFactory.
resizer.resize(sourceImage, destImage);
 
When a specific Resizer is required, the Resizers enum is another way to obtain Resizers.

Since:
0.4.0
Author:
coobird
See Also:
Resizers

Method Summary
static ResizerFactory getInstance()
          Returns an instance of this class.
 Resizer getResizer()
          Returns the default Resizer.
 Resizer getResizer(Dimension originalSize, Dimension thumbnailSize)
          Returns a suitable Resizer, given the Dimensions of the original image and the thumbnail image.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ResizerFactory getInstance()
Returns an instance of this class.

Returns:
An instance of this class.

getResizer

public Resizer getResizer()
Description copied from interface: ResizerFactory
Returns the default Resizer.

Specified by:
getResizer in interface ResizerFactory
Returns:
The default Resizer.

getResizer

public Resizer getResizer(Dimension originalSize,
                          Dimension thumbnailSize)
Description copied from interface: ResizerFactory
Returns a suitable Resizer, given the Dimensions of the original image and the thumbnail image.

Specified by:
getResizer in interface ResizerFactory
Parameters:
originalSize - The size of the original image.
thumbnailSize - The size of the thumbnail.
Returns:
The suitable Resizer to perform the resizing operation for the given condition.


Copyright © 2014. All rights reserved.