public class TLcdBufferedTile extends Object implements ILcdSubtiledTile, ILcdDisposable
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.
Modifier and Type | Field and Description |
---|---|
protected int |
fBitOffset |
protected ILcdBuffer |
fBuffer |
protected ColorModel |
fColorModel |
protected ILcdTileDecoder |
fDecoder |
protected int |
fDefaultValue |
protected String |
fFileName |
protected int |
fForcedTransparentColorIndex |
protected int |
fHeight |
protected int |
fImageIndex |
protected boolean |
fIsAllDefault |
protected int |
fPixelSize |
protected boolean |
fSigned |
protected int |
fSubTileHeight |
protected int |
fSubTileWidth |
protected int |
fType |
protected URL |
fURL |
protected int |
fWidth |
Constructor and Description |
---|
TLcdBufferedTile(String aFileName,
int aImageIndex,
ILcdTileDecoder aDecoder,
ILcdBuffer aBuffer)
Creates a
TLcdBufferedTile of an image accessible through a given file name. |
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. |
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.
|
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. |
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.
|
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. |
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. |
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.
|
TLcdBufferedTile(URL aURL,
int aImageIndex,
ILcdTileDecoder aDecoder,
ILcdBuffer aBuffer)
Creates a
TLcdBufferedTile of an image accessible through a given URL. |
TLcdBufferedTile(URL aURL,
int aImageIndex,
ILcdTileDecoder aDecoder,
ILcdBuffer aBuffer,
int aPixelSize,
int aDefaultValue)
Creates a
TLcdBufferedTile of an image accessible through a given URL. |
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.
|
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. |
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.
|
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. |
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.
|
Modifier and Type | Method and Description |
---|---|
Image |
createImage()
Creates an image of the entire tile, using the tile's own color model.
|
Image |
createImage(ColorModel aColorModel)
Creates an image of the entire tile, using the given color model.
|
Image |
createImage(int aX,
int aY,
int aWidth,
int aHeight)
Creates an image of the specified rectangular area of the tile, using the
tile's own color model.
|
Image |
createImage(int aX,
int aY,
int aWidth,
int aHeight,
ColorModel aColorModel)
Creates an image of the specified rectangular area of the tile, using the
given color model.
|
void |
dispose()
Disposes of this object and allows it to release any system resources that it is holding.
|
int |
getBitOffset() |
ColorModel |
getColorModel()
Returns the optional color model of the tile.
|
String |
getFileName()
Returns the name of the file from which the tile is read, if it has been
set.
|
int |
getForcedTransparentColorIndex() |
int |
getHeight()
Returns the height of the tile, expressed in pixels.
|
int |
getImageIndex()
Returns the index of the image to be read.
|
int |
getPixelSize()
Returns the pixel size of the tile values, expressed in bits.
|
int |
getSubTileHeight()
Returns the height of a subtile in pixels.
|
int |
getSubTileWidth()
Returns the width of a subtile in pixels.
|
ILcdTileDecoder |
getTileDecoder() |
int |
getType()
Returns the internal storage type of the tile values.
|
URL |
getURL()
Returns the URL from which the tile is read, if it has been set.
|
int |
getWidth()
Returns the width of the tile, expressed in pixels.
|
boolean |
isAllDefault()
Returns whether all values in the tile are equal to a default value.
|
boolean |
isSigned()
Returns whether the pixel values are signed.
|
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
protected ILcdBufferSegment |
retrieveTile(int aSubTileRow,
int aSubTileColumn)
Decodes the specified subtile.
|
int |
retrieveValue(int aX,
int aY)
Retrieves the tile value at the specified location.
|
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setColorModel(ColorModel aColorModel) |
void |
setFileName(String aFileName)
Sets the name of the file from which the tile is to be read.
|
void |
setForcedTransparentColorIndex(int aForcedTransparentColorIndex)
Sets the index of a color that should be made transparent.
|
void |
setHeight(int aHeight) |
void |
setImageIndex(int aImageIndex)
Sets the index of the image to decode from a multi-image file.
|
void |
setSigned(boolean aIsSigned)
Specifies whether the pixel values are signed.
|
void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setURL(URL aURL)
Sets the URL of the file from which the tile is to be read.
|
void |
setWidth(int aWidth) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close
protected URL fURL
protected String fFileName
protected int fImageIndex
protected volatile int fWidth
protected volatile int fHeight
protected volatile int fSubTileWidth
protected volatile int fSubTileHeight
protected ILcdTileDecoder fDecoder
protected ILcdBuffer fBuffer
protected int fDefaultValue
protected volatile ColorModel fColorModel
protected int fForcedTransparentColorIndex
protected volatile int fType
protected volatile int fBitOffset
protected volatile int fPixelSize
protected volatile boolean fSigned
protected volatile boolean fIsAllDefault
public TLcdBufferedTile(String aFileName, int aImageIndex, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer)
TLcdBufferedTile
of an image accessible through a given file name.
The tile parameters will be determined by the ILcdTileDecoder
.public TLcdBufferedTile(String aFileName, int aImageIndex, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer, int aPixelSize, int aDefaultValue)
TLcdBufferedTile
of an image accessible through a given file name.
The ColorModel of the tile will be determined by the ILcdTileDecoder
.public TLcdBufferedTile(String aFileName, int aImageIndex, int aSubTileWidth, int aSubTileHeight, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer, int aPixelSize, int aDefaultValue)
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.public TLcdBufferedTile(String aFileName, int aImageIndex, int aWidth, int aHeight, int aSubTileWidth, int aSubTileHeight, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer, int aPixelSize, int aDefaultValue, ColorModel aColorModel)
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.
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.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)
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).
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.public TLcdBufferedTile(URL aURL, int aImageIndex, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer)
TLcdBufferedTile
of an image accessible through a given URL.
The tile parameters will be determined by the ILcdTileDecoder
.public TLcdBufferedTile(URL aURL, int aImageIndex, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer, int aPixelSize, int aDefaultValue)
TLcdBufferedTile
of an image accessible through a given URL.
The size and ColorModel of the tile will be determined by the ILcdTileDecoder
.public TLcdBufferedTile(URL aURL, int aImageIndex, int aSubTileWidth, int aSubTileHeight, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer, int aPixelSize, int aDefaultValue)
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.public TLcdBufferedTile(URL aURL, int aImageIndex, int aWidth, int aHeight, int aSubTileWidth, int aSubTileHeight, ILcdTileDecoder aDecoder, ILcdBuffer aBuffer, int aPixelSize, int aDefaultValue, ColorModel aColorModel)
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.
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.public TLcdBufferedTile(String aFileName, int aImageIndex, ILcdTileDecoder aDecoder, int aType, int aBitOffset, int aPixelSize, ILcdBuffer aBuffer, int aDefaultValue)
public TLcdBufferedTile(String aFileName, int aImageIndex, int aSubTileWidth, int aSubTileHeight, ILcdTileDecoder aDecoder, int aType, int aBitOffset, int aPixelSize, ILcdBuffer aBuffer, int aDefaultValue)
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)
public TLcdBufferedTile(URL aURL, int aImageIndex, ILcdTileDecoder aDecoder, int aType, int aBitOffset, int aPixelSize, ILcdBuffer aBuffer, int aDefaultValue)
public TLcdBufferedTile(URL aURL, int aImageIndex, int aSubTileWidth, int aSubTileHeight, ILcdTileDecoder aDecoder, int aType, int aBitOffset, int aPixelSize, ILcdBuffer aBuffer, int aDefaultValue)
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)
public static void setClassTraceOn(boolean aClassTraceOn)
true
then all log messages are recorded, otherwise only
the informative, warning and error messages are recorded.aClassTraceOn
- if true then all log messages are recorded,
otherwise only the informative, warning and error messages are recorded.public void setTraceOn(boolean aTraceOn)
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.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.public boolean isTraceOn()
true
if tracing is enabled for this class.public void setURL(URL aURL)
public URL getURL()
public void setFileName(String aFileName)
public String getFileName()
public void setImageIndex(int aImageIndex)
public int getImageIndex()
public void setSigned(boolean aIsSigned)
public boolean isSigned()
public void setWidth(int aWidth)
public int getWidth()
ILcdTile
public void setHeight(int aHeight)
public int getHeight()
ILcdTile
public int getType()
ILcdTile
public int getPixelSize()
ILcdTile
getPixelSize
in interface ILcdTile
public int getBitOffset()
public void setColorModel(ColorModel aColorModel)
public ColorModel getColorModel()
ILcdTile
getColorModel
in interface ILcdTile
null
if the raster doesn't have
an explicit color model.public boolean isAllDefault()
ILcdTile
isAllDefault
in interface ILcdTile
public void setForcedTransparentColorIndex(int aForcedTransparentColorIndex)
public int getForcedTransparentColorIndex()
public ILcdTileDecoder getTileDecoder()
public int getSubTileWidth()
ILcdSubtiledTile
getSubTileWidth
in interface ILcdSubtiledTile
public int getSubTileHeight()
ILcdSubtiledTile
getSubTileHeight
in interface ILcdSubtiledTile
public int retrieveValue(int aX, int aY)
ILcdTile
retrieveValue
in interface ILcdTile
aX
- the x ordinate of the value, expressed in tile coordinates.aY
- the y ordinate of the value, expressed in tile coordinates.protected ILcdBufferSegment retrieveTile(int aSubTileRow, int aSubTileColumn)
aSubTileRow
- the subtile row.aSubTileColumn
- the subtile column.public Image createImage()
ILcdTile
createImage
in interface ILcdTile
public Image createImage(ColorModel aColorModel)
ILcdTile
createImage
in interface ILcdTile
aColorModel
- the color model to be used for the image. The color
model should be compatible with the pixel values of
the tile.public Image createImage(int aX, int aY, int aWidth, int aHeight)
ILcdTile
createImage
in interface ILcdTile
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.public Image createImage(int aX, int aY, int aWidth, int aHeight, ColorModel aColorModel)
ILcdTile
createImage
in interface ILcdTile
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.public void dispose()
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.
dispose
in interface ILcdDisposable