Package org.jxmapviewer.viewer
Class AbstractTileFactory
java.lang.Object
org.jxmapviewer.viewer.TileFactory
org.jxmapviewer.viewer.AbstractTileFactory
- Direct Known Subclasses:
DefaultTileFactory
public abstract class AbstractTileFactory extends TileFactory
The
AbstractTileFactory provides
a basic implementation for the TileFactory.-
Constructor Summary
Constructors Constructor Description AbstractTileFactory(TileFactoryInfo info)Creates a new instance of DefaultTileFactory using the spcified TileFactoryInfo -
Method Summary
Modifier and Type Method Description protected voidaddCustomRequestProperties(java.net.URLConnection connection)Adds custom request properties to the connection before sending the request.protected java.lang.RunnablecreateTileRunner(Tile tile)Subclasses can override this if they need custom TileRunners for some reasonvoiddispose()Disposes this TileFactoryintgetPendingTiles()protected java.util.concurrent.ExecutorServicegetService()Subclasses may override this method to provide their own executor services.TilegetTile(int x, int y, int zoom)Returns the tile that is located at the given tilePoint for this zoom.TileCachegetTileCache()voidpromote(Tile tile)Increase the priority of this tile so it will be loaded sooner.voidsetLocalCache(LocalCache cache)voidsetThreadPoolSize(int size)Set the number of threads to use for loading the tiles.voidsetTileCache(TileCache cache)voidsetUserAgent(java.lang.String userAgent)Set the User agent that will be used when making a tile request.protected voidstartLoading(Tile tile)Override this method to load the tile using, for example, anExecutorService.Methods inherited from class org.jxmapviewer.viewer.TileFactory
addTileListener, fireTileLoadedEvent, geoToPixel, getInfo, getMapSize, getTileSize, pixelToGeo, removeTileListener
-
Constructor Details
-
AbstractTileFactory
Creates a new instance of DefaultTileFactory using the spcified TileFactoryInfo- Parameters:
info- a TileFactoryInfo to configure this TileFactory
-
-
Method Details
-
getTile
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.- Specified by:
getTilein classTileFactory- Parameters:
x- the x valuey- the y valuezoom- the current zoom level- Returns:
- the tile that is located at the given tilePoint for this zoom level. For example, if getMapSize() returns 10x20 for this zoom, and the tilePoint is (3,5), then the appropriate tile will be located and returned. This method must not return null. However, it can return dummy tiles that contain no data if it wants. This is appropriate, for example, for tiles which are outside of the bounds of the map and if the factory doesn't implement wrapping.
-
getTileCache
- Returns:
- the tile cache
-
setTileCache
- Parameters:
cache- the tile cache
-
getService
protected java.util.concurrent.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
-
dispose
public void dispose()Description copied from class:TileFactoryDisposes this TileFactory- Specified by:
disposein classTileFactory
-
setThreadPoolSize
public void setThreadPoolSize(int size)Set the number of threads to use for loading the tiles. This controls the number of threads used by the ExecutorService returned from getService(). Note, this method should be called before loading the first tile. Calls after the first tile are loaded will have no effect by default.- Parameters:
size- the thread pool size
-
setUserAgent
public void setUserAgent(java.lang.String userAgent)Set the User agent that will be used when making a tile request. Some tile server usage policies requires application to identify itself, so please make sure that it is set properly.- Parameters:
userAgent- User agent to be used.
-
startLoading
Description copied from class:TileFactoryOverride this method to load the tile using, for example, anExecutorService.- Specified by:
startLoadingin classTileFactory- Parameters:
tile- The tile to load.
-
createTileRunner
Subclasses can override this if they need custom TileRunners for some reason- Parameters:
tile- the tile (unused!)- Returns:
- the tile runner
-
promote
Increase the priority of this tile so it will be loaded sooner.- Parameters:
tile- the tile
-
setLocalCache
- Overrides:
setLocalCachein classTileFactory- Parameters:
cache- the local cache to use
-
getPendingTiles
public int getPendingTiles()- Returns:
- the number of pending (loading or queues) tiles
-
addCustomRequestProperties
protected void addCustomRequestProperties(java.net.URLConnection connection)Adds custom request properties to the connection before sending the request. By default, no properties are added at all.- Parameters:
connection- connection for tile request
-