Class TMSCachedTileLoader

java.lang.Object
org.openstreetmap.josm.data.imagery.TMSCachedTileLoader
All Implemented Interfaces:
org.openstreetmap.gui.jmapviewer.interfaces.CachedTileLoader, org.openstreetmap.gui.jmapviewer.interfaces.TileLoader
Direct Known Subclasses:
WMSCachedTileLoader

public class TMSCachedTileLoader extends Object implements org.openstreetmap.gui.jmapviewer.interfaces.TileLoader, org.openstreetmap.gui.jmapviewer.interfaces.CachedTileLoader
Wrapper class that bridges between JCS cache and Tile Loaders
  • Field Details

  • Constructor Details

    • TMSCachedTileLoader

      public TMSCachedTileLoader(org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener listener, org.apache.commons.jcs3.access.behavior.ICacheAccess<String,BufferedImageCacheEntry> cache, TileJobOptions options)
      Constructor
      Parameters:
      listener - called when tile loading has finished
      cache - of the cache
      options - tile job options
  • Method Details

    • getNewThreadPoolExecutor

      public static ThreadPoolExecutor getNewThreadPoolExecutor(String nameFormat, int workers)
      Returns a new ThreadPoolExecutor.
      Parameters:
      nameFormat - see Utils.newThreadFactory(String, int)
      workers - number of worker thread to keep
      Returns:
      new ThreadPoolExecutor that will use a @see HostLimitQueue based queue
    • getNewThreadPoolExecutor

      public static ThreadPoolExecutor getNewThreadPoolExecutor(String nameFormat, int workers, int hostLimit)
      Returns a new ThreadPoolExecutor.
      Parameters:
      nameFormat - see Utils.newThreadFactory(String, int)
      workers - number of worker thread to keep
      hostLimit - number of concurrent downloads per host allowed
      Returns:
      new ThreadPoolExecutor that will use a @see HostLimitQueue based queue
    • getNewThreadPoolExecutor

      Returns a new ThreadPoolExecutor.
      Parameters:
      name - name of threads
      Returns:
      new ThreadPoolExecutor that will use a HostLimitQueue based queue, with default number of threads
    • createTileLoaderJob

      public org.openstreetmap.gui.jmapviewer.interfaces.TileJob createTileLoaderJob(org.openstreetmap.gui.jmapviewer.Tile tile)
      Specified by:
      createTileLoaderJob in interface org.openstreetmap.gui.jmapviewer.interfaces.TileLoader
    • clearCache

      public void clearCache(org.openstreetmap.gui.jmapviewer.interfaces.TileSource source)
      Specified by:
      clearCache in interface org.openstreetmap.gui.jmapviewer.interfaces.CachedTileLoader
    • getStats

      public String getStats()
      Returns cache statistics as string.
      Returns:
      cache statistics as string
    • cancelOutstandingTasks

      public void cancelOutstandingTasks()
      cancels all outstanding tasks in the queue. This rollbacks the state of the tiles in the queue to loading = false / loaded = false
      Specified by:
      cancelOutstandingTasks in interface org.openstreetmap.gui.jmapviewer.interfaces.TileLoader
    • hasOutstandingTasks

      public boolean hasOutstandingTasks()
      Specified by:
      hasOutstandingTasks in interface org.openstreetmap.gui.jmapviewer.interfaces.TileLoader
    • setDownloadExecutor

      public void setDownloadExecutor(ThreadPoolExecutor downloadExecutor)
      Sets the download executor that will be used to download tiles instead of default one. You can use getNewThreadPoolExecutor(java.lang.String, int) to create a new download executor with separate queue from default.
      Parameters:
      downloadExecutor - download executor that will be used to download tiles
    • getDownloadExecutor

      Returns download executor that is used by this factory.
      Returns:
      download executor that is used by this factory
    • shutdown

      public void shutdown()
      Shutdown the job dispatcher provided that it's not the default one