org.apache.batik.ext.awt.image.rendered

Class AbstractRed

public abstract class AbstractRed extends Object implements CachableRed

This is an abstract base class that takes care of most of the normal issues surrounding the implementation of the CachableRed (RenderedImage) interface. It tries to make no assumptions about the subclass implementation.
Field Summary
protected Rectanglebounds
protected ColorModelcm
protected intminTileX
protected intminTileY
protected intnumXTiles
protected intnumYTiles
protected Mapprops
protected SampleModelsm
protected Vectorsrcs
protected inttileGridXOff
protected inttileGridYOff
protected inttileHeight
protected inttileWidth
Constructor Summary
protected AbstractRed()
void constructor.
protected AbstractRed(Rectangle bounds, Map props)
Construct an Abstract RenderedImage from a bounds rect and props (may be null).
protected AbstractRed(CachableRed src, Map props)
Construct an Abstract RenderedImage from a source image and props (may be null).
protected AbstractRed(CachableRed src, Rectangle bounds, Map props)
Construct an Abstract RenderedImage from a source image, bounds rect and props (may be null).
protected AbstractRed(CachableRed src, Rectangle bounds, ColorModel cm, SampleModel sm, Map props)
Construct an Abstract RenderedImage from a source image, bounds rect and props (may be null).
protected AbstractRed(CachableRed src, Rectangle bounds, ColorModel cm, SampleModel sm, int tileGridXOff, int tileGridYOff, Map props)
Construct an Abstract Rable from a bounds rect and props (may be null).
protected AbstractRed(List srcs, Rectangle bounds, Map props)
Construct an Abstract Rable from a List of sources a bounds rect and props (may be null).
protected AbstractRed(List srcs, Rectangle bounds, ColorModel cm, SampleModel sm, Map props)
Construct an Abstract RenderedImage from a bounds rect, ColorModel (may be null), SampleModel (may be null) and props (may be null).
protected AbstractRed(List srcs, Rectangle bounds, ColorModel cm, SampleModel sm, int tileGridXOff, int tileGridYOff, Map props)
Construct an Abstract RenderedImage from a bounds rect, ColorModel (may be null), SampleModel (may be null), tile grid offsets and props (may be null).
Method Summary
static voidcopyBand(Raster src, int srcBand, WritableRaster dst, int dstBand)
voidcopyToRaster(WritableRaster wr)
Copies data from this images tile grid into wr. wr may extend outside the bounds of this image in which case the data in wr outside the bounds will not be touched.
RectanglegetBounds()
ColorModelgetColorModel()
RastergetData()
RastergetData(Rectangle rect)
ShapegetDependencyRegion(int srcIndex, Rectangle outputRgn)
ShapegetDirtyRegion(int srcIndex, Rectangle inputRgn)
intgetHeight()
intgetMinTileX()
intgetMinTileY()
intgetMinX()
intgetMinY()
intgetNumXTiles()
intgetNumYTiles()
ObjectgetProperty(String name)
String[]getPropertyNames()
SampleModelgetSampleModel()
VectorgetSources()
RastergetTile(int tileX, int tileY)
intgetTileGridXOffset()
intgetTileGridYOffset()
intgetTileHeight()
intgetTileWidth()
intgetWidth()
intgetXTile(int xloc)
Returns the x index of tile under xloc.
intgetYTile(int yloc)
Returns the y index of tile under yloc.
protected voidinit(CachableRed src, Rectangle bounds, ColorModel cm, SampleModel sm, int tileGridXOff, int tileGridYOff, Map props)
This is one of two basic init function (this is for single source rendereds).
protected voidinit(List srcs, Rectangle bounds, ColorModel cm, SampleModel sm, int tileGridXOff, int tileGridYOff, Map props)
This is the basic init function.
WritableRastermakeTile(int tileX, int tileY)
This is a helper function that will create the tile requested Including properly subsetting the bounds of the tile to the bounds of the current image.
protected voidupdateTileGridInfo()
This function computes all the basic information about the tile grid based on the data stored in sm, and tileGridX/YOff.

Field Detail

bounds

protected Rectangle bounds

cm

protected ColorModel cm

minTileX

protected int minTileX

minTileY

protected int minTileY

numXTiles

protected int numXTiles

numYTiles

protected int numYTiles

props

protected Map props

sm

protected SampleModel sm

srcs

protected Vector srcs

tileGridXOff

protected int tileGridXOff

tileGridYOff

protected int tileGridYOff

tileHeight

protected int tileHeight

tileWidth

protected int tileWidth

Constructor Detail

AbstractRed

protected AbstractRed()
void constructor. The subclass must call one of the flavors of init before the object becomes usable. This is useful when the proper parameters to the init method need to be computed in the subclasses constructor.

AbstractRed

protected AbstractRed(Rectangle bounds, Map props)
Construct an Abstract RenderedImage from a bounds rect and props (may be null). The srcs Vector will be empty.

Parameters: bounds this defines the extent of the rable in the user coordinate system. props this initializes the props Map (may be null)

AbstractRed

protected AbstractRed(CachableRed src, Map props)
Construct an Abstract RenderedImage from a source image and props (may be null).

Parameters: src will be the first (and only) member of the srcs Vector. Src is also used to set the bounds, ColorModel, SampleModel, and tile grid offsets. props this initializes the props Map.

AbstractRed

protected AbstractRed(CachableRed src, Rectangle bounds, Map props)
Construct an Abstract RenderedImage from a source image, bounds rect and props (may be null).

Parameters: src will be the first (and only) member of the srcs Vector. Src is also used to set the ColorModel, SampleModel, and tile grid offsets. bounds The bounds of this image. props this initializes the props Map.

AbstractRed

protected AbstractRed(CachableRed src, Rectangle bounds, ColorModel cm, SampleModel sm, Map props)
Construct an Abstract RenderedImage from a source image, bounds rect and props (may be null).

Parameters: src if not null, will be the first (and only) member of the srcs Vector. Also if it is not null it provides the tile grid offsets, otherwise they are zero. bounds The bounds of this image. cm The ColorModel to use. If null it will default to ComponentColorModel. sm The sample model to use. If null it will construct a sample model the matches the given/generated ColorModel and is the size of bounds. props this initializes the props Map.

AbstractRed

protected AbstractRed(CachableRed src, Rectangle bounds, ColorModel cm, SampleModel sm, int tileGridXOff, int tileGridYOff, Map props)
Construct an Abstract Rable from a bounds rect and props (may be null). The srcs Vector will be empty.

Parameters: src will be the first (and only) member of the srcs Vector. Src is also used to set the ColorModel, SampleModel, and tile grid offsets. bounds this defines the extent of the rable in the user coordinate system. cm The ColorModel to use. If null it will default to ComponentColorModel. sm The sample model to use. If null it will construct a sample model the matches the given/generated ColorModel and is the size of bounds. tileGridXOff The x location of tile 0,0. tileGridYOff The y location of tile 0,0. props this initializes the props Map.

AbstractRed

protected AbstractRed(List srcs, Rectangle bounds, Map props)
Construct an Abstract Rable from a List of sources a bounds rect and props (may be null).

Parameters: srcs This is used to initialize the srcs Vector. All the members of srcs must be CachableRed otherwise an error will be thrown. bounds this defines the extent of the rendered in pixels props this initializes the props Map.

AbstractRed

protected AbstractRed(List srcs, Rectangle bounds, ColorModel cm, SampleModel sm, Map props)
Construct an Abstract RenderedImage from a bounds rect, ColorModel (may be null), SampleModel (may be null) and props (may be null). The srcs Vector will be empty.

Parameters: srcs This is used to initialize the srcs Vector. All the members of srcs must be CachableRed otherwise an error will be thrown. bounds this defines the extent of the rendered in pixels cm The ColorModel to use. If null it will default to ComponentColorModel. sm The sample model to use. If null it will construct a sample model the matches the given/generated ColorModel and is the size of bounds. props this initializes the props Map.

AbstractRed

protected AbstractRed(List srcs, Rectangle bounds, ColorModel cm, SampleModel sm, int tileGridXOff, int tileGridYOff, Map props)
Construct an Abstract RenderedImage from a bounds rect, ColorModel (may be null), SampleModel (may be null), tile grid offsets and props (may be null). The srcs Vector will be empty.

Parameters: srcs This is used to initialize the srcs Vector. All the members of srcs must be CachableRed otherwise an error will be thrown. bounds this defines the extent of the rable in the user coordinate system. cm The ColorModel to use. If null it will default to ComponentColorModel. sm The sample model to use. If null it will construct a sample model the matches the given/generated ColorModel and is the size of bounds. tileGridXOff The x location of tile 0,0. tileGridYOff The y location of tile 0,0. props this initializes the props Map.

Method Detail

copyBand

public static void copyBand(Raster src, int srcBand, WritableRaster dst, int dstBand)

copyToRaster

public void copyToRaster(WritableRaster wr)
Copies data from this images tile grid into wr. wr may extend outside the bounds of this image in which case the data in wr outside the bounds will not be touched.

Parameters: wr Raster to fill with image data.

getBounds

public Rectangle getBounds()

getColorModel

public ColorModel getColorModel()

getData

public Raster getData()

getData

public Raster getData(Rectangle rect)

getDependencyRegion

public Shape getDependencyRegion(int srcIndex, Rectangle outputRgn)

getDirtyRegion

public Shape getDirtyRegion(int srcIndex, Rectangle inputRgn)

getHeight

public int getHeight()

getMinTileX

public int getMinTileX()

getMinTileY

public int getMinTileY()

getMinX

public int getMinX()

getMinY

public int getMinY()

getNumXTiles

public int getNumXTiles()

getNumYTiles

public int getNumYTiles()

getProperty

public Object getProperty(String name)

getPropertyNames

public String[] getPropertyNames()

getSampleModel

public SampleModel getSampleModel()

getSources

public Vector getSources()

getTile

public Raster getTile(int tileX, int tileY)

getTileGridXOffset

public int getTileGridXOffset()

getTileGridYOffset

public int getTileGridYOffset()

getTileHeight

public int getTileHeight()

getTileWidth

public int getTileWidth()

getWidth

public int getWidth()

getXTile

public final int getXTile(int xloc)
Returns the x index of tile under xloc.

Parameters: xloc the x location (in pixels) to get tile for.

Returns: The tile index under xloc (may be outside tile grid).

getYTile

public final int getYTile(int yloc)
Returns the y index of tile under yloc.

Parameters: yloc the y location (in pixels) to get tile for.

Returns: The tile index under yloc (may be outside tile grid).

init

protected void init(CachableRed src, Rectangle bounds, ColorModel cm, SampleModel sm, int tileGridXOff, int tileGridYOff, Map props)
This is one of two basic init function (this is for single source rendereds). It is provided so subclasses can compute various values before initializing all the state in the base class. You really should call this method before returning from your subclass constructor.

Parameters: src The source for the filter bounds The bounds of the image cm The ColorModel to use. If null it defaults to ComponentColorModel/ src's ColorModel. sm The Sample modle to use. If this is null it will use the src's sample model if that is null it will construct a sample model that matches the ColorModel and is the size of the whole image. tileGridXOff The x location of tile 0,0. tileGridYOff The y location of tile 0,0. props Any properties you want to associate with the image.

init

protected void init(List srcs, Rectangle bounds, ColorModel cm, SampleModel sm, int tileGridXOff, int tileGridYOff, Map props)
This is the basic init function. It is provided so subclasses can compute various values before initializing all the state in the base class. You really should call this method before returning from your subclass constructor.

Parameters: srcs The list of sources bounds The bounds of the image cm The ColorModel to use. If null it defaults to ComponentColorModel. sm The Sample modle to use. If this is null it will construct a sample model that matches the ColorModel and is the size of the whole image. tileGridXOff The x location of tile 0,0. tileGridYOff The y location of tile 0,0. props Any properties you want to associate with the image.

makeTile

public WritableRaster makeTile(int tileX, int tileY)
This is a helper function that will create the tile requested Including properly subsetting the bounds of the tile to the bounds of the current image.

Parameters: tileX The x index of the tile to be built tileY The y index of the tile to be built

Returns: The tile requested

Throws: IndexOutOfBoundsException if the requested tile index falles outside of the bounds of the tile grid for the image.

updateTileGridInfo

protected void updateTileGridInfo()
This function computes all the basic information about the tile grid based on the data stored in sm, and tileGridX/YOff. It is responsible for updating tileWidth, tileHeight, minTileX/Y, and numX/YTiles.
Copyright B) 2008 Apache Software Foundation. All Rights Reserved.