Class AbstractTiledRed

  • All Implemented Interfaces:
    java.awt.image.RenderedImage, CachableRed, TileGenerator
    Direct Known Subclasses:
    SpecularLightingRed, TileCacheRed

    public abstract class AbstractTiledRed
    extends AbstractRed
    implements TileGenerator
    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: AbstractTiledRed.java 1804130 2017-08-04 14:41:11Z ssteiner $
    • Field Detail

      • defaultTileSize

        private static int defaultTileSize
    • Constructor Detail

      • AbstractTiledRed

        protected AbstractTiledRed()
        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.
      • AbstractTiledRed

        protected AbstractTiledRed​(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)
      • AbstractTiledRed

        protected AbstractTiledRed​(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.
      • AbstractTiledRed

        protected AbstractTiledRed​(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.
      • AbstractTiledRed

        protected AbstractTiledRed​(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 - 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.
        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.
      • AbstractTiledRed

        protected AbstractTiledRed​(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.
      • AbstractTiledRed

        protected AbstractTiledRed​(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 pixels
        props - this initializes the props Map.
      • AbstractTiledRed

        protected AbstractTiledRed​(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 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.
      • AbstractTiledRed

        protected AbstractTiledRed​(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

      • getDefaultTileSize

        public static int getDefaultTileSize()
      • 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.
        Overrides:
        init in class AbstractRed
        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​(CachableRed src,
                            java.awt.Rectangle bounds,
                            java.awt.image.ColorModel cm,
                            java.awt.image.SampleModel sm,
                            int tileGridXOff,
                            int tileGridYOff,
                            TileStore tiles,
                            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 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.
        tiles - The tileStore to use (or null).
        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.
        Overrides:
        init in class AbstractRed
        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.
      • getTileStore

        public TileStore getTileStore()
      • setTileStore

        protected void setTileStore​(TileStore tiles)
      • createTileStore

        protected TileStore createTileStore()
      • copyData

        public java.awt.image.WritableRaster copyData​(java.awt.image.WritableRaster wr)
        Specified by:
        copyData in interface java.awt.image.RenderedImage
      • getData

        public java.awt.image.Raster getData​(java.awt.Rectangle rect)
        Specified by:
        getData in interface java.awt.image.RenderedImage
        Overrides:
        getData in class AbstractRed
      • getTile

        public java.awt.image.Raster getTile​(int x,
                                             int y)
        Specified by:
        getTile in interface java.awt.image.RenderedImage
        Overrides:
        getTile in class AbstractRed
      • genTile

        public java.awt.image.Raster genTile​(int x,
                                             int y)
        Specified by:
        genTile in interface TileGenerator
      • genRect

        public abstract void genRect​(java.awt.image.WritableRaster wr)
      • setTile

        public void setTile​(int x,
                            int y,
                            java.awt.image.Raster ras)
      • copyToRasterByBlocks

        public void copyToRasterByBlocks​(java.awt.image.WritableRaster wr)
      • 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.
        Overrides:
        copyToRaster in class AbstractRed
        Parameters:
        wr - Raster to fill with image data.
      • drawBlock

        protected void drawBlock​(TileBlock block,
                                 java.awt.image.WritableRaster wr)
      • drawBlockAndCopy

        protected void drawBlockAndCopy​(TileBlock[] blocks,
                                        java.awt.image.WritableRaster wr)
      • drawBlockInPlace

        protected void drawBlockInPlace​(TileBlock[] blocks,
                                        java.awt.image.WritableRaster wr)