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 |
DEFAULT_GALLERY_PROCESSOR_ID, GALLERY_PROCESSOR_ID
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) |
static GalleryProcessor |
getGalleryProcessor(IPluginContext pluginContext,
IPluginConfig pluginConfig)
Get the gallery processor service identified by the parameter
GalleryProcessor.GALLERY_PROCESSOR_ID in
the plugin config. |
static GalleryProcessor |
getGalleryProcessor(IPluginContext pluginContext,
IPluginConfig pluginConfig,
String defaultServiceId)
Get the gallery processor service specified by the parameter
GalleryProcessor.GALLERY_PROCESSOR_ID in the
plugin config. |
BufferedImage |
getScaledInstance(BufferedImage img,
int targetWidth,
int targetHeight,
Object hint,
boolean higherQuality)
Convenience method that returns a scaled instance of the provided
BufferedImage . |
Map<String,ScalingParameters> |
getScalingParametersMap() |
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) |
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 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
public Map<String,ScalingParameters> getScalingParametersMap()
getScalingParametersMap
in interface GalleryProcessor
public static GalleryProcessor getGalleryProcessor(IPluginContext pluginContext, IPluginConfig pluginConfig)
GalleryProcessor.GALLERY_PROCESSOR_ID
in
the plugin config. If no service id configuration is found, the service with id
GalleryProcessor.DEFAULT_GALLERY_PROCESSOR_ID
is used.public static GalleryProcessor getGalleryProcessor(IPluginContext pluginContext, IPluginConfig pluginConfig, String defaultServiceId)
GalleryProcessor.GALLERY_PROCESSOR_ID
in the
plugin config. If no service id configuration is found, the service with id defaultServiceId
is used.
If the service with this default id is not found, a new instance of the DefaultGalleryProcessor
is returned.Copyright © 2007–2017 Hippo B.V. (http://www.onehippo.com). All rights reserved.