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.
- Author:
- Pete Bankhead
-
Field Summary
Modifier and TypeFieldDescriptionprotected Map
<RegionRequest, BufferedImage> protected static boolean
protected Map
<RegionRequest, BufferedImage> protected List
<TileListener<BufferedImage>> -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTileListener
(TileListener<BufferedImage> listener) void
Clear the cache, including thumbnails, and cancel any pending requests.void
clearCache
(boolean clearThumbnails, boolean stopWaiting) Clear the cache, optionally including thumbnails and stopping any pending requests.void
clearCacheForRequestOverlap
(RegionRequest request) void
clearCacheForServer
(ImageServer<BufferedImage> server) void
close()
protected qupath.lib.gui.images.stores.TileWorker
<BufferedImage> createTileWorker
(ImageServer<BufferedImage> server, RegionRequest request, Map<RegionRequest, BufferedImage> cache, boolean ensureTileReturned) getCache()
protected BufferedImage
getCachedRegion
(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) long
Get the tile cache size, in bytes.void
paintRegion
(ImageServer<BufferedImage> server, Graphics g, Shape clipShapeVisible, int zPosition, int tPosition, double downsampleFactor, BufferedImage imgThumbnail, ImageObserver observer, ImageRenderer imageDisplay) Paint an image region.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)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.protected void
registerRequest
(TileListener<BufferedImage> tileListener, ImageServer<BufferedImage> server, RegionRequest region, double downsampleFactor, int zPosition, int tPosition) void
removeTileListener
(TileListener<BufferedImage> listener) protected Object
requestImageTile
(ImageServer<BufferedImage> server, RegionRequest request, Map<RegionRequest, BufferedImage> cache, boolean ensureTileReturned) Request an image tile.protected boolean
stopWaiting
(RegionRequest request) protected void
workerComplete
(qupath.lib.gui.images.stores.TileWorker<BufferedImage> worker) Every TileWorker should call this when the task is done!
-
Field Details
-
paintTileBorders
protected static boolean paintTileBorders -
tileListeners
-
cache
-
thumbnailCache
-
-
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 interfaceImageRegionRenderer
- 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 interfaceImageRegionRenderer
- Parameters:
server
- the server representing the image that shown be paintedg
- the graphics object upon which to paintclipShapeVisible
- the visible shape representing the area of the graphics object that should be filledzPosition
- the z-stack positiontPosition
- the timepoint positiondownsampleFactor
- the downsample factorimgThumbnail
- a thumbnail image; if not null, this will be used to 'fill the gaps'observer
- anImageObserver
(often ignored)imageDisplay
- anImageRenderer
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
-
getCache
-
removeTileListener
-
getCachedTile
-
getCachedTilesForServer
Get a map of all cached tiles pertaining to a specific ImageServer.- Parameters:
server
-- Returns:
-
workerComplete
Every TileWorker should call this when the task is done!- Parameters:
worker
-
-
getCachedRegion
-
stopWaiting
-
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 - 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:
-
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
-
clearCacheForRequestOverlap
-