public class CachedDataRaster extends AVListImpl implements DataRaster
CachedDataRaster is used to hold data raster's source and metadata, while the actual data raster may
 not be loaded in to the memory. This is mostly used together with a memory caches. CachedDataRaster
 actually implements all interfaces of the DataRaster, and acts as a proxy, that loads a real data raster
 only when it is actually needed.| Modifier and Type | Class and Description | 
|---|---|
| protected static class  | CachedDataRaster.ErrorHandlerMode | 
| Modifier and Type | Field and Description | 
|---|---|
| protected MemoryCache.CacheListener | cacheListener | 
| protected DataRasterReader | dataReader | 
| protected Object | dataSource | 
| protected MemoryCache | rasterCache | 
| protected Object | rasterRetrievalLock | 
| protected Object | rasterUsageLock | 
| protected String[] | requiredKeys | 
| Constructor and Description | 
|---|
| CachedDataRaster(Object source,
                AVList params,
                DataRasterReader reader,
                MemoryCache cache)Create a cached data raster. | 
| Modifier and Type | Method and Description | 
|---|---|
| protected void | assembleMetadata(Object source,
                AVList params,
                DataRasterReader reader) | 
| protected String | composeExceptionReason(Throwable t) | 
| void | dispose()Disposes of any internal resources allocated by the object. | 
| protected static void | disposeRasters(DataRaster[] rasters) | 
| void | drawOnTo(DataRaster canvas)Copies this raster into a specified raster. | 
| DataRasterReader | getDataRasterReader() | 
| protected DataRaster[] | getDataRasters() | 
| Object | getDataSource() | 
| int | getHeight()Returns the raster's height in raster units. | 
| AVList | getMetadata() | 
| AVList | getParams() | 
| protected String[] | getRequiredKeysList() | 
| Sector | getSector()Returns the region covered be the data. | 
| protected long | getSizeInBytes(DataRaster[] rasters) | 
| DataRaster | getSubRaster(AVList params)Returns a portion of this raster as another raster. | 
| DataRaster | getSubRaster(int width,
            int height,
            Sector sector,
            AVList params)Returns a portion of this raster as another raster. | 
| protected static long | getTotalUsedMemory() | 
| int | getWidth()Returns the raster's width in raster units. | 
| protected boolean | hasRequiredMetadata(AVList params,
                   CachedDataRaster.ErrorHandlerMode throwException)Validates if params (AVList) has all required keys. | 
| protected void | releaseMemory() | 
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValuesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValuesprotected MemoryCache.CacheListener cacheListener
protected DataRasterReader dataReader
protected Object dataSource
protected MemoryCache rasterCache
protected final Object rasterRetrievalLock
protected final Object rasterUsageLock
protected String[] requiredKeys
public CachedDataRaster(Object source, AVList params, DataRasterReader reader, MemoryCache cache) throws IOException, IllegalArgumentException
source - the location of the local file, expressed as either a String path, a File, or a file URL.params - metadata as AVList, it is expected to next parameters: AVKey.WIDTH, AVKey.HEIGHT, AVKey.SECTOR,
               AVKey.PIXEL_FORMAT.
               
               If any of these keys is missing, there will be an attempt made to retrieve missign metadata from
               the source using the reader.reader - A reference to a DataRasterReader instancecache - A reference to a MemoryCache instanceIOException - thrown if there is an error to read metadata from the sourceIllegalArgumentException - thrown when a source or a reader are nullprotected void assembleMetadata(Object source, AVList params, DataRasterReader reader) throws IOException, IllegalArgumentException
IOExceptionIllegalArgumentExceptionpublic void dispose()
Disposabledispose in interface Disposableprotected static void disposeRasters(DataRaster[] rasters)
public void drawOnTo(DataRaster canvas)
DataRasterdrawOnTo in interface DataRastercanvas - - the raster to copy into.public DataRasterReader getDataRasterReader()
protected DataRaster[] getDataRasters() throws IOException, WWRuntimeException
IOExceptionWWRuntimeExceptionpublic Object getDataSource()
public int getHeight()
DataRastergetHeight in interface DataRasterpublic AVList getMetadata()
public AVList getParams()
protected String[] getRequiredKeysList()
public Sector getSector()
DataRastergetSector in interface DataRasterprotected long getSizeInBytes(DataRaster[] rasters)
public DataRaster getSubRaster(AVList params)
DataRastergetSubRaster in interface DataRasterparams - a list of parameters that specify the width, height and sector of the region to return. Specify
               these values using AVKey.WIDTH, AVKey.HEIGHT and AVKey.SECTOR.public DataRaster getSubRaster(int width, int height, Sector sector, AVList params)
DataRastergetSubRaster in interface DataRasterwidth - the width to make the returned sub-raster.height - the height to make the returned sub-raster.sector - the sector to copy.params - a list of parameters that specify the width, height and sector of the region to return. Specify
               these values using AVKey.WIDTH, AVKey.HEIGHT and AVKey.SECTOR.protected static long getTotalUsedMemory()
public int getWidth()
DataRastergetWidth in interface DataRasterprotected boolean hasRequiredMetadata(AVList params, CachedDataRaster.ErrorHandlerMode throwException) throws IllegalArgumentException
params - AVList of key/value pairsthrowException - specifies weather to throw exception when a key/value is missing, or just return false.IllegalArgumentException - If a key/value is missing and throwException is set to TRUEprotected void releaseMemory()