Class DefaultImageRegionStore

java.lang.Object
qupath.lib.gui.images.stores.DefaultImageRegionStore
All Implemented Interfaces:
ImageRegionRenderer

public class DefaultImageRegionStore extends Object implements ImageRegionRenderer
An ImageRegionStore suitable for either Swing or JavaFX applications.
Author:
Pete Bankhead
  • Field Details

  • Method Details

    • paintRegionCompletely

      public void paintRegionCompletely(ImageServer<BufferedImage> server, Graphics g, Shape clipShapeVisible, int zPosition, int tPosition, double downsampleFactor, ImageObserver observer, ImageRenderer imageDisplay, long timeoutMilliseconds)
      Similar to paintRegion, but wait until all the tiles have arrived (or abort if it is taking too long)
      Specified by:
      paintRegionCompletely in interface ImageRegionRenderer
      Parameters:
      server -
      g -
      clipShapeVisible -
      zPosition -
      tPosition -
      downsampleFactor -
      observer -
      imageDisplay -
      timeoutMilliseconds - Timeout after which a request is made from the PathImageServer directly, rather than waiting for tile requests.
    • paintRegion

      public void paintRegion(ImageServer<BufferedImage> server, Graphics g, Shape clipShapeVisible, int zPosition, int tPosition, double downsampleFactor, BufferedImage imgThumbnail, ImageObserver observer, ImageRenderer imageDisplay)
      Description copied from interface: ImageRegionRenderer
      Paint an image region.
      Specified by:
      paintRegion in interface ImageRegionRenderer
      Parameters:
      server - the server representing the image that shown be painted
      g - the graphics object upon which to paint
      clipShapeVisible - the visible shape representing the area of the graphics object that should be filled
      zPosition - the z-stack position
      tPosition - the timepoint position
      downsampleFactor - the downsample factor
      imgThumbnail - a thumbnail image; if not null, this will be used to 'fill the gaps'
      observer - an ImageObserver (often ignored)
      imageDisplay - an ImageRenderer to convert images to RGB
    • close

      public void close()
    • getTileCacheSize

      public long getTileCacheSize()
      Get the tile cache size, in bytes. Image tiles larger than this cannot be cached.
      Returns:
    • getCachedThumbnail

      public BufferedImage getCachedThumbnail(ImageServer<BufferedImage> server, int zPosition, int tPosition)
    • registerRequest

      protected void registerRequest(TileListener<BufferedImage> tileListener, ImageServer<BufferedImage> server, Shape clipShape, double downsampleFactor, int zPosition, int tPosition)
      Register a request so that the tile request queue will be populated, including potentially for nearby tiles (i.e. preemptively).
      Parameters:
      tileListener -
      server -
      clipShape -
      downsampleFactor -
      zPosition -
      tPosition -
    • registerRequest

      protected void registerRequest(TileListener<BufferedImage> tileListener, ImageServer<BufferedImage> server, RegionRequest region, double downsampleFactor, int zPosition, int tPosition)
    • addTileListener

      public void addTileListener(TileListener<BufferedImage> listener)
    • getCache

      public Map<RegionRequest,BufferedImage> getCache()
    • removeTileListener

      public void removeTileListener(TileListener<BufferedImage> listener)
    • getCachedTile

      public BufferedImage getCachedTile(ImageServer<BufferedImage> server, RegionRequest request)
    • getCachedTilesForServer

      public Map<RegionRequest,BufferedImage> getCachedTilesForServer(ImageServer<BufferedImage> server)
      Get a map of all cached tiles pertaining to a specific ImageServer.
      Parameters:
      server -
      Returns:
    • workerComplete

      protected void workerComplete(qupath.lib.gui.images.stores.TileWorker<BufferedImage> worker)
      Every TileWorker should call this when the task is done!
      Parameters:
      worker -
    • getCachedRegion

      protected BufferedImage getCachedRegion(ImageServer<BufferedImage> server, RegionRequest request)
    • stopWaiting

      protected boolean stopWaiting(RegionRequest request)
    • requestImageTile

      protected Object requestImageTile(ImageServer<BufferedImage> server, RegionRequest request, Map<RegionRequest,BufferedImage> cache, boolean ensureTileReturned)
      Request an image tile. There are 3 possible return values: - a T for the tile - the TileWorker<T> object currently charged with fetching the tile - null, if this is the value stored in the TiledImageCache (i.e. the tile has previously been fetched, and there is no image corresponding to the request)
      Parameters:
      server -
      request -
      cache -
      ensureTileReturned -
      Returns:
    • createTileWorker

      protected qupath.lib.gui.images.stores.TileWorker<BufferedImage> createTileWorker(ImageServer<BufferedImage> server, RegionRequest request, Map<RegionRequest,BufferedImage> cache, boolean ensureTileReturned)
    • getThumbnail

      public BufferedImage getThumbnail(ImageServer<BufferedImage> server, int zPosition, int tPosition, boolean addToCache)
    • clearCache

      public void clearCache()
      Clear the cache, including thumbnails, and cancel any pending requests.
    • clearCache

      public void clearCache(boolean clearThumbnails, boolean stopWaiting)
      Clear the cache, optionally including thumbnails and stopping any pending requests.
      Parameters:
      clearThumbnails -
      stopWaiting -
    • clearCacheForServer

      public void clearCacheForServer(ImageServer<BufferedImage> server)
    • clearCacheForRequestOverlap

      public void clearCacheForRequestOverlap(RegionRequest request)