Class AbstractRed
- java.lang.Object
-
- org.apache.batik.ext.awt.image.rendered.AbstractRed
-
- All Implemented Interfaces:
java.awt.image.RenderedImage,CachableRed
- Direct Known Subclasses:
AbstractTiledRed,AffineRed,Any2LsRGBRed,Any2LumRed,Any2sRGBRed,BufferedImageCachableRed,ColorMatrixRed,ComponentTransferRed,CompositeRed,DiffuseLightingRed,DisplacementMapRed,FilterAlphaRed,FilterAsAlphaRed,FloodRed,FormatRed,GaussianBlurRed8Bit,GraphicsNodeRed8Bit,HistogramRed,MultiplyAlphaRed,PadRed,PNGRed,ProfileRed,TileRed,TranslateRed,TurbulencePatternRed
public abstract class AbstractRed extends java.lang.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.- Version:
- $Id: AbstractRed.java 1804130 2017-08-04 14:41:11Z ssteiner $
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.Rectangleboundsprotected java.awt.image.ColorModelcmprotected intminTileXprotected intminTileYprotected intnumXTilesprotected intnumYTilesprotected java.util.Mappropsprotected java.awt.image.SampleModelsmprotected java.util.Vectorsrcsprotected inttileGridXOffprotected inttileGridYOffprotected inttileHeightprotected inttileWidth
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractRed()void constructor.protectedAbstractRed(java.awt.Rectangle bounds, java.util.Map props)Construct an Abstract RenderedImage from a bounds rect and props (may be null).protectedAbstractRed(java.util.List srcs, java.awt.Rectangle bounds, java.awt.image.ColorModel cm, java.awt.image.SampleModel sm, int tileGridXOff, int tileGridYOff, java.util.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).protectedAbstractRed(java.util.List srcs, java.awt.Rectangle bounds, java.awt.image.ColorModel cm, java.awt.image.SampleModel sm, java.util.Map props)Construct an Abstract RenderedImage from a bounds rect, ColorModel (may be null), SampleModel (may be null) and props (may be null).protectedAbstractRed(java.util.List srcs, java.awt.Rectangle bounds, java.util.Map props)Construct an Abstract Rable from a List of sources a bounds rect and props (may be null).protectedAbstractRed(CachableRed src, java.awt.Rectangle bounds, java.awt.image.ColorModel cm, java.awt.image.SampleModel sm, int tileGridXOff, int tileGridYOff, java.util.Map props)Construct an Abstract Rable from a bounds rect and props (may be null).protectedAbstractRed(CachableRed src, java.awt.Rectangle bounds, java.awt.image.ColorModel cm, java.awt.image.SampleModel sm, java.util.Map props)Construct an Abstract RenderedImage from a source image, bounds rect and props (may be null).protectedAbstractRed(CachableRed src, java.awt.Rectangle bounds, java.util.Map props)Construct an Abstract RenderedImage from a source image, bounds rect and props (may be null).protectedAbstractRed(CachableRed src, java.util.Map props)Construct an Abstract RenderedImage from a source image and props (may be null).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidcopyBand(java.awt.image.Raster src, int srcBand, java.awt.image.WritableRaster dst, int dstBand)voidcopyToRaster(java.awt.image.WritableRaster wr)Copies data from this images tile grid into wr.java.awt.RectanglegetBounds()Returns the bounds of the current image.java.awt.image.ColorModelgetColorModel()java.awt.image.RastergetData()java.awt.image.RastergetData(java.awt.Rectangle rect)java.awt.ShapegetDependencyRegion(int srcIndex, java.awt.Rectangle outputRgn)Returns the region of input data is is required to generate outputRgn.java.awt.ShapegetDirtyRegion(int srcIndex, java.awt.Rectangle inputRgn)This calculates the region of output that is affected by a change in a region of input.intgetHeight()intgetMinTileX()intgetMinTileY()intgetMinX()intgetMinY()intgetNumXTiles()intgetNumYTiles()java.lang.ObjectgetProperty(java.lang.String name)java.lang.String[]getPropertyNames()java.awt.image.SampleModelgetSampleModel()java.util.VectorgetSources()java.awt.image.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(java.util.List srcs, java.awt.Rectangle bounds, java.awt.image.ColorModel cm, java.awt.image.SampleModel sm, int tileGridXOff, int tileGridYOff, java.util.Map props)This is the basic init function.protected voidinit(CachableRed src, java.awt.Rectangle bounds, java.awt.image.ColorModel cm, java.awt.image.SampleModel sm, int tileGridXOff, int tileGridYOff, java.util.Map props)This is one of two basic init function (this is for single source rendereds).java.awt.image.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 java.awt.Rectangle bounds
-
srcs
protected java.util.Vector srcs
-
props
protected java.util.Map props
-
sm
protected java.awt.image.SampleModel sm
-
cm
protected java.awt.image.ColorModel 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 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(java.awt.Rectangle bounds, java.util.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, java.util.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, java.awt.Rectangle bounds, java.util.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, java.awt.Rectangle bounds, java.awt.image.ColorModel cm, java.awt.image.SampleModel sm, java.util.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, java.awt.Rectangle bounds, java.awt.image.ColorModel cm, java.awt.image.SampleModel sm, int tileGridXOff, int tileGridYOff, java.util.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(java.util.List srcs, java.awt.Rectangle bounds, java.util.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 pixelsprops- this initializes the props Map.
-
AbstractRed
protected AbstractRed(java.util.List srcs, java.awt.Rectangle bounds, java.awt.image.ColorModel cm, java.awt.image.SampleModel sm, java.util.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 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(java.util.List srcs, java.awt.Rectangle bounds, java.awt.image.ColorModel cm, java.awt.image.SampleModel sm, int tileGridXOff, int tileGridYOff, java.util.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
-
init
protected void init(CachableRed src, java.awt.Rectangle bounds, java.awt.image.ColorModel cm, java.awt.image.SampleModel sm, int tileGridXOff, int tileGridYOff, java.util.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(java.util.List srcs, java.awt.Rectangle bounds, java.awt.image.ColorModel cm, java.awt.image.SampleModel sm, int tileGridXOff, int tileGridYOff, java.util.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
public java.awt.Rectangle getBounds()
Description copied from interface:CachableRedReturns the bounds of the current image. This should be 'in sync' with getMinX, getMinY, getWidth, getHeight- Specified by:
getBoundsin interfaceCachableRed
-
getSources
public java.util.Vector getSources()
- Specified by:
getSourcesin interfacejava.awt.image.RenderedImage
-
getColorModel
public java.awt.image.ColorModel getColorModel()
- Specified by:
getColorModelin interfacejava.awt.image.RenderedImage
-
getSampleModel
public java.awt.image.SampleModel getSampleModel()
- Specified by:
getSampleModelin interfacejava.awt.image.RenderedImage
-
getMinX
public int getMinX()
- Specified by:
getMinXin interfacejava.awt.image.RenderedImage
-
getMinY
public int getMinY()
- Specified by:
getMinYin interfacejava.awt.image.RenderedImage
-
getWidth
public int getWidth()
- Specified by:
getWidthin interfacejava.awt.image.RenderedImage
-
getHeight
public int getHeight()
- Specified by:
getHeightin interfacejava.awt.image.RenderedImage
-
getTileWidth
public int getTileWidth()
- Specified by:
getTileWidthin interfacejava.awt.image.RenderedImage
-
getTileHeight
public int getTileHeight()
- Specified by:
getTileHeightin interfacejava.awt.image.RenderedImage
-
getTileGridXOffset
public int getTileGridXOffset()
- Specified by:
getTileGridXOffsetin interfacejava.awt.image.RenderedImage
-
getTileGridYOffset
public int getTileGridYOffset()
- Specified by:
getTileGridYOffsetin interfacejava.awt.image.RenderedImage
-
getMinTileX
public int getMinTileX()
- Specified by:
getMinTileXin interfacejava.awt.image.RenderedImage
-
getMinTileY
public int getMinTileY()
- Specified by:
getMinTileYin interfacejava.awt.image.RenderedImage
-
getNumXTiles
public int getNumXTiles()
- Specified by:
getNumXTilesin interfacejava.awt.image.RenderedImage
-
getNumYTiles
public int getNumYTiles()
- Specified by:
getNumYTilesin interfacejava.awt.image.RenderedImage
-
getProperty
public java.lang.Object getProperty(java.lang.String name)
- Specified by:
getPropertyin interfacejava.awt.image.RenderedImage
-
getPropertyNames
public java.lang.String[] getPropertyNames()
- Specified by:
getPropertyNamesin interfacejava.awt.image.RenderedImage
-
getDependencyRegion
public java.awt.Shape getDependencyRegion(int srcIndex, java.awt.Rectangle outputRgn)Description copied from interface:CachableRedReturns the region of input data is is required to generate outputRgn.- Specified by:
getDependencyRegionin 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
public java.awt.Shape getDirtyRegion(int srcIndex, java.awt.Rectangle inputRgn)Description copied from interface:CachableRedThis calculates the region of output that is affected by a change in a region of input.- Specified by:
getDirtyRegionin 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
public java.awt.image.Raster getTile(int tileX, int tileY)- Specified by:
getTilein interfacejava.awt.image.RenderedImage
-
getData
public java.awt.image.Raster getData()
- Specified by:
getDatain interfacejava.awt.image.RenderedImage
-
getData
public java.awt.image.Raster getData(java.awt.Rectangle rect)
- Specified by:
getDatain interfacejava.awt.image.RenderedImage
-
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
public void copyToRaster(java.awt.image.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.
-
makeTile
public java.awt.image.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 builttileY- The y index of the tile to be built- Returns:
- The tile requested
- Throws:
java.lang.IndexOutOfBoundsException- if the requested tile index falles outside of the bounds of the tile grid for the image.
-
copyBand
public static void copyBand(java.awt.image.Raster src, int srcBand, java.awt.image.WritableRaster dst, int dstBand)
-
-