|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.gui.jmapviewer.MemoryTileCache
public class MemoryTileCache
TileCache
implementation that stores all Tile
objects in
memory up to a certain limit (getCacheSize()
). If the limit is
exceeded the least recently used Tile
objects will be deleted.
Nested Class Summary | |
---|---|
protected static class |
MemoryTileCache.CacheEntry
Linked list element holding the Tile and links to the
MemoryTileCache.CacheEntry.next and MemoryTileCache.CacheEntry.prev item in the list. |
protected static class |
MemoryTileCache.CacheLinkedListElement
Special implementation of a double linked list for MemoryTileCache.CacheEntry
elements. |
Field Summary | |
---|---|
protected int |
cacheSize
Default cache size |
protected java.util.Hashtable<java.lang.String,MemoryTileCache.CacheEntry> |
hashtable
|
protected static java.util.logging.Logger |
log
|
protected MemoryTileCache.CacheLinkedListElement |
lruTiles
List of all tiles in their last recently used order |
Constructor Summary | |
---|---|
MemoryTileCache()
|
Method Summary | |
---|---|
void |
addTile(Tile tile)
Adds a tile to the cache. |
void |
clear()
Clears the cache deleting all tiles from memory |
protected MemoryTileCache.CacheEntry |
createCacheEntry(Tile tile)
|
int |
getCacheSize()
|
Tile |
getTile(TileSource source,
int x,
int y,
int z)
Retrieves a tile from the cache if present, otherwise null
will be returned. |
int |
getTileCount()
|
protected void |
removeEntry(MemoryTileCache.CacheEntry entry)
|
protected void |
removeOldEntries()
Removes the least recently used tiles |
void |
setCacheSize(int cacheSize)
Changes the maximum number of Tile objects that this cache holds. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.util.logging.Logger log
protected int cacheSize
protected java.util.Hashtable<java.lang.String,MemoryTileCache.CacheEntry> hashtable
protected MemoryTileCache.CacheLinkedListElement lruTiles
Constructor Detail |
---|
public MemoryTileCache()
Method Detail |
---|
public void addTile(Tile tile)
TileCache
TileCache.getTile(TileSource, int, int, int)
is unspecified and depends on the
implementation.
addTile
in interface TileCache
tile
- the tile to be addedpublic Tile getTile(TileSource source, int x, int y, int z)
TileCache
null
will be returned.
getTile
in interface TileCache
source
- the tile sourcex
- tile number on the x axis of the tile to be retrievedy
- tile number on the y axis of the tile to be retrievedz
- zoom level of the tile to be retrieved
null
if the tile is not
present in the cacheprotected void removeOldEntries()
protected void removeEntry(MemoryTileCache.CacheEntry entry)
protected MemoryTileCache.CacheEntry createCacheEntry(Tile tile)
public void clear()
public int getTileCount()
getTileCount
in interface TileCache
public int getCacheSize()
public void setCacheSize(int cacheSize)
Tile
objects that this cache holds.
cacheSize
- new maximum number of tiles
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |