javax.media.jai
Class MultiResolutionRenderableImage

java.lang.Object
  |
  +--javax.media.jai.MultiResolutionRenderableImage
All Implemented Interfaces:
PropertyChangeEmitter, PropertySource, RenderableImage, Serializable, WritablePropertySource

public class MultiResolutionRenderableImage
extends Object
implements WritablePropertySource, RenderableImage, Serializable

A RenderableImage that produces renderings based on a set of supplied RenderedImages at various resolutions.

See Also:
Serialized Form

Field Summary
protected  float aspect
          The aspect ratio, derived from the highest-resolution source.
protected  PropertyChangeSupportJAI eventManager
          A helper object to manage firing events.
protected  float height
          The height in Renderable coordinates.
protected  float minX
          The min X coordinate in Renderable coordinates.
protected  float minY
          The min Y coordinate in Renderable coordinates.
protected  WritablePropertySourceImpl properties
          A helper object to manage the image properties.
protected  RenderedImage[] renderedSource
          An array of RenderedImage sources.
protected  float width
          The width in Renderable coordinates.
 
Fields inherited from interface java.awt.image.renderable.RenderableImage
HINTS_OBSERVED
 
Constructor Summary
MultiResolutionRenderableImage(Vector renderedSources, float minX, float minY, float height)
          Constructs a MultiResolutionRenderableImage with given dimensions from a Vector of progressively lower resolution versions of a RenderedImage.
 
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()
          Returns the full resolution source RenderedImage with no rendering hints.
 RenderedImage createRendering(RenderContext renderContext)
          Returns a rendering based on a RenderContext.
 RenderedImage createScaledRendering(int width, int height, RenderingHints hints)
          Returns a rendering with a given width, height, and rendering hints.
 float getHeight()
          Returns the floating-point height of the RenderableImage.
 float getMaxX()
          Returns the floating-point max X coordinate of the RenderableImage.
 float getMaxY()
          Returns the floating-point max Y coordinate of the RenderableImage.
 float getMinX()
          Returns the floating-point min X coordinate of the RenderableImage.
 float getMinY()
          Returns the floating-point min Y coordinate of the RenderableImage.
 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()
          Returns an empty Vector, indicating that this RenderableImage has no Renderable sources.
 float getWidth()
          Returns the floating-point width of the RenderableImage.
 boolean isDynamic()
          Returns false since successive renderings (that is, calls to createRendering() or createScaledRendering()) with the same arguments will never produce different results.
 void removeProperty(String name)
          Removes the named property from the MultiResolutionRenderableImage.
 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 MultiResolutionRenderableImage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

renderedSource

protected transient RenderedImage[] renderedSource
An array of RenderedImage sources.

aspect

protected float aspect
The aspect ratio, derived from the highest-resolution source.

minX

protected float minX
The min X coordinate in Renderable coordinates.

minY

protected float minY
The min Y coordinate in Renderable coordinates.

width

protected float width
The width in Renderable coordinates.

height

protected float height
The height in Renderable coordinates.

eventManager

protected PropertyChangeSupportJAI eventManager
A helper object to manage firing events.
Since:
JAI 1.1

properties

protected WritablePropertySourceImpl properties
A helper object to manage the image properties.
Since:
JAI 1.1
Constructor Detail

MultiResolutionRenderableImage

public MultiResolutionRenderableImage(Vector renderedSources,
                                      float minX,
                                      float minY,
                                      float height)
Constructs a MultiResolutionRenderableImage with given dimensions from a Vector of progressively lower resolution versions of a RenderedImage.
Parameters:
renderedSources - a Vector of RenderedImages.
minX - the minimum X coordinate of the Renderable, as a float.
minY - the minimum Y coordinate of the Renderable, as a float.
height - the height of the Renderable, as a float.
Throws:
IllegalArgumentException - if the supplied height is non-positive.
Method Detail

getSources

public Vector getSources()
Returns an empty Vector, indicating that this RenderableImage has no Renderable sources.
Specified by:
getSources in interface RenderableImage
Returns:
an empty Vector.

getPropertyNames

public String[] getPropertyNames()
Returns a list of the properties recognized by this image. If no properties are recognized by this image, null will be returned. The default implementation returns null, i.e., no property names are recognized.
Specified by:
getPropertyNames in interface PropertySource
Returns:
an array of Strings representing valid property names.
Since:
JAI 1.1

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 are recognized, or no property names match, null will be returned. The comparison is done in a case-independent manner.
Specified by:
getPropertyNames in interface PropertySource
Parameters:
prefix - the supplied prefix for the property source.
Returns:
An array of Strings giving the valid property names.
Throws:
IllegalArgumentException - if prefix 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
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

getProperty

public 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. The default implementation returns java.awt.Image.UndefinedProperty.
Specified by:
getProperty in interface PropertySource
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.

setProperty

public void setProperty(String name,
                        Object value)
Sets a property on a MultiResolutionRenderableImage.
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 MultiResolutionRenderableImage.
Specified by:
removeProperty in interface WritablePropertySource
Returns:
The value of the property removed or java.awt.Image.UndefinedProperty if it was not present in the property set.
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 listener will be invoked only when a call on firePropertyChange names that 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 float getWidth()
Returns the floating-point width of the RenderableImage.
Specified by:
getWidth in interface RenderableImage

getHeight

public float getHeight()
Returns the floating-point height of the RenderableImage.
Specified by:
getHeight in interface RenderableImage

getMinX

public float getMinX()
Returns the floating-point min X coordinate of the RenderableImage.
Specified by:
getMinX in interface RenderableImage

getMaxX

public float getMaxX()
Returns the floating-point max X coordinate of the RenderableImage.

getMinY

public float getMinY()
Returns the floating-point min Y coordinate of the RenderableImage.
Specified by:
getMinY in interface RenderableImage

getMaxY

public float getMaxY()
Returns the floating-point max Y coordinate of the RenderableImage.

isDynamic

public boolean isDynamic()
Returns false since successive renderings (that is, calls to createRendering() or createScaledRendering()) with the same arguments will never produce different results.
Specified by:
isDynamic in interface RenderableImage

createScaledRendering

public RenderedImage createScaledRendering(int width,
                                           int height,
                                           RenderingHints hints)
Returns a rendering with a given width, height, and rendering hints.

If a JAI rendering hint named JAI.KEY_INTERPOLATION is provided, its corresponding Interpolation object is used as an argument to the JAI operator used to scale the image. If no such hint is present, an instance of InterpolationNearest is used.

Specified by:
createScaledRendering in interface RenderableImage
Parameters:
width - the width of the rendering in pixels.
height - the height of the rendering in pixels.
hints - a Hashtable of rendering hints.
Throws:
IllegalArgumentException - if width or height are non-positive.

createDefaultRendering

public RenderedImage createDefaultRendering()
Returns the full resolution source RenderedImage with no rendering hints.
Specified by:
createDefaultRendering in interface RenderableImage

createRendering

public RenderedImage createRendering(RenderContext renderContext)
Returns a rendering based on a RenderContext.

If a JAI rendering hint named JAI.KEY_INTERPOLATION is provided, its corresponding Interpolation object is used as an argument to the JAI operator used to transform the image. If no such hint is present, an instance of InterpolationNearest is used.

The RenderContext may contain a Shape that represents the area-of-interest (aoi). If the aoi is specifed, it is still legal to return an image that's larger than this aoi. Therefore, by default, the aoi, if specified, is ignored at the rendering.

Specified by:
createRendering in interface RenderableImage
Parameters:
renderContext - a RenderContext describing the transform rendering hints.
Throws:
IllegalArgumentException - if renderContext is null.