Class ViewerManager

java.lang.Object
qupath.lib.gui.viewer.ViewerManager
All Implemented Interfaces:
EventListener, QuPathViewerListener

public class ViewerManager extends Object implements QuPathViewerListener
Class to manage multiple QuPathViewer instances in a UI region.
Since:
v0.5.0
Author:
Pete Bankhead
  • Property Details

  • Method Details

    • create

      public static ViewerManager create(QuPathGUI qupath)
      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

      public ObservableList<QuPathViewer> 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

      public OverlayOptions getOverlayOptions()
      Get the overlay options shared by all viewers created by this manager.
      Returns:
    • showOverviewProperty

      public BooleanProperty showOverviewProperty()
      Show the overview image.
      Returns:
    • showLocationProperty

      public BooleanProperty showLocationProperty()
      Show the cursor location.
      Returns:
    • showScalebarProperty

      public BooleanProperty 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

      public void setActiveViewer(QuPathViewer viewer)
      Sets the value of the activeViewer 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 the activeViewer property
      See Also:
    • imageDataProperty

      public ReadOnlyObjectProperty<ImageData<BufferedImage>> 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

      public QuPathViewer getActiveViewer()
      Get the value of activeViewerProperty().
      Returns:
    • activeViewerProperty

      public ReadOnlyObjectProperty<QuPathViewer> 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 of getAllViewers() should never be empty).
      Returns:
      See Also:
    • getRegion

      public Region 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

      protected QuPathViewerPlus 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

      public boolean removeRow(QuPathViewer viewer)
      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

      public boolean removeColumn(QuPathViewer viewer)
      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

      public void addRow(QuPathViewer viewer)
    • addColumn

      public void addColumn(QuPathViewer viewer)
    • splitViewer

      public void splitViewer(QuPathViewer viewer, boolean splitVertical)
    • 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 interface QuPathViewerListener
      Parameters:
      viewer - the viewer whose image has changed
      imageDataOld - the image previously open in the viewer
      imageDataNew - the image now open in the viewer
    • visibleRegionChanged

      public void visibleRegionChanged(QuPathViewer viewer, Shape shape)
      Description copied from interface: QuPathViewerListener
      Called when the visible region has changed in a viewer.
      Specified by:
      visibleRegionChanged in interface QuPathViewerListener
      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 the synchronizeViewers property.
      Property description:
      Returns:
      the value of the synchronizeViewers property
      See Also:
    • setSynchronizeViewers

      public void setSynchronizeViewers(boolean synchronizeViewers)
      Sets the value of the synchronizeViewers property.
      Property description:
      Parameters:
      synchronizeViewers - the value for the synchronizeViewers property
      See Also:
    • synchronizeViewersProperty

      public ReadOnlyBooleanProperty synchronizeViewersProperty()
      Returns:
      the synchronizeViewers property
      See Also:
    • selectedObjectChanged

      public void selectedObjectChanged(QuPathViewer viewer, PathObject pathObjectSelected)
      Description copied from interface: QuPathViewerListener
      Called when the primary selected object has changed in a viewer.
      Specified by:
      selectedObjectChanged in interface QuPathViewerListener
      Parameters:
      viewer - the viewer
      pathObjectSelected -
    • applyLastAnnotationToActiveViewer

      public boolean applyLastAnnotationToActiveViewer()
    • viewerClosed

      public void viewerClosed(QuPathViewer viewer)
      Description copied from interface: QuPathViewerListener
      Called when a viewer is closed.
      Specified by:
      viewerClosed in interface QuPathViewerListener
      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

      public void detachViewerFromGrid(QuPathViewer viewer)
      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

      public void attachViewerToGrid(QuPathViewer viewer)
      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 -