001 package org.openstreetmap.gui.jmapviewer.interfaces; 002 003 import org.openstreetmap.gui.jmapviewer.JMapViewer; 004 import org.openstreetmap.gui.jmapviewer.Tile; 005 006 //License: GPL. Copyright 2008 by Jan Peter Stotz 007 008 /** 009 * Implement this interface for creating your custom tile cache for 010 * {@link JMapViewer}. 011 * 012 * @author Jan Peter Stotz 013 */ 014 public interface TileCache { 015 016 /** 017 * Retrieves a tile from the cache if present, otherwise <code>null</code> 018 * will be returned. 019 * 020 * @param source 021 * the tile source 022 * @param x 023 * tile number on the x axis of the tile to be retrieved 024 * @param y 025 * tile number on the y axis of the tile to be retrieved 026 * @param z 027 * zoom level of the tile to be retrieved 028 * @return the requested tile or <code>null</code> if the tile is not 029 * present in the cache 030 */ 031 public Tile getTile(TileSource source, int x, int y, int z); 032 033 /** 034 * Adds a tile to the cache. How long after adding a tile can be retrieved 035 * via {@link #getTile(TileSource, int, int, int)} is unspecified and depends on the 036 * implementation. 037 * 038 * @param tile the tile to be added 039 */ 040 public void addTile(Tile tile); 041 042 /** 043 * @return the number of tiles hold by the cache 044 */ 045 public int getTileCount(); 046 }