public class IlvRasterMappedBuffer extends Object implements IlvPersistentObject
Modifier and Type | Class and Description |
---|---|
static interface |
IlvRasterMappedBuffer.JITDataLoader
Class responsible for loading raster data when an
IlvRasterTileLoader loads a tile whose buffer is empty (0 bytes). |
Modifier and Type | Field and Description |
---|---|
static int |
BYTE_RASTER
When the the data type attribute is set to this value, it means that the
raster is coded with bytes.
|
static int |
INT_RASTER
When the the data type attribute is set to this value, it means that the
raster is coded with integers.
|
protected int |
memoryManagement
Type of data storage.
|
static int |
SHORT_RASTER
When the the data type attribute is set to this value, it means that the
raster is coded with short.
|
static int |
USE_MAP
Indicates a raster mapped buffer storing pixel information on disk mapped
memory.
|
static int |
USE_MEMORY
Indicates a raster mapped buffer storing pixel information in memory.
|
Constructor and Description |
---|
IlvRasterMappedBuffer(IlvInputStream stream)
Reads the
rasterinfo from the specified input stream. |
IlvRasterMappedBuffer(String sourceName,
byte[] pixels)
Constructor.
|
IlvRasterMappedBuffer(String sourceName,
int[] pixels)
Constructor.
|
IlvRasterMappedBuffer(String sourceName,
int type,
int size)
Creates a mapped buffer from a file with the correct content.
|
IlvRasterMappedBuffer(String sourceName,
int size,
String fName,
int rasterDataType)
Creates a raster mapped buffer without creating a temporary file.
|
IlvRasterMappedBuffer(String sourceName,
int size,
URL url,
int rasterDataType)
Creates a raster mapped buffer from an url.
|
IlvRasterMappedBuffer(String sourceName,
short[] pixels)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
callJITLoaderIfNecessary(IlvRasterProperties props,
boolean stopOnOutofMemory)
This method checks if the data has not been loaded and if necessary calls the
JITDataLoader to load the data. |
void |
clear()
Clear the memory or the files supporting the raster data.
|
void |
closeMap()
Closes any file related resource used by this
IlvRasterMappedBuffer
(RandomAccessFile , FileChannel as well as MappedByteBuffer . |
protected void |
finalize()
Clear the raster image source on finalization.
|
long |
getAccessChannelPosition()
Returns the
accessChannelPosition . |
int |
getArraySize()
Returns the array Size.
|
int |
getBytePixel(int index,
int noDataValue)
Retrieve the information from the raster
data.
|
static int |
getDefaultMemoryPolicy()
Returns the default memory management policy that will be used when
|
int |
getIntPixel(int index,
int noDataValue)
Retrieve the information from the raster data.
|
IlvRasterMappedBuffer.JITDataLoader |
getLoader()
Returns the optional Just-In-Time data loader for this buffer.
|
int |
getRasterDataType()
Indicates the kind of data supported.
|
protected void |
initMemoryManagement()
Method that initializes the memory management for this buffer.
|
boolean |
isSwapBytes()
Returns whether bytes have to be swapped.
|
void |
putBytePixel(int index,
byte value)
Sets the pixel with the value provided.
|
void |
putIntPixel(int index,
int value)
Sets the pixel with the value provided.
|
void |
remap(RandomAccessFile raf,
long position)
Deprecated.
|
void |
remap(String filename,
long position)
Changes the underlying mapped byte buffer use by this class
|
void |
setBytes(byte[] pixels)
Changes the pixel array of the original image.
|
static void |
setDefaultMemoryPolicy(int defaultMemoryPolicy)
Indicates the default memory management policy that will be used when
creating an
IlvRasterMappedBuffer . |
void |
setInts(int[] pixels)
Changes the pixel array of the original image.
|
void |
setLoader(IlvRasterMappedBuffer.JITDataLoader loader)
Sets the optional Just-In-Time data loader for this buffer.
|
void |
setShorts(short[] pixels)
Changes the pixel array of the original image
|
void |
setSwapBytes(boolean swap)
Indicate if bytes have to be swapped.Default is false.
|
void |
write(IlvOutputStream out)
Writes the attributes of a persistent object.
|
public static final int BYTE_RASTER
public static final int INT_RASTER
public static final int SHORT_RASTER
public static final int USE_MAP
public static final int USE_MEMORY
protected int memoryManagement
USE_MAP
or USE_MEMORY
public IlvRasterMappedBuffer(IlvInputStream stream) throws IlvReadFileException
rasterinfo
from the specified input stream.stream
- The input stream.IlvReadFileException
- if an error occurs while reading the data.public IlvRasterMappedBuffer(String sourceName, byte[] pixels)
sourceName
- The identifier of the raster producer.pixels
- The pixel array of the original image.public IlvRasterMappedBuffer(String sourceName, short[] pixels)
sourceName
- The identifier of the raster producer.pixels
- The pixel array of the original image.public IlvRasterMappedBuffer(String sourceName, int type, int size)
sourceName
- Name of the buffer.type
- Type of buffer (SHORT_RASTER
,INT_RASTER
,
BYTE_RASTER
).size
- Number of elements in the array.public IlvRasterMappedBuffer(String sourceName, int size, String fName, int rasterDataType)
sourceName
- The identifier of the raster producer.size
- The number of elements in the data.fName
- The file to read (in internal format).rasterDataType
- The type of data.public IlvRasterMappedBuffer(String sourceName, int size, URL url, int rasterDataType)
sourceName
- The identifier of the raster producer.size
- The number of elements in the data.url
- The URL to read (in internal format).rasterDataType
- The type of data.public IlvRasterMappedBuffer(String sourceName, int[] pixels)
sourceName
- The identifier of the raster producer.pixels
- The pixel array of the original image.public static void setDefaultMemoryPolicy(int defaultMemoryPolicy)
IlvRasterMappedBuffer
.defaultMemoryPolicy
- either USE_MAP
or USE_MEMORY
public static int getDefaultMemoryPolicy()
IlvRasterMappedBuffer
.setDefaultMemoryPolicy(int)
public void setBytes(byte[] pixels)
pixels
- The pixel array of the original image.protected void initMemoryManagement()
USE_MEMORY
.setDefaultMemoryPolicy(int)
public void setShorts(short[] pixels)
pixels
- The pixel array of the original image.public void setInts(int[] pixels)
pixels
- The pixel array of the original image.public int getArraySize()
public void clear()
public void closeMap()
IlvRasterMappedBuffer
(RandomAccessFile
, FileChannel
as well as MappedByteBuffer
.public int getBytePixel(int index, int noDataValue)
index
- The index of the pixel to retrieve from the raster data.noDataValue
- Value to return when the index is out of bounds.@Deprecated public void remap(RandomAccessFile raf, long position)
raf
- a RandomAccessFile
on a file containing raster dataposition
- the buffer start position on the filepublic void remap(String filename, long position) throws FileNotFoundException
filename
- the name of a file containing raster dataposition
- the buffer start position on the fileFileNotFoundException
public boolean isSwapBytes()
public void setSwapBytes(boolean swap)
swap
- The swap to set.public int getIntPixel(int index, int noDataValue)
index
- The index of the pixel to retrieve from the raster data.noDataValue
- Value to return when index is out of bounds.public int getRasterDataType()
BYTE_RASTER
or INT_RASTER
depending on the
constructor that was used.public void write(IlvOutputStream out) throws IOException
write
in interface IlvPersistentObject
out
- the output streamIOException
- thrown when an exception occurs during
the write operation for this object.IlvPersistentObject.write(ilog.views.io.IlvOutputStream)
protected void finalize() throws Throwable
finalize
in class Object
Throwable
Object.finalize()
,
clear()
public void putIntPixel(int index, int value) throws IOException
index
- Index of the pixel in the single dimension array.value
- Value of the pixel.IOException
- in case of error writing the value on the disc.public void putBytePixel(int index, byte value) throws IOException
index
- Index of the pixel in the single dimension array.value
- Value of the pixel.IOException
- in case of error writing the value on the disc.public long getAccessChannelPosition()
accessChannelPosition
.accessChannelPosition
.public void setLoader(IlvRasterMappedBuffer.JITDataLoader loader)
loader
- Just-In-Time data loader.public IlvRasterMappedBuffer.JITDataLoader getLoader()
public boolean callJITLoaderIfNecessary(IlvRasterProperties props, boolean stopOnOutofMemory) throws OutOfMemoryError
JITDataLoader
to load the data.
If stopOnOutofMemory
false, and an OutOfMemory
exception happens, the method will try again to load data after a short wait.props
- The properties to use to load the data.stopOnOutofMemory
- Indicates whether the method should stop whenever available memory is not enough.true
if the JITLoader has been called (successfully).OutOfMemoryError
- if stopOnOutofMemory
is true
and there is not enough memory to load the data.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.