Package qupath.lib.gui.images.stores
Class DefaultImageRegionStore
java.lang.Object
qupath.lib.gui.images.stores.DefaultImageRegionStore
- All Implemented Interfaces:
- ImageRegionRenderer
An ImageRegionStore suitable for either Swing or JavaFX applications.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Map<RegionRequest, BufferedImage> protected List<TileListener<BufferedImage>> 
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddTileListener(TileListener<BufferedImage> listener) voidClear the cache, including thumbnails, and cancel any pending requests.voidclearCache(boolean stopWaiting) Clear the cache, optionally including thumbnails and stopping any pending requests.voidclearCacheForRequestOverlap(RegionRequest request) voidclearCacheForServer(ImageServer<BufferedImage> server) voidclose()protected qupath.lib.gui.images.stores.TileWorker<BufferedImage> createTileWorker(ImageServer<BufferedImage> server, RegionRequest request, Map<RegionRequest, BufferedImage> cache, boolean ensureTileReturned) getCache()protected BufferedImagegetCachedRegion(ImageServer<BufferedImage> server, RegionRequest request) getCachedThumbnail(ImageServer<BufferedImage> server, int zPosition, int tPosition) getCachedTile(ImageServer<BufferedImage> server, RegionRequest request) Get a map of all cached tiles pertaining to a specific ImageServer.getThumbnail(ImageServer<BufferedImage> server, int zPosition, int tPosition, boolean addToCache) longGet the tile cache size, in bytes.voidpaintRegion(ImageServer<BufferedImage> server, Graphics g, Shape clipShapeVisible, int zPosition, int tPosition, double downsampleFactor, BufferedImage imgThumbnail, ImageObserver observer, ImageRenderer imageDisplay) Paint an image region.voidpaintRegionCompletely(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)protected voidregisterRequest(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.voidremoveTileListener(TileListener<BufferedImage> listener) protected ObjectrequestImageTile(ImageServer<BufferedImage> server, RegionRequest request, Map<RegionRequest, BufferedImage> cache, boolean ensureTileReturned) Request an image tile.protected booleanstopWaiting(RegionRequest request) protected voidworkerComplete(qupath.lib.gui.images.stores.TileWorker<BufferedImage> worker) Every TileWorker should call this when the task is done!
- 
Field Details- 
tileListeners
- 
cache
 
- 
- 
Method Details- 
paintRegionCompletelypublic 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:
- paintRegionCompletelyin 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.
 
- 
paintRegionpublic 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:ImageRegionRendererPaint an image region.- Specified by:
- paintRegionin 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- ImageRendererto convert images to RGB
 
- 
closepublic void close()
- 
getTileCacheSizepublic long getTileCacheSize()Get the tile cache size, in bytes. Image tiles larger than this cannot be cached.- Returns:
 
- 
getCachedThumbnailpublic BufferedImage getCachedThumbnail(ImageServer<BufferedImage> server, int zPosition, int tPosition) 
- 
registerRequestprotected 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-
 
- 
addTileListener
- 
getCache
- 
removeTileListener
- 
getCachedTile
- 
getCachedTilesForServerGet a map of all cached tiles pertaining to a specific ImageServer.- Parameters:
- server-
- Returns:
 
- 
workerCompleteEvery TileWorker should call this when the task is done!- Parameters:
- worker-
 
- 
getCachedRegion
- 
stopWaiting
- 
requestImageTileprotected 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 - theTileWorker<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:
 
- 
createTileWorkerprotected qupath.lib.gui.images.stores.TileWorker<BufferedImage> createTileWorker(ImageServer<BufferedImage> server, RegionRequest request, Map<RegionRequest, BufferedImage> cache, boolean ensureTileReturned) 
- 
getThumbnailpublic BufferedImage getThumbnail(ImageServer<BufferedImage> server, int zPosition, int tPosition, boolean addToCache) 
- 
clearCachepublic void clearCache()Clear the cache, including thumbnails, and cancel any pending requests.
- 
clearCachepublic void clearCache(boolean stopWaiting) Clear the cache, optionally including thumbnails and stopping any pending requests.- Parameters:
- stopWaiting- cancel any tasks that are currently fetching tiles
 
- 
clearCacheForServer
- 
clearCacheForRequestOverlap
 
-