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 Details

    • AbstractTileFactory

      public AbstractTileFactory​(TileFactoryInfo info)
      Creates a new instance of DefaultTileFactory using the spcified TileFactoryInfo
      Parameters:
      info - a TileFactoryInfo to configure this TileFactory
  • Method Details

    • 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:
      x - the x value
      y - the y value
      zoom - 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

      public TileCache getTileCache()
      Returns:
      the tile cache
    • setTileCache

      public void setTileCache​(TileCache cache)
      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: TileFactory
      Disposes this TileFactory
      Specified by:
      dispose in class TileFactory
    • 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

      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 java.lang.Runnable createTileRunner​(Tile tile)
      Subclasses can override this if they need custom TileRunners for some reason
      Parameters:
      tile - the tile (unused!)
      Returns:
      the tile runner
    • promote

      public void promote​(Tile tile)
      Increase the priority of this tile so it will be loaded sooner.
      Parameters:
      tile - the tile
    • setLocalCache

      public void setLocalCache​(LocalCache cache)
      Overrides:
      setLocalCache in class TileFactory
      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