info.magnolia.imaging.operations.cropresize
Class AbstractCropAndResize<P extends ParameterProvider<?>>

java.lang.Object
  extended by info.magnolia.imaging.operations.cropresize.AbstractCropAndResize<P>
Type Parameters:
P - type of ParameterProvider
All Implemented Interfaces:
ImageOperation<P>
Direct Known Subclasses:
AutoCropAndResize, BoundedResize, SelectedCropAndResize

public abstract class AbstractCropAndResize<P extends ParameterProvider<?>>
extends Object
implements ImageOperation<P>

Subclasses of this determine which portion of the source image is taken into account, and what final dimensions the image needs to be resized to.

Version:
$Id$

Constructor Summary
AbstractCropAndResize()
           
 
Method Summary
 BufferedImage apply(BufferedImage source, P params)
           
protected abstract  Coords getCroopCoords(BufferedImage source, P params)
          Determines the coordinates of the cropping to apply on the source image.
protected abstract  Size getEffectiveTargetSize(BufferedImage source, Coords cropCoords, P params)
          Determines the actual size for the resized image based on the source image, the crop coordinates calculated by getCroopCoords(java.awt.image.BufferedImage, P) and the given ParameterProvider.
 Resizer getResizer()
           
protected  BufferedImage resize(BufferedImage src, Coords srcCoords, Size targetSize)
           
 void setResizer(Resizer resizer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCropAndResize

public AbstractCropAndResize()
Method Detail

apply

public BufferedImage apply(BufferedImage source,
                           P params)
                    throws ImagingException
Specified by:
apply in interface ImageOperation<P extends ParameterProvider<?>>
Throws:
ImagingException

getCroopCoords

protected abstract Coords getCroopCoords(BufferedImage source,
                                         P params)
                                  throws ImagingException
Determines the coordinates of the cropping to apply on the source image. If no cropping needs to happen, return new Coords(0, 0, source.getWidth(), source.getHeight()).

Throws:
ImagingException

getEffectiveTargetSize

protected abstract Size getEffectiveTargetSize(BufferedImage source,
                                               Coords cropCoords,
                                               P params)
Determines the actual size for the resized image based on the source image, the crop coordinates calculated by getCroopCoords(java.awt.image.BufferedImage, P) and the given ParameterProvider.


resize

protected BufferedImage resize(BufferedImage src,
                               Coords srcCoords,
                               Size targetSize)

getResizer

public Resizer getResizer()

setResizer

public void setResizer(Resizer resizer)


Copyright © 2013 Magnolia International Ltd.. All Rights Reserved.