javax.media.jai
Class RenderableImageAdapter

java.lang.Object
  extended byjavax.media.jai.RenderableImageAdapter
All Implemented Interfaces:
PropertyChangeEmitter, PropertySource, RenderableImage, WritablePropertySource

public final class RenderableImageAdapter
extends Object
implements RenderableImage, WritablePropertySource

An adapter class for externally-generated RenderableImages. All methods are simply forwarded to the image being adapted. The purpose of this class is simply to ensure that the PropertySource interface is available for all JAI RenderableImages.

The set of properties available on the image will be a combination of those defined locally via setProperty() and those defined on the source image with the local properties taking precedence. No PropertySourceChangeEvent will be generated as a result of changes to the property set of the source image.


Field Summary
 
Fields inherited from interface java.awt.image.renderable.RenderableImage
HINTS_OBSERVED
 
Constructor Summary
RenderableImageAdapter(RenderableImage im)
          Constructs a RenderableImageAdapter from a RenderableImage.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a PropertyChangeListener to the listener list.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Add a PropertyChangeListener for a specific property.
 RenderedImage createDefaultRendering()
          Gets a RenderedImage instance of this image with a default width and height in pixels.
 RenderedImage createRendering(RenderContext renderContext)
          Gets a RenderedImage instance of this image from a RenderContext.
 RenderedImage createScaledRendering(int w, int h, RenderingHints hints)
          Gets a RenderedImage instance of this image with width w, and height h in pixels.
 float getHeight()
          Gets the height in user coordinate space.
 float getMinX()
          Gets the minimum X coordinate of the rendering-independent image.
 float getMinY()
          Gets the minimum Y coordinate of the rendering-independent image.
 Object getProperty(String name)
          Gets a property from the property set of this image.
 Class getPropertyClass(String name)
          Returns the class expected to be returned by a request for the property with the specified name.
 String[] getPropertyNames()
          Returns a list of the properties recognized by this image.
 String[] getPropertyNames(String prefix)
          Returns an array of Strings recognized as names by this property source that begin with the supplied prefix.
 Vector getSources()
           
 float getWidth()
          Gets the width in user coordinate space.
 RenderableImage getWrappedImage()
          Returns the reference to the external RenderableImage originally supplied to the constructor.
 boolean isDynamic()
          Returns true if successive renderings (that is, calls to createRendering() or createScaledRendering()) with the same arguments may produce different results.
 void removeProperty(String name)
          Removes the named property from the RenderableImageAdapter.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a PropertyChangeListener from the listener list.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Remove a PropertyChangeListener for a specific property.
 void setProperty(String name, Object value)
          Sets a property on a RenderableImageAdapter.
static RenderableImageAdapter wrapRenderableImage(RenderableImage im)
          Adapts a RenderableImage into a RenderableImageAdapter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RenderableImageAdapter

public RenderableImageAdapter(RenderableImage im)
Constructs a RenderableImageAdapter from a RenderableImage.

Throws:
IllegalArgumentException - if im is null.
Method Detail

wrapRenderableImage

public static RenderableImageAdapter wrapRenderableImage(RenderableImage im)
Adapts a RenderableImage into a RenderableImageAdapter. If the image is already an instance of RenderableImageAdapter, it is returned unchanged.

Parameters:
im - a RenderableImage.
Returns:
a RenderableImageAdapter.
Throws:
IllegalArgumentException - if im is null.

getWrappedImage

public final RenderableImage getWrappedImage()
Returns the reference to the external RenderableImage originally supplied to the constructor.

Since:
JAI 1.1.2

getSources

public final Vector getSources()
Specified by:
getSources in interface RenderableImage

getProperty

public final Object getProperty(String name)
Gets a property from the property set of this image. If the property name is not recognized, java.awt.Image.UndefinedProperty will be returned.

Specified by:
getProperty in interface RenderableImage
Parameters:
name - the name of the property to get, as a String.
Returns:
a reference to the property Object, or the value java.awt.Image.UndefinedProperty.
Throws:
IllegalArgumentException - if name is null.

getPropertyClass

public Class getPropertyClass(String name)
Returns the class expected to be returned by a request for the property with the specified name. If this information is unavailable, null will be returned.

Specified by:
getPropertyClass in interface PropertySource
Parameters:
name - the name of the property, as a String.
Returns:
The Class expected to be return by a request for the value of this property or null.
Throws:
IllegalArgumentException - if name is null.
Since:
JAI 1.1

getPropertyNames

public final String[] getPropertyNames()
Returns a list of the properties recognized by this image. If no properties are available, null will be returned.

Specified by:
getPropertyNames in interface RenderableImage
Returns:
an array of Strings representing valid property names.

getPropertyNames

public String[] getPropertyNames(String prefix)
Returns an array of Strings recognized as names by this property source that begin with the supplied prefix. If no property names match, null will be returned. The comparison is done in a case-independent manner.

Specified by:
getPropertyNames in interface PropertySource
Returns:
an array of Strings giving the valid property names.
Throws:
IllegalArgumentException - if prefix is null.

setProperty

public void setProperty(String name,
                        Object value)
Sets a property on a RenderableImageAdapter.

Specified by:
setProperty in interface WritablePropertySource
Parameters:
name - a String containing the property's name.
value - the property, as a general Object.
Throws:
IllegalArgumentException - If name or value is null.
Since:
JAI 1.1

removeProperty

public void removeProperty(String name)
Removes the named property from the RenderableImageAdapter.

Specified by:
removeProperty in interface WritablePropertySource
Parameters:
name - the name of the property, as a String.
Throws:
IllegalArgumentException - if name is null.
Since:
JAI 1.1

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. The listener is registered for all properties.

Specified by:
addPropertyChangeListener in interface PropertyChangeEmitter
Since:
JAI 1.1

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Add a PropertyChangeListener for a specific property. The case of the name is ignored.

Specified by:
addPropertyChangeListener in interface PropertyChangeEmitter
Since:
JAI 1.1

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.

Specified by:
removePropertyChangeListener in interface PropertyChangeEmitter
Since:
JAI 1.1

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Remove a PropertyChangeListener for a specific property. The case of the name is ignored.

Specified by:
removePropertyChangeListener in interface PropertyChangeEmitter
Since:
JAI 1.1

getWidth

public final float getWidth()
Gets the width in user coordinate space. By convention, the usual width of a RenderableImage is equal to the image's aspect ratio (width divided by height).

Specified by:
getWidth in interface RenderableImage
Returns:
the width of the image in user coordinates.

getHeight

public final float getHeight()
Gets the height in user coordinate space. By convention, the usual height of a RenderedImage is equal to 1.0F.

Specified by:
getHeight in interface RenderableImage
Returns:
the height of the image in user coordinates.

getMinX

public final float getMinX()
Gets the minimum X coordinate of the rendering-independent image.

Specified by:
getMinX in interface RenderableImage

getMinY

public final float getMinY()
Gets the minimum Y coordinate of the rendering-independent image.

Specified by:
getMinY in interface RenderableImage

isDynamic

public final boolean isDynamic()
Returns true if successive renderings (that is, calls to createRendering() or createScaledRendering()) with the same arguments may produce different results. This method may be used to determine whether an existing rendering may be cached and reused.

Specified by:
isDynamic in interface RenderableImage

createScaledRendering

public final RenderedImage createScaledRendering(int w,
                                                 int h,
                                                 RenderingHints hints)
Gets a RenderedImage instance of this image with width w, and height h in pixels. The RenderContext is built automatically with an appropriate usr2dev transform and an area of interest of the full image. All the rendering hints come from hints passed in.

Specified by:
createScaledRendering in interface RenderableImage
Parameters:
w - the width of rendered image in pixels.
h - the height of rendered image in pixels.
hints - a RenderingHints object containing rendering hints.
Returns:
a RenderedImage containing the rendered data.

createDefaultRendering

public final RenderedImage createDefaultRendering()
Gets a RenderedImage instance of this image with a default width and height in pixels. The RenderContext is built automatically with an appropriate usr2dev transform and an area of interest of the full image. All the rendering hints come from hints passed in. Implementors of this interface must be sure that there is a defined default width and height.

Specified by:
createDefaultRendering in interface RenderableImage
Returns:
a RenderedImage containing the rendered data.

createRendering

public final RenderedImage createRendering(RenderContext renderContext)
Gets a RenderedImage instance of this image from a RenderContext. This is the most general way to obtain a rendering of a RenderableImage.

Specified by:
createRendering in interface RenderableImage
Parameters:
renderContext - the RenderContext to use to produce the rendering.
Returns:
a RenderedImage containing the rendered data.