org.jaitools.media.jai
Class AttributeOpImage

java.lang.Object
  extended by javax.media.jai.PlanarImage
      extended by javax.media.jai.OpImage
          extended by org.jaitools.media.jai.AttributeOpImage
All Implemented Interfaces:
RenderedImage, javax.media.jai.ImageJAI, javax.media.jai.PropertyChangeEmitter, javax.media.jai.PropertySource, javax.media.jai.WritablePropertySource
Direct Known Subclasses:
ContourOpImage, VectorizeOpImage

public abstract class AttributeOpImage
extends javax.media.jai.OpImage

Abstract base class for operators that generate non-image attributes from a source image while passing source image pixels directly to destination pixels.

Since:
1.1
Version:
$Id$
Author:
Michael Bedward

Field Summary
protected  javax.media.jai.ROI roi
          An optional ROI to define the region over which to derive attributes.
protected  Rectangle srcBounds
          Bounds of the source image as a convenience.
 
Fields inherited from class javax.media.jai.OpImage
cache, cobbleSources, OP_COMPUTE_BOUND, OP_IO_BOUND, OP_NETWORK_BOUND, tileCacheMetric, tileRecycler
 
Fields inherited from class javax.media.jai.PlanarImage
colorModel, eventManager, height, minX, minY, properties, sampleModel, tileFactory, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, width
 
Constructor Summary
AttributeOpImage(RenderedImage source, javax.media.jai.ROI roi)
          Constructor.
 
Method Summary
 boolean computesUniqueTiles()
          Always returns false since source and destination tiles are the same.
 Raster computeTile(int tileX, int tileY)
          Handles a request to compute image data for a given tile by simply passing a getTile request to the source image.
protected abstract  Object getAttribute(String name)
          Retrieves an attribute by name.
protected  Class<?> getAttributeClass(String name)
          Returns the class of the specified attribute.
protected abstract  String[] getAttributeNames()
          Returns the names of available attributes.
 Object getProperty(String name)
           
 Class getPropertyClass(String name)
           
 String[] getPropertyNames()
           
 Raster getTile(int tileX, int tileY)
          Gets the requested image tile (which will be from the source image).
 Raster[] getTiles(Point[] tileIndices)
          Gets the requested image tiles (which will be from the source image).
 Rectangle mapDestRect(Rectangle destRect, int sourceIndex)
          Maps the destination rectangle into source image space (which will be identical).
 Rectangle mapSourceRect(Rectangle sourceRect, int sourceIndex)
          Maps the source rectangle into destination space (which will be identical).
 
Methods inherited from class javax.media.jai.OpImage
addTileToCache, cancelTiles, computeRect, computeRect, createTile, dispose, getExpandedNumBands, getFormatTags, getOperationComputeType, getTileCache, getTileCacheMetric, getTileDependencies, getTileFromCache, getTileRecycler, hasExtender, mapDestPoint, mapSourcePoint, prefetchTiles, queueTiles, recycleTile, setTileCache, vectorize, vectorize, vectorize
 
Methods inherited from class javax.media.jai.PlanarImage
addPropertyChangeListener, addPropertyChangeListener, addSink, addSink, addSource, addTileComputationListener, copyData, copyData, copyExtendedData, createColorModel, createSnapshot, createWritableRaster, finalize, getAsBufferedImage, getAsBufferedImage, getBounds, getColorModel, getData, getData, getDefaultColorModel, getExtendedData, getGraphics, getHeight, getImageID, getMaxTileX, getMaxTileY, getMaxX, getMaxY, getMinTileX, getMinTileY, getMinX, getMinY, getNumBands, getNumSources, getNumXTiles, getNumYTiles, getProperties, getPropertyNames, getSampleModel, getSinks, getSource, getSourceImage, getSourceObject, getSources, getSplits, getTileComputationListeners, getTileFactory, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileIndices, getTileRect, getTiles, getTileWidth, getWidth, overlapsMultipleTiles, removeProperty, removePropertyChangeListener, removePropertyChangeListener, removeSink, removeSink, removeSinks, removeSource, removeSources, removeTileComputationListener, setImageLayout, setProperties, setProperty, setSource, setSources, tileXToX, tileXToX, tileYToY, tileYToY, toString, wrapRenderedImage, XToTileX, XToTileX, YToTileY, YToTileY
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

roi

protected javax.media.jai.ROI roi
An optional ROI to define the region over which to derive attributes. If an ROI is not provided this will be set to an ROIShape having the bounds of the source image.


srcBounds

protected Rectangle srcBounds
Bounds of the source image as a convenience.

Constructor Detail

AttributeOpImage

public AttributeOpImage(RenderedImage source,
                        javax.media.jai.ROI roi)
Constructor.

Parameters:
source - the source image from from which to derive attributes
roi - an optional ROI to define sub-region(s) of the source image to examine.
Method Detail

computesUniqueTiles

public boolean computesUniqueTiles()
Always returns false since source and destination tiles are the same.

Overrides:
computesUniqueTiles in class javax.media.jai.OpImage

getTile

public Raster getTile(int tileX,
                      int tileY)
Gets the requested image tile (which will be from the source image).

Specified by:
getTile in interface RenderedImage
Overrides:
getTile in class javax.media.jai.OpImage
Parameters:
tileX - tile X index
tileY - tile Y index
Returns:
the requested tile

computeTile

public Raster computeTile(int tileX,
                          int tileY)
Handles a request to compute image data for a given tile by simply passing a getTile request to the source image.

Overrides:
computeTile in class javax.media.jai.OpImage
Parameters:
tileX - tile X index
tileY - tile Y index
Returns:
the requested tile

getTiles

public Raster[] getTiles(Point[] tileIndices)
Gets the requested image tiles (which will be from the source image).

Overrides:
getTiles in class javax.media.jai.OpImage
Parameters:
tileIndices - tile X and Y indices as Points
Throws:
IllegalArgumentException - If tileIndices is null.

mapSourceRect

public Rectangle mapSourceRect(Rectangle sourceRect,
                               int sourceIndex)
Maps the source rectangle into destination space (which will be identical).

Specified by:
mapSourceRect in class javax.media.jai.OpImage
Parameters:
sourceRect - the Rectangle in source image coordinates
sourceIndex - the index of the source image (must be 0 since there is only one source image)
Returns:
A new Rectangle with identical bounds to sourceRect
Throws:
IllegalArgumentException - if sourceRect is null
IllegalArgumentException - if sourceIndex is not 0

mapDestRect

public Rectangle mapDestRect(Rectangle destRect,
                             int sourceIndex)
Maps the destination rectangle into source image space (which will be identical).

Specified by:
mapDestRect in class javax.media.jai.OpImage
Parameters:
destRect - the Rectangle in destination image coordinates
sourceIndex - the index of the source image (must be 0 since there is only one source image)
Returns:
A new Rectangle with identical bounds to destRect
Throws:
IllegalArgumentException - if destRect is null
IllegalArgumentException - if sourceIndex is not 0

getAttribute

protected abstract Object getAttribute(String name)
Retrieves an attribute by name. Calling this method will fire a request for it to be generated if it has not already been so, or if the sub-class does not cache the attribute.

Parameters:
name - the attribute name
Returns:
the requested attribute or null if the name does not match any of the available attributes
Throws:
IllegalArgumentException - if name is null

getAttributeClass

protected Class<?> getAttributeClass(String name)
Returns the class of the specified attribute. This default implementation always returns class Object.

Parameters:
name - attribute name
Returns:
the attribute class

getAttributeNames

protected abstract String[] getAttributeNames()
Returns the names of available attributes.

Returns:
attribute names

getProperty

public Object getProperty(String name)
Specified by:
getProperty in interface RenderedImage
Specified by:
getProperty in interface javax.media.jai.PropertySource
Overrides:
getProperty in class javax.media.jai.PlanarImage

getPropertyClass

public Class getPropertyClass(String name)
Specified by:
getPropertyClass in interface javax.media.jai.PropertySource
Overrides:
getPropertyClass in class javax.media.jai.PlanarImage

getPropertyNames

public String[] getPropertyNames()
Specified by:
getPropertyNames in interface RenderedImage
Specified by:
getPropertyNames in interface javax.media.jai.PropertySource
Overrides:
getPropertyNames in class javax.media.jai.PlanarImage


Copyright © 2009-2013. All Rights Reserved.