Package qupath.lib.gui.viewer
Class ViewerManager
java.lang.Object
qupath.lib.gui.viewer.ViewerManager
- All Implemented Interfaces:
EventListener
,QuPathViewerListener
Class to manage multiple
QuPathViewer
instances in a UI region.- Since:
- v0.5.0
- Author:
- Pete Bankhead
-
Property Summary
TypePropertyDescriptionGet a read-only property representing the currently active viewer.Read-only property containing the image open within the currently-active viewer.Show the cursor location.Show the overview image.Show the scalebar. -
Method Summary
Modifier and TypeMethodDescriptionGet a read-only property representing the currently active viewer.void
addColumn
(QuPathViewer viewer) void
addRow
(QuPathViewer viewer) boolean
void
Insert the currently active viewer back into the viewer grid.void
attachViewerToGrid
(QuPathViewer viewer) Attach the specified viewer to the viewer grid, if possible.static ViewerManager
Create a new instanceprotected QuPathViewerPlus
Create a viewer, adding it to the stored array but not adding it to any component (which is left up to the calling code to handle)void
Detach the currently active viewer from the viewer grid, if possible.void
detachViewerFromGrid
(QuPathViewer viewer) Detach the specified viewer from the viewer grid, if possible.Get the value ofactiveViewerProperty()
.Get an observable list of viewers.Get the overlay options shared by all viewers created by this manager.Get the region node that can be added to a scene graph to display the viewers.boolean
Gets the value of thesynchronizeViewers
property.void
imageDataChanged
(QuPathViewer viewer, ImageData<BufferedImage> imageDataOld, ImageData<BufferedImage> imageDataNew) Called with the image data within a viewer has changed.Read-only property containing the image open within the currently-active viewer.void
Match the display resolutions (downsamples) of all viewers to match the current viewer.void
Request that viewers refresh their titles.boolean
removeColumn
(QuPathViewer viewer) Try to remove the column containing the specified viewer, notifying the user if this isn't possible.boolean
removeRow
(QuPathViewer viewer) Try to remove the row containing the specified viewer, notifying the user if this isn't possible.void
Request that all viewers are repainted as soon as possible.void
void
selectedObjectChanged
(QuPathViewer viewer, PathObject pathObjectSelected) Called when the primary selected object has changed in a viewer.void
setActiveViewer
(QuPathViewer viewer) Sets the value of theactiveViewer
property.boolean
setGridSize
(int nRows, int nCols) Set the grid to have a specific number of rows and columns.void
setSynchronizeViewers
(boolean synchronizeViewers) Sets the value of thesynchronizeViewers
property.Show the cursor location.Show the overview image.Show the scalebar.void
splitViewer
(QuPathViewer viewer, boolean splitVertical) void
viewerClosed
(QuPathViewer viewer) Called when a viewer is closed.void
visibleRegionChanged
(QuPathViewer viewer, Shape shape) Called when the visible region has changed in a viewer.
-
Property Details
-
showOverview
Show the overview image.- See Also:
-
showLocation
Show the cursor location.- See Also:
-
showScalebar
Show the scalebar.- See Also:
-
imageData
Read-only property containing the image open within the currently-active viewer. To change the open image data, you should do so directly within the viewer.- See Also:
-
activeViewer
Get a read-only property representing the currently active viewer. Only one viewer can be active, and this should not be null (i.e. the list ofgetAllViewers()
should never be empty).- See Also:
-
synchronizeViewers
- See Also:
-
-
Method Details
-
create
Create a new instance- Parameters:
qupath
-- Returns:
-
refreshTitles
public void refreshTitles()Request that viewers refresh their titles. This is only really needed for detached viewers, so that they are notified of any changes to the image name. -
getAllViewers
Get an observable list of viewers. Note that the list is unmodifiable; viewers should be added or removed through other methods in thie class.- Returns:
-
getOverlayOptions
Get the overlay options shared by all viewers created by this manager.- Returns:
-
showOverviewProperty
Show the overview image.- Returns:
-
showLocationProperty
Show the cursor location.- Returns:
-
showScalebarProperty
Show the scalebar.- Returns:
-
matchResolutions
public void matchResolutions()Match the display resolutions (downsamples) of all viewers to match the current viewer. This uses calibrated pixel size information if available. -
setActiveViewer
Sets the value of theactiveViewer
property.- Property description:
- Get a read-only property representing the currently active viewer.
Only one viewer can be active, and this should not be null (i.e. the list of
getAllViewers()
should never be empty). - Parameters:
viewer
- the value for theactiveViewer
property- See Also:
-
imageDataProperty
Read-only property containing the image open within the currently-active viewer. To change the open image data, you should do so directly within the viewer.- Returns:
-
getActiveViewer
Get the value ofactiveViewerProperty()
.- Returns:
-
activeViewerProperty
Get a read-only property representing the currently active viewer. Only one viewer can be active, and this should not be null (i.e. the list ofgetAllViewers()
should never be empty).- Returns:
- See Also:
-
getRegion
Get the region node that can be added to a scene graph to display the viewers.- Returns:
-
repaintAllViewers
public void repaintAllViewers()Request that all viewers are repainted as soon as possible. -
createViewer
Create a viewer, adding it to the stored array but not adding it to any component (which is left up to the calling code to handle)- Returns:
-
removeRow
Try to remove the row containing the specified viewer, notifying the user if this isn't possible.- Parameters:
viewer
-- Returns:
- true if the row was removed, false otherwise
-
removeColumn
Try to remove the column containing the specified viewer, notifying the user if this isn't possible.- Parameters:
viewer
-- Returns:
- true if the column was removed, false otherwise
-
setGridSize
public boolean setGridSize(int nRows, int nCols) Set the grid to have a specific number of rows and columns.- Parameters:
nRows
-nCols
-- Returns:
-
addRow
-
addColumn
-
splitViewer
-
resetGridSize
public void resetGridSize() -
imageDataChanged
public void imageDataChanged(QuPathViewer viewer, ImageData<BufferedImage> imageDataOld, ImageData<BufferedImage> imageDataNew) Description copied from interface:QuPathViewerListener
Called with the image data within a viewer has changed.- Specified by:
imageDataChanged
in interfaceQuPathViewerListener
- Parameters:
viewer
- the viewer whose image has changedimageDataOld
- the image previously open in the viewerimageDataNew
- the image now open in the viewer
-
visibleRegionChanged
Description copied from interface:QuPathViewerListener
Called when the visible region has changed in a viewer.- Specified by:
visibleRegionChanged
in interfaceQuPathViewerListener
- Parameters:
viewer
- the viewer whose visible region has changed.shape
- shape representing the new visible region (in image pixel coordinates). This is rectangular, but may also be rotated.
-
getSynchronizeViewers
public boolean getSynchronizeViewers()Gets the value of thesynchronizeViewers
property.- Property description:
- Returns:
- the value of the
synchronizeViewers
property - See Also:
-
setSynchronizeViewers
public void setSynchronizeViewers(boolean synchronizeViewers) Sets the value of thesynchronizeViewers
property.- Property description:
- Parameters:
synchronizeViewers
- the value for thesynchronizeViewers
property- See Also:
-
synchronizeViewersProperty
- Returns:
- the
synchronizeViewers
property - See Also:
-
selectedObjectChanged
Description copied from interface:QuPathViewerListener
Called when the primary selected object has changed in a viewer.- Specified by:
selectedObjectChanged
in interfaceQuPathViewerListener
- Parameters:
viewer
- the viewerpathObjectSelected
-
-
applyLastAnnotationToActiveViewer
public boolean applyLastAnnotationToActiveViewer() -
viewerClosed
Description copied from interface:QuPathViewerListener
Called when a viewer is closed.- Specified by:
viewerClosed
in interfaceQuPathViewerListener
- Parameters:
viewer
- the viewer that has been closed.
-
detachActiveViewerFromGrid
public void detachActiveViewerFromGrid()Detach the currently active viewer from the viewer grid, if possible. -
attachActiveViewerToGrid
public void attachActiveViewerToGrid()Insert the currently active viewer back into the viewer grid.- See Also:
-
detachViewerFromGrid
Detach the specified viewer from the viewer grid, if possible. This will remove the viewer from the grid, and create a new window to contain it.- Parameters:
viewer
-- See Also:
-
attachViewerToGrid
Attach the specified viewer to the viewer grid, if possible. It will be inserted in place of the first available empty viewer slot. If no empty slots are available, an error will be shown.- Parameters:
viewer
-
-