public class DefaultGalleryProcessor extends Object implements GalleryProcessor
Modifier and Type | Class and Description |
---|---|
static class |
DefaultGalleryProcessor.UnsupportedMimeTypeException |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_THUMBNAIL_SIZE |
Constructor and Description |
---|
DefaultGalleryProcessor() |
Modifier and Type | Method and Description |
---|---|
InputStream |
createThumbnail(InputStream imageData,
int maxSize,
String mimeType)
Creates a thumbnail version of an image.
|
Dimension |
getDesiredResourceDimension(javax.jcr.Node node) |
BufferedImage |
getScaledInstance(BufferedImage img,
int targetWidth,
int targetHeight,
Object hint,
boolean higherQuality)
Convenience method that returns a scaled instance of the provided
BufferedImage . |
int |
getThumbnailSize() |
void |
initGalleryResource(javax.jcr.Node node,
InputStream data,
String mimeType,
String fileName,
Calendar lastModified) |
boolean |
isUpscalingEnabled(javax.jcr.Node node) |
void |
makeImage(javax.jcr.Node node,
InputStream istream,
String mimeType,
String fileName) |
protected void |
makeRegularImage(javax.jcr.Node node,
String name,
InputStream istream,
String mimeType,
Calendar lastModified) |
protected void |
makeThumbnailImage(javax.jcr.Node node,
InputStream resourceData,
String mimeType) |
void |
setThumbnailSize(int thumbnailSize) |
void |
validateResource(javax.jcr.Node node,
String fileName) |
public static final int DEFAULT_THUMBNAIL_SIZE
public void setThumbnailSize(int thumbnailSize)
public int getThumbnailSize()
public InputStream createThumbnail(InputStream imageData, int maxSize, String mimeType) throws GalleryException
imageData
- the original image data; the input stream is closed by this method.maxSize
- the maximum height or width of the scaled imagemimeType
- the mime type of the imageGalleryException
public BufferedImage getScaledInstance(BufferedImage img, int targetWidth, int targetHeight, Object hint, boolean higherQuality)
BufferedImage
.img
- the original image to be scaledtargetWidth
- the desired width of the scaled instance, in pixelstargetHeight
- the desired height of the scaled instance, in pixelshint
- one of the rendering hints that corresponds to RenderingHints.KEY_INTERPOLATION
(e.g. RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR
, RenderingHints.VALUE_INTERPOLATION_BILINEAR
, RenderingHints.VALUE_INTERPOLATION_BICUBIC
)higherQuality
- if true, this method will use a multi-step scaling technique
that provides higher quality than the usual one-step technique
(only useful in downscaling cases, where targetWidth
or targetHeight
is smaller than the original
dimensions, and generally only when the BILINEAR
hint
is specified)BufferedImage
public Dimension getDesiredResourceDimension(javax.jcr.Node node) throws javax.jcr.RepositoryException
getDesiredResourceDimension
in interface GalleryProcessor
javax.jcr.RepositoryException
public void makeImage(javax.jcr.Node node, InputStream istream, String mimeType, String fileName) throws GalleryException, javax.jcr.RepositoryException
makeImage
in interface GalleryProcessor
GalleryException
javax.jcr.RepositoryException
protected void makeRegularImage(javax.jcr.Node node, String name, InputStream istream, String mimeType, Calendar lastModified) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
protected void makeThumbnailImage(javax.jcr.Node node, InputStream resourceData, String mimeType) throws javax.jcr.RepositoryException, GalleryException
javax.jcr.RepositoryException
GalleryException
public void validateResource(javax.jcr.Node node, String fileName) throws GalleryException, javax.jcr.RepositoryException
validateResource
in interface GalleryProcessor
GalleryException
javax.jcr.RepositoryException
public void initGalleryResource(javax.jcr.Node node, InputStream data, String mimeType, String fileName, Calendar lastModified) throws GalleryException, javax.jcr.RepositoryException
initGalleryResource
in interface GalleryProcessor
GalleryException
javax.jcr.RepositoryException
public boolean isUpscalingEnabled(javax.jcr.Node node) throws GalleryException, javax.jcr.RepositoryException
isUpscalingEnabled
in interface GalleryProcessor
GalleryException
javax.jcr.RepositoryException
Copyright © 2007-2013 Hippo B.V. (http://www.onehippo.com). All Rights Reserved.