|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object magoffin.matt.ma2.support.AbstractMediaHandler magoffin.matt.ma2.image.BaseImageMediaHandler
public abstract class BaseImageMediaHandler
Base implementation of MediaMetadata for image media types.
The DEFAULT_ORIENTATION_90_CLOCKWISE_VALUE
,
DEFAULT_ORIENTATION_90_COUNTER_CLOCKWISE_VALUE
, and
DEFAULT_ORIENTATION_180_VALUE
constants are
set to 8
, 6
, and 3
to work with EXIF camera
orientation values by default.
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_ORIENTATION_180_VALUE
The default value for the orientation180 property. |
static java.lang.String |
DEFAULT_ORIENTATION_90_CLOCKWISE_VALUE
The default value for the orientationClockwiseValue property. |
static java.lang.String |
DEFAULT_ORIENTATION_90_COUNTER_CLOCKWISE_VALUE
The default value for the orientationCounterClockwiseValue property. |
static java.lang.String |
DEFAULT_ORIENTATION_METADATA_KEY
The default value for the orientationMetadataKey property. |
static java.lang.Integer |
ROTATE_180
The rotation degrees for 180 degrees. |
static java.lang.Integer |
ROTATE_90_CCW
The rotation degrees for 90 degrees counter-clockwise. |
static java.lang.Integer |
ROTATE_90_CW
The rotation degrees for 90 degrees clockwise. |
Fields inherited from class magoffin.matt.ma2.support.AbstractMediaHandler |
---|
log, METADATA_PARAMETER_KEY |
Constructor Summary | |
---|---|
BaseImageMediaHandler(java.lang.String mime)
Construct with a MIME type. |
Method Summary | |
---|---|
java.lang.String |
getOrientation180Value()
|
java.lang.String |
getOrientation90ClockwiseValue()
|
java.lang.String |
getOrientation90CounterClockwiseValue()
|
java.lang.String |
getOrientationMetadataKey()
|
protected MediaMetadata |
handleMetadata(MediaRequest request,
org.springframework.core.io.Resource mediaResource,
MediaItem item)
Extract metadata from a resource and replace item metadata with all extracted data. |
protected boolean |
needToRotate(MediaItem item,
MediaRequest request)
Check if rotation needs to be performed for a given media item based on the orientation metadata available in the media item. |
void |
setOrientation180Value(java.lang.String orientation180Value)
|
void |
setOrientation90ClockwiseValue(java.lang.String orientation90ClockwiseValue)
|
void |
setOrientation90CounterClockwiseValue(java.lang.String orientation90CounterClockwiseValue)
|
void |
setOrientationMetadataKey(java.lang.String orientationMetadataKey)
|
Methods inherited from class magoffin.matt.ma2.support.AbstractMediaHandler |
---|
applyEffects, createMetadataList, defaultHandleRequestOriginal, getDomainObjectFactory, getEffect, getFileExtension, getMediaBiz, getMediaMetadataInstance, getMime, getNoWatermarkSizes, getPreferredFileExtension, getRequestEffects, getSmetaPropertyMap, getUserBiz, needToAlter, setDomainObjectFactory, setMediaBiz, setMime, setNoWatermarkSizes, setPreferredFileExtension, setSmetaPropertyMap, setUserBiz |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface magoffin.matt.ma2.MediaHandler |
---|
createNewMediaItem, handleMediaRequest |
Field Detail |
---|
public static final java.lang.Integer ROTATE_90_CW
public static final java.lang.Integer ROTATE_90_CCW
public static final java.lang.Integer ROTATE_180
public static final java.lang.String DEFAULT_ORIENTATION_METADATA_KEY
orientationMetadataKey
property.
public static final java.lang.String DEFAULT_ORIENTATION_90_COUNTER_CLOCKWISE_VALUE
orientationCounterClockwiseValue
property.
public static final java.lang.String DEFAULT_ORIENTATION_90_CLOCKWISE_VALUE
orientationClockwiseValue
property.
public static final java.lang.String DEFAULT_ORIENTATION_180_VALUE
orientation180
property.
Constructor Detail |
---|
public BaseImageMediaHandler(java.lang.String mime)
mime
- the MIMEMethod Detail |
---|
protected MediaMetadata handleMetadata(MediaRequest request, org.springframework.core.io.Resource mediaResource, MediaItem item)
AbstractMediaHandler
This method provides a simple way to populate the Metadata
list of a newly created MediaItem
. It will generate the list
of Metadata
and then add all of them into the List returned
by MediaItem.getMetadata()
.
This method first calls AbstractMediaHandler.getMediaMetadataInstance(MediaRequest, Resource, MediaItem)
to create a new instance of MediaMetadata
and then calls
MediaMetadata.setMediaResource(Resource)
.
If MediaMetadata.getCreationDate()
returns a non-null value
then a new Calendar
instance will be created from it and used
to set the creationDate
property of the MediaItem.
If the MediaMetadata is an instance of EmbeddedImageMetadata
then EmbeddedImageMetadata.getEmbeddedImage()
will be
called, and the width/height of the returned image will be used to
set the width/height properties of the MediaItem provided.
handleMetadata
in class AbstractMediaHandler
request
- the reqeust (may be null)mediaResource
- the media resource to extract the metadata fromitem
- the item to replace the extracted metadata in
protected boolean needToRotate(MediaItem item, MediaRequest request)
This method looks in the MediaItem.getMetadata()
list for
a Metadata.getKey()
value equal to getOrientationMetadataKey()
as configured on this class.
If rotation should be applied, this method will set the
MediaEffect.MEDIA_REQUEST_PARAM_ROTATE_DEGREES
parameter on
the MediaRequest.getParameters()
map to the degrees by which
the image should be rotated. This is determined by examining the
Metadata.getValue()
of the found orientation metadata object.
If it is equal to getOrientation90ClockwiseValue()
then the degrees
will be set to ROTATE_90_CW
. If the value is equal to
getOrientation90CounterClockwiseValue()
then the degrees will be set
to ROTATE_90_CCW
. If the value is equal to getOrientation180Value()
then the degrees will be set to ROTATE_180
.
needToRotate
in class AbstractMediaHandler
item
- the item being processedrequest
- the request the current request
public java.lang.String getOrientationMetadataKey()
public void setOrientationMetadataKey(java.lang.String orientationMetadataKey)
orientationMetadataKey
- the orientationMetadataKey to setpublic java.lang.String getOrientation90CounterClockwiseValue()
public void setOrientation90CounterClockwiseValue(java.lang.String orientation90CounterClockwiseValue)
orientation90CounterClockwiseValue
- the orientation90CounterClockwiseValue to setpublic java.lang.String getOrientation90ClockwiseValue()
public void setOrientation90ClockwiseValue(java.lang.String orientation90ClockwiseValue)
orientation90ClockwiseValue
- the orientation90ClockwiseValue to setpublic java.lang.String getOrientation180Value()
public void setOrientation180Value(java.lang.String orientation180Value)
orientation180Value
- the orientation180Value to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |