org.jdesktop.swingx.mapviewer
Class AbstractTileFactory

java.lang.Object
  extended by org.jdesktop.swingx.mapviewer.TileFactory
      extended by org.jdesktop.swingx.mapviewer.AbstractTileFactory
Direct Known Subclasses:
DefaultTileFactory

public abstract class AbstractTileFactory
extends TileFactory

The AbstractTileFactory provides a basic implementation for the TileFactory.


Constructor Summary
AbstractTileFactory(TileFactoryInfo info)
          Creates a new instance of DefaultTileFactory using the spcified TileFactoryInfo
 
Method Summary
protected  Runnable createTileRunner(Tile tile)
          Subclasses can override this if they need custom TileRunners for some reason
protected  ExecutorService getService()
          Subclasses may override this method to provide their own executor services.
 Tile getTile(int x, int y, int zoom)
          Returns the tile that is located at the given tilePoint for this zoom.
 TileCache getTileCache()
           
 void promote(Tile tile)
          Increase the priority of this tile so it will be loaded sooner.
 void setThreadPoolSize(int size)
          Set the number of threads to use for loading the tiles.
 void setTileCache(TileCache cache)
           
protected  void startLoading(Tile tile)
          Override this method to load the tile using, for example, an ExecutorService.
 
Methods inherited from class org.jdesktop.swingx.mapviewer.TileFactory
geoToPixel, getInfo, getMapSize, getTileSize, pixelToGeo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 Tile 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.

Specified by:
getTile in class TileFactory
Parameters:
tilePoint -
zoom -
Returns:

getTileCache

public TileCache getTileCache()

setTileCache

public void setTileCache(TileCache cache)

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

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 -

startLoading

protected void startLoading(Tile tile)
Description copied from class: TileFactory
Override this method to load the tile using, for example, an ExecutorService.

Specified by:
startLoading in class TileFactory
Parameters:
tile - The tile to load.

createTileRunner

protected Runnable createTileRunner(Tile tile)
Subclasses can override this if they need custom TileRunners for some reason

Returns:

promote

public void promote(Tile tile)
Increase the priority of this tile so it will be loaded sooner.