public BufferedImage getTileImage(int x, int y) throws IOException { SRCachedTile cachedTile = cache.get(new CacheKey(x, y)); BufferedImage image = null; if (cachedTile != null) { CachedTile tile = cachedTile.get(); if (tile != null) { if (tile.loaded) log.trace(String.format("Cache hit: x=%d y=%d", x, y)); image = tile.getImage(); if (!tile.nextLoadJobCreated) { // log.debug(String.format("Preload job added : x=%d y=%d l=%d", // x + 1, y, layer)); preloadTile(new CachedTile(new CacheKey(x + 1, y))); tile.nextLoadJobCreated = true; } } } if (image == null) { log.trace(String.format("Cache miss: x=%d y=%d", x, y)); // log.debug(String.format("Preload job added : x=%d y=%d l=%d", x + // 1, y, layer)); preloadTile(new CachedTile(new CacheKey(x + 1, y))); image = internalGetTileImage(x, y); } return image; }