| Programming with JViews Maps > Introducing the Main Classes > Raster Image Management > The IlvRasterMappedBuffer Class |
The IlvRasterMappedBuffer Class |
INDEX
PREVIOUS
NEXT
|
The IlvRasterMappedBuffer class manages raster data for readers. It uses temporary files to store the data when it is not needed.
The buffer stores a table of [width x height] pixel values. Pixel values can use different primitive types, such as byte, short or integer values. The pixel value type must be compatible with the color model of the associated IlvRasterProperties object. The buffer is backed up by two mechanism to reduce memory consumption:
java.nio.MappedByteBuffer class), giving access times close to those of direct memory storage.
java.io.RandomAccessFile.
If machine dependant constraints prevent the memory mapped mechanism from succeeding (on 32 bits machines, for example, this happens when more than 2-4GB of images have been loaded), the random access file mechanism is put in place immediately.
The IlvRasterTemporaryFileManager class handles temporary files. The temporary file folder can become cluttered, for example, after an application has been interrupted brutally by errors, exceptions, or even debugging session stops. To clean the temporary file folder, you can call:
IlvRasterTemporaryFileManager.removeAllFiles();
This call searches for all temporary files created by JViews Maps applications and try to remove them. Temporary files that are in use, for example, if another application is running, are not removed.
You can even improve this mechanism by providing a Just In Time (JIT) loader. Instead of loading and filling the image bytes at creation, you can provide an instance of JITLoader, that loads the image bytes only when the image is about to be displayed. For example:
IlvRasterMappedBuffer.JITDataLoader jitLoader = new
IlvRasterMappedBuffer.JITDataLoader() {
public void loadData(IlvRasterMappedBuffer source, IlvRasterProperties
properties) {
System.out.println("loading "+properties.getBaseName());
// load the data...
}
public void unloadData(IlvRasterMappedBuffer source,
IlvRasterProperties properties) {
// raz the stored bytes.
source.setBytes(new byte[0]);
}
};
source.setLoader(jitLoader);
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. Legal terms. | PREVIOUS NEXT |