magoffin.matt.ma2
Interface MediaEffect

All Known Subinterfaces:
AwtMediaEffect, JMagickMediaEffect
All Known Implementing Classes:
BaseAwtMediaEffect, BaseJMagickMediaEffect, BumpMapEffect, BumpMapEffect, CompositeEffect, RotateEffect, RotateEffect, ScaleEffect, ScaleEffect

public interface MediaEffect

API for applying effects to media items.

The MediaEffect is a way for Matte to apply effects to media items during processing in a call to MediaHandler.handleMediaRequest(magoffin.matt.ma2.domain.MediaItem, magoffin.matt.ma2.MediaRequest, magoffin.matt.ma2.MediaResponse). Standard effects are resizing (scale) and rotating the media, and those effects have constant keys defined in this API (KEY_SCALE and KEY_ROTATE.

The getKey() method should return a unique key for the implementation and function of effect the code implements. There might be several different implementations of a "scale" effect, but they all should include the key KEY_SCALE at the end of the value returned by getKey().

Each effect implementation might require specific parameters to function. Those parameters should be passed to the effect via the MediaRequest.getParameters() map. For example, a rotate effect needs to know by how many degrees it should rotate an image. This amount can be passed as a parameter (the MEDIA_REQUEST_PARAM_ROTATE_DEGREES parameter is defined for this purpose).

Version:
$Revision: 43 $ $Date: 2007-10-21 11:10:01 +1300 (Sun, 21 Oct 2007) $
Author:
Matt Magoffin (spamsqr@msqr.us)

Field Summary
static java.lang.String KEY_ROTATE
          The key for rotating the media item.
static java.lang.String KEY_SCALE
          The key for scaling the media item.
static java.lang.String KEY_WATERMARK
          The key for applying a watermark to a media item.
static java.lang.String MEDIA_REQUEST_PARAM_ROTATE_DEGREES
          A MediaRequest parameter key for a integer value representing a rotational degree to apply to the media item.
static java.lang.String MEDIA_REQUEST_PARAM_WATERMARK_RESOURCE
          A MediaRequest parameter key for a Spring Resource instance that should be used as a watermark image.
 
Method Summary
 void apply(MediaItem item, MediaRequest request, MediaResponse response)
          Apply the effect.
 java.lang.String getKey()
          Get the key for this effect.
 

Field Detail

KEY_SCALE

static final java.lang.String KEY_SCALE
The key for scaling the media item.

See Also:
Constant Field Values

KEY_ROTATE

static final java.lang.String KEY_ROTATE
The key for rotating the media item.

See Also:
Constant Field Values

KEY_WATERMARK

static final java.lang.String KEY_WATERMARK
The key for applying a watermark to a media item.

See Also:
Constant Field Values

MEDIA_REQUEST_PARAM_ROTATE_DEGREES

static final java.lang.String MEDIA_REQUEST_PARAM_ROTATE_DEGREES
A MediaRequest parameter key for a integer value representing a rotational degree to apply to the media item.

See Also:
Constant Field Values

MEDIA_REQUEST_PARAM_WATERMARK_RESOURCE

static final java.lang.String MEDIA_REQUEST_PARAM_WATERMARK_RESOURCE
A MediaRequest parameter key for a Spring Resource instance that should be used as a watermark image.

See Also:
Constant Field Values
Method Detail

getKey

java.lang.String getKey()
Get the key for this effect.

Keys uniquely describe the implementation and function of the effect. The implementation key should come first, and the function key at the end. Some standard function key values are defined in this API: KEY_SCALE for re-sizing and KEY_ROTATE for rotating.

For example, a key might look like image.awt.rotate for an image rotation effect based on a Java AWT implementation.

Returns:
the effect key

apply

void apply(MediaItem item,
           MediaRequest request,
           MediaResponse response)
Apply the effect.

MediaHandler and MediaEffect implementations can utilize the MediaRequest.getParameters() map to keep track of request processing state during processing. Different implementations of MediaHandler will support different implementations of MediaEffects.

Parameters:
item - the item being processed
request - the current request
response - the current response