Package nl.bebr.mapviewer.data
Class AbstractTileFactory<T,U extends Tile<T>>
- java.lang.Object
-
- nl.bebr.mapviewer.data.TileFactory<T,U>
-
- nl.bebr.mapviewer.data.AbstractTileFactory<T,U>
-
- Direct Known Subclasses:
DefaultTileFactory
public abstract class AbstractTileFactory<T,U extends Tile<T>> extends TileFactory<T,U>
TheAbstractTileFactoryprovides a basic implementation for the TileFactory.- Author:
- Frantisek Post
-
-
Constructor Summary
Constructors Constructor Description AbstractTileFactory(TileFactoryInfo info)Creates a new instance of DefaultTileFactory using the spcified TileFactoryInfo
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclearQueueAndStopLoading()Method to stop the tile runner and clear all cachesabstract UcreateTile(int x, int y, int zoom, String url, AbstractTileFactory<T,U> tileFactory)abstract TileCache<T>createTileCache()protected abstract RunnablecreateTileRunner()Subclasses can override this if they need custom TileRunners for some reasonprotected ExecutorServicegetService()Subclasses may override this method to provide their own executor services.UgetTile(int x, int y, int zoom)Returns the tile that is located at the given tilePoint for this zoom.TileCache<T>getTileCache()protected abstract Map<String,U>getTileMap()gets tileMap which should be static.
target implementation should provide static tileMapabstract BlockingQueue<U>getTileQueue()gets tileQueue which should be static.
target implementation should provide static tileQueuevoidpromote(U tile)Increase the priority of this tile so it will be loaded sooner.voidsetTileCache(TileCache<T> cache)protected voidstartLoading(U tile)Override this method to load the tile using, for example, anExecutorService.-
Methods inherited from class nl.bebr.mapviewer.data.TileFactory
geoToPixel, getInfo, getMapSize, getTileSize, pixelToGeo
-
-
-
-
Constructor Detail
-
AbstractTileFactory
public AbstractTileFactory(TileFactoryInfo info)
Creates a new instance of DefaultTileFactory using the spcified TileFactoryInfo- Parameters:
info- a TileFactoryInfo to configure this TileFactory
-
-
Method Detail
-
getTile
public U getTile(int x, int y, int zoom)
Returns the tile that is located at the given tilePoint for this zoom. For example, if getMapSize() returns 10x20 for this zoom, and the tilePoint is (3,5), then the appropriate tile will be located and returned.
-
getService
protected ExecutorService getService()
Subclasses may override this method to provide their own executor services. This method will be called each time a tile needs to be loaded. Implementations should cache the ExecutorService when possible.- Returns:
- ExecutorService to load tiles with
-
startLoading
protected void startLoading(U tile)
Description copied from class:TileFactoryOverride this method to load the tile using, for example, anExecutorService.- Specified by:
startLoadingin classTileFactory<T,U extends Tile<T>>- Parameters:
tile- The tile to load.
-
createTileRunner
protected abstract Runnable createTileRunner()
Subclasses can override this if they need custom TileRunners for some reason- Returns:
-
promote
public void promote(U tile)
Increase the priority of this tile so it will be loaded sooner.
-
getTileQueue
public abstract BlockingQueue<U> getTileQueue()
gets tileQueue which should be static.
target implementation should provide static tileQueue
-
createTile
public abstract U createTile(int x, int y, int zoom, String url, AbstractTileFactory<T,U> tileFactory)
-
getTileMap
protected abstract Map<String,U> getTileMap()
gets tileMap which should be static.
target implementation should provide static tileMap
-
clearQueueAndStopLoading
public void clearQueueAndStopLoading()
Description copied from class:TileFactoryMethod to stop the tile runner and clear all caches- Specified by:
clearQueueAndStopLoadingin classTileFactory<T,U extends Tile<T>>
-
-