Class AbstractRed
java.lang.Object
org.apache.xmlgraphics.image.rendered.AbstractRed
- All Implemented Interfaces:
RenderedImage
,CachableRed
- Direct Known Subclasses:
Any2LsRGBRed
,Any2sRGBRed
,BufferedImageCachableRed
,FormatRed
,PNGRed
,TIFFImage
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.
- Version:
- $Id$ Originally authored by Thomas DeWeese.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Rectangle
protected ColorModel
protected int
protected int
protected int
protected int
protected Map
protected SampleModel
protected Vector
protected int
protected int
protected int
protected int
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
void constructor.protected
AbstractRed
(Rectangle bounds, Map props) Construct an Abstract RenderedImage from a bounds rect 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).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, Map props) Construct an Abstract Rable from a List of sources a 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
(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, Map props) Construct an Abstract RenderedImage from a source image, 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). -
Method Summary
Modifier and TypeMethodDescriptionstatic void
copyBand
(Raster src, int srcBand, WritableRaster dst, int dstBand) void
Copies data from this images tile grid into wr.Returns the bounds of the current image.getData()
getDependencyRegion
(int srcIndex, Rectangle outputRgn) Returns the region of input data is is required to generate outputRgn.getDirtyRegion
(int srcIndex, Rectangle inputRgn) This calculates the region of output that is affected by a change in a region of input.int
int
int
int
getMinX()
int
getMinY()
int
int
getProperty
(String name) String[]
getTile
(int tileX, int tileY) int
int
int
int
int
getWidth()
final int
getXTile
(int xloc) Returns the x index of tile under xloc.final int
getYTile
(int yloc) Returns the y index of tile under yloc.protected void
init
(List srcs, Rectangle bounds, ColorModel cm, SampleModel sm, int tileGridXOff, int tileGridYOff, Map props) This is the basic init function.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).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.protected void
This function computes all the basic information about the tile grid based on the data stored in sm, and tileGridX/YOff.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.awt.image.RenderedImage
copyData
-
Field Details
-
bounds
-
srcs
-
props
-
sm
-
cm
-
tileGridXOff
protected int tileGridXOff -
tileGridYOff
protected int tileGridYOff -
tileWidth
protected int tileWidth -
tileHeight
protected int tileHeight -
minTileX
protected int minTileX -
minTileY
protected int minTileY -
numXTiles
protected int numXTiles -
numYTiles
protected int numYTiles
-
-
Constructor Details
-
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
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
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
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
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
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 pixelsprops
- this initializes the props Map.
-
AbstractRed
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 pixelscm
- 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 Details
-
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 filterbounds
- The bounds of the imagecm
- 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 sourcesbounds
- The bounds of the imagecm
- 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.
-
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. -
getBounds
Description copied from interface:CachableRed
Returns the bounds of the current image. This should be 'in sync' with getMinX, getMinY, getWidth, getHeight- Specified by:
getBounds
in interfaceCachableRed
-
getSources
- Specified by:
getSources
in interfaceRenderedImage
-
getColorModel
- Specified by:
getColorModel
in interfaceRenderedImage
-
getSampleModel
- Specified by:
getSampleModel
in interfaceRenderedImage
-
getMinX
public int getMinX()- Specified by:
getMinX
in interfaceRenderedImage
-
getMinY
public int getMinY()- Specified by:
getMinY
in interfaceRenderedImage
-
getWidth
public int getWidth()- Specified by:
getWidth
in interfaceRenderedImage
-
getHeight
public int getHeight()- Specified by:
getHeight
in interfaceRenderedImage
-
getTileWidth
public int getTileWidth()- Specified by:
getTileWidth
in interfaceRenderedImage
-
getTileHeight
public int getTileHeight()- Specified by:
getTileHeight
in interfaceRenderedImage
-
getTileGridXOffset
public int getTileGridXOffset()- Specified by:
getTileGridXOffset
in interfaceRenderedImage
-
getTileGridYOffset
public int getTileGridYOffset()- Specified by:
getTileGridYOffset
in interfaceRenderedImage
-
getMinTileX
public int getMinTileX()- Specified by:
getMinTileX
in interfaceRenderedImage
-
getMinTileY
public int getMinTileY()- Specified by:
getMinTileY
in interfaceRenderedImage
-
getNumXTiles
public int getNumXTiles()- Specified by:
getNumXTiles
in interfaceRenderedImage
-
getNumYTiles
public int getNumYTiles()- Specified by:
getNumYTiles
in interfaceRenderedImage
-
getProperty
- Specified by:
getProperty
in interfaceRenderedImage
-
getPropertyNames
- Specified by:
getPropertyNames
in interfaceRenderedImage
-
getDependencyRegion
Description copied from interface:CachableRed
Returns the region of input data is is required to generate outputRgn.- Specified by:
getDependencyRegion
in interfaceCachableRed
- Parameters:
srcIndex
- The source to do the dependency calculation for.outputRgn
- The region of output you are interested in generating dependencies for. The is given in the output pixel coordiate system for this node.- Returns:
- The region of input required. This is in the output pixel coordinate system for the source indicated by srcIndex.
-
getDirtyRegion
Description copied from interface:CachableRed
This calculates the region of output that is affected by a change in a region of input.- Specified by:
getDirtyRegion
in interfaceCachableRed
- Parameters:
srcIndex
- The input that inputRgn reflects changes in.inputRgn
- the region of input that has changed, used to calculate the returned shape. This is given in the pixel coordinate system of the source indicated by srcIndex.- Returns:
- The region of output that would be invalid given a change to inputRgn of the source selected by srcIndex. this is in the output pixel coordinate system of this node.
-
getTile
- Specified by:
getTile
in interfaceRenderedImage
-
getData
- Specified by:
getData
in interfaceRenderedImage
-
getData
- Specified by:
getData
in interfaceRenderedImage
-
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).
-
copyToRaster
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.
-
makeTile
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 builttileY
- 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.
-
copyBand
-