Class TLcdBufferedTile

java.lang.Object
com.luciad.format.raster.TLcdBufferedTile
All Implemented Interfaces:
ILcdSubtiledTile, ILcdTile, ILcdDisposable, AutoCloseable
Direct Known Subclasses:
TLcdCADRGTile, TLcdDTEDTile, TLcdUSRPTile

public class TLcdBufferedTile extends Object implements ILcdSubtiledTile, ILcdDisposable
This implementation of ILcdTile provides lazy decoding of image data that can be retrieved from a file or from a URL. The actual decoding is left to an ILcdTileDecoder.

The decoded data are stored in an ILcdBuffer. Such a buffer generally serves as a cache that is shared across the application. Decoded data may therefore be flushed as the buffer is filled by other classes or instances. The data then get decoded again when needed, transparently to the user.

If the provided tile decoder supports it, the tile can be subtiled. Only subtiles are then decoded at a time, which provides improved performance and memory usage for large tiles.

This class is thread-safe for concurrent read-only access of its contents, on the condition that a thread-safe buffer implementation is used.

  • Field Details

    • fURL

      protected URL fURL
    • fFileName

      protected String fFileName
    • fImageIndex

      protected int fImageIndex
    • fWidth

      protected volatile int fWidth
    • fHeight

      protected volatile int fHeight
    • fSubTileWidth

      protected volatile int fSubTileWidth
    • fSubTileHeight

      protected volatile int fSubTileHeight
    • fDecoder

      protected ILcdTileDecoder fDecoder
    • fBuffer

      protected ILcdBuffer fBuffer
    • fDefaultValue

      protected int fDefaultValue
    • fColorModel

      protected volatile ColorModel fColorModel
    • fForcedTransparentColorIndex

      protected int fForcedTransparentColorIndex
    • fType

      protected volatile int fType
    • fBitOffset

      protected volatile int fBitOffset
    • fPixelSize

      protected volatile int fPixelSize
    • fSigned

      protected volatile boolean fSigned
    • fIsAllDefault

      protected volatile boolean fIsAllDefault
  • Constructor Details

    • TLcdBufferedTile

      public TLcdBufferedTile(String aFileName, int aImageIndex, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer)
      Creates a TLcdBufferedTile of an image accessible through a given file name. The tile parameters will be determined by the ILcdTileDecoder.
    • TLcdBufferedTile

      public TLcdBufferedTile(String aFileName, int aImageIndex, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer, int aPixelSize, int aDefaultValue)
      Creates a TLcdBufferedTile of an image accessible through a given file name. The ColorModel of the tile will be determined by the ILcdTileDecoder.
    • TLcdBufferedTile

      public TLcdBufferedTile(String aFileName, int aImageIndex, int aSubTileWidth, int aSubTileHeight, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer, int aPixelSize, int aDefaultValue)
      Creates a TLcdBufferedTile of an image accessible through a given file name. The size and ColorModel of the tile will be determined by the ILcdTileDecoder. The tile is sub-tiled with sub-tiles of a given size.
    • TLcdBufferedTile

      public TLcdBufferedTile(String aFileName, int aImageIndex, int aWidth, int aHeight, int aSubTileWidth, int aSubTileHeight, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer, int aPixelSize, int aDefaultValue, ColorModel aColorModel)
      Creates a TLcdBufferedTile of an image accessible through a given file name. The tile is sub-tiled with sub-tiles of a given size. By default, only short pixel values are considered signed.

      A typical example of a constructor could be:

      new TLcdBufferedTile(aFileName, 0, 512, 512, 256, 256, aDecoder, aBuffer, 32, 0, ColorModel.getRGBdefault()) This constructor creates a buffered tile of 512 by 512 pixels, with sub-tiles of 256 by 256 pixels. Each pixel is specified using a 32-bit integer with a default value of 0, in the default DirectColorModel.

      Parameters:
      aFileName - the name of the file that contains the image.
      aImageIndex - the index of the image to decode from a multi-image file.
      aWidth - the number of columns of pixels in the tile.
      aHeight - the number of rows of pixels in the tile.
      aSubTileWidth - the total number of rows of sub-tiles in which the image (URL) is divided horizontally.
      aSubTileHeight - the total number of columns of sub-tiles in which the image (URL) is divided vertically.
      aDecoder - an image decoder knowing how to read and decode pixels of a sub-tile from an image.
      aBuffer - the buffer that will be used for caching the pixel values of the tile.
      aPixelSize - the number of bits used to specify a pixel value.
      aDefaultValue - a default value for pixels that can't be resolved.
      aColorModel - an optional ColorModel for the pixels.
    • TLcdBufferedTile

      public TLcdBufferedTile(String aFileName, int aImageIndex, int aWidth, int aHeight, int aSubTileWidth, int aSubTileHeight, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer, int aPixelSize, int aDefaultValue, ColorModel aColorModel, boolean aSigned)
      Creates a TLcdBufferedTile of an image accessible through a given file name. The tile is sub-tiled with sub-tiles of a given size.

      A typical example of a constructor could be:

      new TLcdBufferedTile(aFileName, 0, 512, 512, 256, 256, aDecoder, aBuffer, 16, 0xffff, aIndexColorModel, false) This constructor creates a buffered tile of 512 by 512 pixels, with sub-tiles of 256 by 256 pixels. Each pixel is specified using an unsigned 16-bits integer with a default value of 0xffff, and an IndexColorModel (which must be 16-bits also).

      Parameters:
      aFileName - the name of the file that contains the image.
      aImageIndex - the index of the image to decode from a multi-image file.
      aWidth - the number of columns of pixels in the tile.
      aHeight - the number of rows of pixels in the tile.
      aSubTileWidth - the total number of rows of sub-tiles in which the image (URL) is divided horizontally.
      aSubTileHeight - the total number of columns of sub-tiles in which the image (URL) is divided vertically.
      aDecoder - an image decoder knowing how to read and decode pixels of a sub-tile from an image.
      aBuffer - the buffer that will be used for caching the pixel values of the tile.
      aPixelSize - the number of bits used to specify a pixel value.
      aDefaultValue - a default value for pixels that can't be resolved.
      aColorModel - an optional ColorModel for the pixels.
      aSigned - specifies whether the pixel values are signed.
    • TLcdBufferedTile

      public TLcdBufferedTile(URL aURL, int aImageIndex, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer)
      Creates a TLcdBufferedTile of an image accessible through a given URL. The tile parameters will be determined by the ILcdTileDecoder.
    • TLcdBufferedTile

      public TLcdBufferedTile(URL aURL, int aImageIndex, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer, int aPixelSize, int aDefaultValue)
      Creates a TLcdBufferedTile of an image accessible through a given URL. The size and ColorModel of the tile will be determined by the ILcdTileDecoder.
    • TLcdBufferedTile

      public TLcdBufferedTile(URL aURL, int aImageIndex, int aSubTileWidth, int aSubTileHeight, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer, int aPixelSize, int aDefaultValue)
      Creates a TLcdBufferedTile of an image accessible through a given URL. The size and ColorModel of the tile will be determined by the ILcdTileDecoder. The tile is sub-tiled with sub-tiles of a given size.
    • TLcdBufferedTile

      public TLcdBufferedTile(URL aURL, int aImageIndex, int aWidth, int aHeight, int aSubTileWidth, int aSubTileHeight, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer, int aPixelSize, int aDefaultValue, ColorModel aColorModel)
      Creates a TLcdBufferedTile as a sub-tile of an image accessible through a given URL. The size and ColorModel of the tile will be determined by the ILcdTileDecoder. The tile is sub-tiled with sub-tiles of a given size.

      new TLcdBufferedTile(aURL, 0, 512, 512, 256, 256, aDecoder, aBuffer, 32, 0, ColorModel.getRGBdefault()) This constructor creates a buffered tile of 512 by 512 pixels, with sub-tiles of 256 by 256 pixels. Each pixel is specified using a 32-bit integer with a default value of 0, in e default DirectColorModel.

      Parameters:
      aURL - URL defining the underlying image for the tile.
      aImageIndex - the index of the image to decode from a multi-image file.
      aWidth - the number of columns of pixels in the tile.
      aHeight - the number of rows of pixels in the tile.
      aSubTileWidth - the total number of rows of sub-tiles in which the image (URL) is divided horizontally.
      aSubTileHeight - the total number of columns of sub-tiles in which the image (URL) is divided vertically.
      aDecoder - an image decoder knowing how to read and decode pixels of a sub-tile from an image.
      aBuffer - the buffer that will be used for caching the pixel values of the tile.
      aPixelSize - the number of bits used to specify a pixel value.
      aDefaultValue - a default value for pixels that can't be resolved.
      aColorModel - an optional ColorModel for the pixels.
    • TLcdBufferedTile

      public TLcdBufferedTile(String aFileName, int aImageIndex, ILcdTileDecoder aDecoder, int aType, int aBitOffset, int aPixelSize, ILcdBuffer aBuffer, int aDefaultValue)
      Deprecated.
      Type and offset don't need to be specified; they are now decoded by the given ILcdTileDecoder.
      See Also:
    • TLcdBufferedTile

      public TLcdBufferedTile(String aFileName, int aImageIndex, int aSubTileWidth, int aSubTileHeight, ILcdTileDecoder aDecoder, int aType, int aBitOffset, int aPixelSize, ILcdBuffer aBuffer, int aDefaultValue)
      Deprecated.
      Type and offset don't need to be specified; they are now decoded by the given ILcdTileDecoder.
      See Also:
    • TLcdBufferedTile

      public TLcdBufferedTile(String aFileName, int aImageIndex, int aWidth, int aHeight, int aSubTileWidth, int aSubTileHeight, ILcdTileDecoder aDecoder, int aType, int aBitOffset, int aPixelSize, ILcdBuffer aBuffer, int aDefaultValue, ColorModel aColorModel)
      Deprecated.
      Type and offset don't need to be specified; they are now decoded by the given ILcdTileDecoder.
      See Also:
    • TLcdBufferedTile

      public TLcdBufferedTile(URL aURL, int aImageIndex, ILcdTileDecoder aDecoder, int aType, int aBitOffset, int aPixelSize, ILcdBuffer aBuffer, int aDefaultValue)
      Deprecated.
      Type and offset don't need to be specified; they are now decoded by the given ILcdTileDecoder.
      See Also:
    • TLcdBufferedTile

      public TLcdBufferedTile(URL aURL, int aImageIndex, int aSubTileWidth, int aSubTileHeight, ILcdTileDecoder aDecoder, int aType, int aBitOffset, int aPixelSize, ILcdBuffer aBuffer, int aDefaultValue)
      Deprecated.
      Type and offset don't need to be specified; they are now decoded by the given ILcdTileDecoder.
      See Also:
    • TLcdBufferedTile

      public TLcdBufferedTile(URL aURL, int aImageIndex, int aWidth, int aHeight, int aSubTileWidth, int aSubTileHeight, ILcdTileDecoder aDecoder, int aType, int aBitOffset, int aPixelSize, ILcdBuffer aBuffer, int aDefaultValue, ColorModel aColorModel)
      Deprecated.
      Type and offset don't need to be specified; they are now decoded by the given ILcdTileDecoder.
      See Also:
  • Method Details

    • setClassTraceOn

      public static void setClassTraceOn(boolean aClassTraceOn)
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Enables tracing for all instances of this class. If the argument is true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
      Parameters:
      aClassTraceOn - if true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
    • setTraceOn

      public void setTraceOn(boolean aTraceOn)
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Enables tracing for this class instance. Calling this method with either true or false as argument automatically turns off tracing for all other class instances for which setTraceOn has not been called. If the argument is false then only the informative, warning and error log messages are recorded.
      Parameters:
      aTraceOn - if true then all log messages are recorded for this instance. If false, then only the informative, warning and error log messages are recorded.
    • isTraceOn

      public boolean isTraceOn()
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Returns true if tracing is enabled for this class.
      Returns:
      true if tracing is enabled for this class, false otherwise.
    • setURL

      public void setURL(URL aURL)
      Sets the URL of the file from which the tile is to be read.
    • getURL

      public URL getURL()
      Returns the URL from which the tile is read, if it has been set.
    • setFileName

      public void setFileName(String aFileName)
      Sets the name of the file from which the tile is to be read.
    • getFileName

      public String getFileName()
      Returns the name of the file from which the tile is read, if it has been set.
    • setImageIndex

      public void setImageIndex(int aImageIndex)
      Sets the index of the image to decode from a multi-image file.
    • getImageIndex

      public int getImageIndex()
      Returns the index of the image to be read. The meaning of the index can depend on the file format that the tile decoder decodes.
    • setSigned

      public void setSigned(boolean aIsSigned)
      Specifies whether the pixel values are signed.
    • isSigned

      public boolean isSigned()
      Returns whether the pixel values are signed.
    • setWidth

      public void setWidth(int aWidth)
    • getWidth

      public int getWidth()
      Description copied from interface: ILcdTile
      Returns the width of the tile, expressed in pixels.
      Specified by:
      getWidth in interface ILcdTile
    • setHeight

      public void setHeight(int aHeight)
    • getHeight

      public int getHeight()
      Description copied from interface: ILcdTile
      Returns the height of the tile, expressed in pixels.
      Specified by:
      getHeight in interface ILcdTile
    • getType

      public int getType()
      Description copied from interface: ILcdTile
      Returns the internal storage type of the tile values.
      Specified by:
      getType in interface ILcdTile
      Returns:
      one of BYTE, SHORT, or INT.
    • getPixelSize

      public int getPixelSize()
      Description copied from interface: ILcdTile
      Returns the pixel size of the tile values, expressed in bits.
      Specified by:
      getPixelSize in interface ILcdTile
    • getBitOffset

      public int getBitOffset()
    • setColorModel

      public void setColorModel(ColorModel aColorModel)
    • getColorModel

      public ColorModel getColorModel()
      Description copied from interface: ILcdTile
      Returns the optional color model of the tile.
      Specified by:
      getColorModel in interface ILcdTile
      Returns:
      the color model, or null if the raster doesn't have an explicit color model.
    • isAllDefault

      public boolean isAllDefault()
      Description copied from interface: ILcdTile
      Returns whether all values in the tile are equal to a default value.
      Specified by:
      isAllDefault in interface ILcdTile
    • setForcedTransparentColorIndex

      public void setForcedTransparentColorIndex(int aForcedTransparentColorIndex)
      Sets the index of a color that should be made transparent. This can be useful if the RenderedImage has an IndexColorModel that doesn't have a transparent color of its own.
    • getForcedTransparentColorIndex

      public int getForcedTransparentColorIndex()
    • getTileDecoder

      public ILcdTileDecoder getTileDecoder()
    • getSubTileWidth

      public int getSubTileWidth()
      Description copied from interface: ILcdSubtiledTile
      Returns the width of a subtile in pixels. May be equal to the width of the parent tile (as returned by the getWidth() method), in which case the tile is not subdivided.
      Specified by:
      getSubTileWidth in interface ILcdSubtiledTile
    • getSubTileHeight

      public int getSubTileHeight()
      Description copied from interface: ILcdSubtiledTile
      Returns the height of a subtile in pixels. May be equal to the height of the parent tile (as returned by the getHeight() method), in which case the tile is not subdivided.
      Specified by:
      getSubTileHeight in interface ILcdSubtiledTile
    • retrieveValue

      public int retrieveValue(int aX, int aY)
      Description copied from interface: ILcdTile
      Retrieves the tile value at the specified location.
      Specified by:
      retrieveValue in interface ILcdTile
      Parameters:
      aX - the x ordinate of the value, expressed in tile coordinates.
      aY - the y ordinate of the value, expressed in tile coordinates.
      Returns:
      the integer tile value at the specified location.
    • retrieveTile

      protected ILcdBufferSegment retrieveTile(int aSubTileRow, int aSubTileColumn)
      Decodes the specified subtile.
      Parameters:
      aSubTileRow - the subtile row.
      aSubTileColumn - the subtile column.
      Returns:
      the decoded tile contents.
    • createImage

      public Image createImage()
      Description copied from interface: ILcdTile
      Creates an image of the entire tile, using the tile's own color model.
      Specified by:
      createImage in interface ILcdTile
    • createImage

      public Image createImage(ColorModel aColorModel)
      Description copied from interface: ILcdTile
      Creates an image of the entire tile, using the given color model.
      Specified by:
      createImage in interface ILcdTile
      Parameters:
      aColorModel - the color model to be used for the image. The color model should be compatible with the pixel values of the tile.
    • createImage

      public Image createImage(int aX, int aY, int aWidth, int aHeight)
      Description copied from interface: ILcdTile
      Creates an image of the specified rectangular area of the tile, using the tile's own color model.
      Specified by:
      createImage in interface ILcdTile
      Parameters:
      aX - the x ordinate of the area, expressed in tile coordinates.
      aY - the y ordinate of the area, expressed in tile coordinates.
      aWidth - the width of the area, expressed in tile coordinates.
      aHeight - the height of the area, expressed in tile coordinates.
    • createImage

      public Image createImage(int aX, int aY, int aWidth, int aHeight, ColorModel aColorModel)
      Description copied from interface: ILcdTile
      Creates an image of the specified rectangular area of the tile, using the given color model.
      Specified by:
      createImage in interface ILcdTile
      Parameters:
      aX - the x ordinate of the area, expressed in tile coordinates.
      aY - the y ordinate of the area, expressed in tile coordinates.
      aWidth - the width of the area, expressed in tile coordinates.
      aHeight - the height of the area, expressed in tile coordinates.
      aColorModel - the color model to be used for the image. The color model should be compatible with the pixel values of the tile.
    • dispose

      public void dispose()
      Description copied from interface: ILcdDisposable

      Disposes of this object and allows it to release any system resources that it is holding.

      The result of calling any other method (other than finalize) on this object subsequent to a call to this method is undefined.

      Specified by:
      dispose in interface ILcdDisposable