javax.media.jai
Class CRIFImpl

java.lang.Object
  |
  +--javax.media.jai.CRIFImpl
All Implemented Interfaces:
ContextualRenderedImageFactory, RenderedImageFactory
Direct Known Subclasses:
NullCRIF

public abstract class CRIFImpl
extends Object
implements ContextualRenderedImageFactory

A utility class to minimize in most cases the effort required to implement the ContextualRenderedImageFactory (CRIF) of an operation. An extender of this class is required to implement only the method RenderedImage create(ParameterBlock, RenderingHints) defined in the RenderedImageFactory interface. The remaining methods may be overridden insofar as this is necessary to obtain behavior different from that provided by default.

Since:
JAI 1.1
See Also:
ContextualRenderedImageFactory, RenderedImageFactory

Field Summary
protected  String operationName
          If non-null, this name will be used as a parameter to JAI.create() in create(RenderContext,ParameterBlock); otherwise the RIF create(ParameterBlock,RenderingHints) method implemented in the extending class will be invoked.
 
Constructor Summary
CRIFImpl()
          Default constructor.
CRIFImpl(String operationName)
          Constructor.
 
Method Summary
abstract  RenderedImage create(ParameterBlock paramBlock, RenderingHints renderHints)
          The RenderedImageFactory create() method which must be implemented by concrete subclasses.
 RenderedImage create(RenderContext renderContext, ParameterBlock paramBlock)
          Creates a RenderedImage from the renderable layer.
 Rectangle2D getBounds2D(ParameterBlock paramBlock)
          Returns the bounding box for the output of the operation.
 Object getProperty(ParameterBlock paramBlock, String name)
          Returns the appropriate instance of the property with the indicated name.
 String[] getPropertyNames()
          Returns the valid property names for the operation.
 boolean isDynamic()
          Returns true if successive renderings with the same arguments may produce different results.
 RenderContext mapRenderContext(int i, RenderContext renderContext, ParameterBlock paramBlock, RenderableImage image)
          Maps the destination RenderContext into a RenderContext for each source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

operationName

protected String operationName
If non-null, this name will be used as a parameter to JAI.create() in create(RenderContext,ParameterBlock); otherwise the RIF create(ParameterBlock,RenderingHints) method implemented in the extending class will be invoked.
Constructor Detail

CRIFImpl

public CRIFImpl()
Default constructor. The operation name is set to null.

CRIFImpl

public CRIFImpl(String operationName)
Constructor. The operation name is set to the specified value which may be null.
Method Detail

create

public abstract RenderedImage create(ParameterBlock paramBlock,
                                     RenderingHints renderHints)
The RenderedImageFactory create() method which must be implemented by concrete subclasses.
Specified by:
create in interface RenderedImageFactory

create

public RenderedImage create(RenderContext renderContext,
                            ParameterBlock paramBlock)
Creates a RenderedImage from the renderable layer.

If operationName is non-null, JAI.create() will be invoked using the supplied ParameterBlock and the RenderingHints contained in the RenderContext. If operationName is null, or JAI.create() returns null, the create(ParameterBlock,RenderingHints) method defined in the extending class will be invoked.

Specified by:
create in interface ContextualRenderedImageFactory
Parameters:
renderContext - The rendering information associated with this rendering.
paramBlock - The parameters used to create the image.
Returns:
A RenderedImage.

mapRenderContext

public RenderContext mapRenderContext(int i,
                                      RenderContext renderContext,
                                      ParameterBlock paramBlock,
                                      RenderableImage image)
Maps the destination RenderContext into a RenderContext for each source. The implementation in this class simply returns the RenderContext passed in by the caller.
Specified by:
mapRenderContext in interface ContextualRenderedImageFactory
Parameters:
i - The index of the source image.
renderContext - The RenderContext being applied to the operation.
paramBlock - A ParameterBlock containing the sources and parameters of the operation.
image - The RenderableImage being rendered.
Returns:
The RenderContext to be used to render the given source.

getBounds2D

public Rectangle2D getBounds2D(ParameterBlock paramBlock)
Returns the bounding box for the output of the operation. The implementation in this class computes the bounding box as the intersection the bounding boxes of all the (renderable sources).
Specified by:
getBounds2D in interface ContextualRenderedImageFactory
Parameters:
paramBlock - A ParameterBlock containing the sources and parameters of the operation.
Returns:
A Rectangle2D specifying the bounding box.

getProperty

public Object getProperty(ParameterBlock paramBlock,
                          String name)
Returns the appropriate instance of the property with the indicated name.

The implementation in this class always returns java.awt.Image.UndefinedProperty since no properties are defined by default.

Specified by:
getProperty in interface ContextualRenderedImageFactory
Parameters:
paramBlock - A ParameterBlock containing the sources and parameters of the operation.
name - A String containing the desired property name.
Returns:
the value java.awt.Image.UndefinedProperty indicating that the property is undefined.

getPropertyNames

public String[] getPropertyNames()
Returns the valid property names for the operation. The implementation in this class always returns null since no properties are associated with the operation by default.
Specified by:
getPropertyNames in interface ContextualRenderedImageFactory
Returns:
null indicating that no properties are defined.

isDynamic

public boolean isDynamic()
Returns true if successive renderings with the same arguments may produce different results. The implementation in this class always returns false so as to enable caching of renderings by default. CRIFs that do implement dynamic rendering behavior must override this method.
Specified by:
isDynamic in interface ContextualRenderedImageFactory
Returns:
false indicating that the rendering is static.