public CacheObject load(Object key,int x,int y,int zoomLevel,Projection proj){
  if (key instanceof String) {
    if (verbose) {
      logger.fine("fetching file for cache: " + key);
    }
    byte[] imageBytes=null;
    CacheObject localVersion=super.load(key,x,y,zoomLevel,proj);
    if (localVersion != null) {
      logger.fine("found version of tile in local cache: " + key);
      return localVersion;
    }
    String imagePath=buildFilePath(x,y,zoomLevel,fileExt);
    imageBytes=getImageBytes(imagePath,(String)key);
    if (imageBytes != null && imageBytes.length > 0) {
      ImageIcon ii=new ImageIcon(imageBytes);
      try {
        BufferedImage rasterImage=preprocessImage(ii.getImage(),ii.getIconWidth(),ii.getIconHeight());
        OMGraphic raster=createOMGraphicFromBufferedImage(rasterImage,x,y,zoomLevel,proj);
        if (raster != null) {
          return new CacheObject(key,raster);
        }
      }
 catch (      InterruptedException ie) {
        if (logger.isLoggable(Level.FINE)) {
          logger.fine("factory interrupted fetching " + imagePath);
        }
      }
    }
    return getEmptyTile(key,x,y,zoomLevel,proj);
  }
  return null;
}

public CacheObject load ( Object key , int x , int y , int zoomLevel , Projection proj ) { if ( key instanceof String ) { if ( verbose ) { logger . fine ( "fetching file for cache: " + key ) ; } byte [ ] imageBytes = null ; CacheObject localVersion = super . load ( key , x , y , zoomLevel , proj ) ; if ( localVersion != null ) { logger . fine ( "found version of tile in local cache: " + key ) ; return localVersion ; } String imagePath = buildFilePath ( x , y , zoomLevel , fileExt ) ; imageBytes = getImageBytes ( imagePath , ( String ) key ) ; if ( imageBytes != null && imageBytes . length > 0 ) { ImageIcon ii = new ImageIcon ( imageBytes ) ; try { BufferedImage rasterImage = preprocessImage ( ii . getImage ( ) , ii . getIconWidth ( ) , ii . getIconHeight ( ) ) ; OMGraphic raster = createOMGraphicFromBufferedImage ( rasterImage , x , y , zoomLevel , proj ) ; if ( raster != null ) { return new CacheObject ( key , raster ) ; } } catch ( InterruptedException ie ) { if ( logger . isLoggable ( Level . FINE ) ) { logger . fine ( "factory interrupted fetching " + imagePath ) ; } } } return getEmptyTile ( key , x , y , zoomLevel , proj ) ; } return null ; }
checks the local directory first for a locally cached version of the tile before going off to the server . if a local directory is listed as a cache , any retrieved files will be stored there for future use . we are using the local name of the file as the cache key for all tiles for consistency - all tiles are looked up with local cache locations .
