/** * Advises the cache that a tile is no longer needed. It is legal * to implement this method as a no-op. * * @param owner The <code>RenderedImage</code> that the tile belongs to. * @param tileX The X index of the tile in the owner's tile grid. * @param tileY The Y index of the tile in the owner's tile grid. */ public void remove(RenderedImage owner, int tileX, int tileY) { removeTile(createTileId(owner, tileX, tileY)); }
/** * Retrieves a tile. Returns <code>null</code> if the tile is not * present in the cache. * * @param owner The <code>RenderedImage</code> that the tile belongs to. * @param tileX The X index of the tile in the owner's tile grid. * @param tileY The Y index of the tile in the owner's tile grid. */ public Raster getTile(RenderedImage owner, int tileX, int tileY) { TileId tileId = createTileId(owner, tileX, tileY); Raster tile = null; synchronized (this) { CachedTileImpl cachedTile = tileMap.get(tileId); if (cachedTile != null) { try { DataBuffer dataBuffer = readTileData(cachedTile.file, cachedTile.sampleModel); if (cachedTile.writable) { tile = Raster.createWritableRaster(cachedTile.sampleModel, dataBuffer, cachedTile.location); } else { tile = Raster.createRaster(cachedTile.sampleModel, dataBuffer, cachedTile.location); } cachedTile.tileTimeStamp = System.currentTimeMillis(); } catch (IOException e) { // todo - log warning } } } return tile; }
TileId tileId = createTileId(owner, tileX, tileY); synchronized (this) { CachedTileImpl cachedTile = tileMap.get(tileId);