Class RenderedImageAdapter

Object
PlanarImage
RenderedImageAdapter
All Implemented Interfaces:
RenderedImage, ImageImageN, PropertyChangeEmitter, PropertySource, WritablePropertySource
Direct Known Subclasses:
AttributedImage, WritableRenderedImageAdapter

public class RenderedImageAdapter extends PlanarImage
A PlanarImage wrapper for a non-writable RenderedImage. The tile layout, sample model, and so forth are preserved. Calls to getTile(), getData(), and copyData() are forwarded to the image being adapted.

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.

From ImageN's point of view, this image is a PlanarImage of unknown type, with no sources. The source image is assumed to be immutable. If the RenderedImage source implements WritableRenderedImage , a WritableRenderedImageAdapter should be used.

The methods are marked 'final' in order to allow dynamic inlining to take place. This should eliminate any performance penalty associated with the use of an adapter class.

Since the methods of this class all derive from PlanarImage, they are not commented in detail.

See Also:
  • Constructor Details

    • RenderedImageAdapter

      public RenderedImageAdapter(RenderedImage im)
      Constructs a RenderedImageAdapter.
      Parameters:
      im - a RenderedImage to be `wrapped' as a PlanarImage.
      Throws:
      IllegalArgumentException - if im is null.
  • Method Details

    • getWrappedImage

      public final RenderedImage getWrappedImage()
      Returns the reference to the external RenderedImage originally supplied to the constructor.
    • getTile

      public final Raster getTile(int x, int y)
      Forwards call to the true source unless the specified tile indices refer to a tile which does not overlap the image bounds in which case null is returned.
      Specified by:
      getTile in interface RenderedImage
      Specified by:
      getTile in class PlanarImage
      Parameters:
      x - The X index of the requested tile in the tile array.
      y - The Y index of the requested tile in the tile array.
    • getData

      public final Raster getData()
      Forwards call to the true source.
      Specified by:
      getData in interface RenderedImage
      Overrides:
      getData in class PlanarImage
      Returns:
      A Raster containing the entire image data.
    • getData

      public final Raster getData(Rectangle rect)
      Forwards call to the true source.
      Specified by:
      getData in interface RenderedImage
      Overrides:
      getData in class PlanarImage
      Parameters:
      rect - The rectangular region of this image to be returned, or null.
      Returns:
      A Raster containing the specified image data.
    • copyData

      public final WritableRaster copyData(WritableRaster raster)
      Forwards call to the true source.
      Specified by:
      copyData in interface RenderedImage
      Overrides:
      copyData in class PlanarImage
      Parameters:
      raster - A WritableRaster to hold the copied pixel data of this image.
      Returns:
      A reference to the supplied WritableRaster, or to a new WritableRaster if the supplied one was null.
    • getPropertyNames

      public final String[] getPropertyNames()
      Retrieves a list of property names recognized by this image. The locally defined property names are combined with those derived from the true source.
      Specified by:
      getPropertyNames in interface PropertySource
      Specified by:
      getPropertyNames in interface RenderedImage
      Overrides:
      getPropertyNames in class PlanarImage
      Returns:
      an array of Strings containing valid property names or null.
    • getProperty

      public final Object getProperty(String name)
      Retrieves the property from those set locally on the image or, if the property is not available locally, the call is forwarded to the true source.
      Specified by:
      getProperty in interface PropertySource
      Specified by:
      getProperty in interface RenderedImage
      Overrides:
      getProperty in class PlanarImage
      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 final 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
      Overrides:
      getPropertyClass in class PlanarImage
      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.