Interface DisplayWindow

All Superinterfaces:
AutoCloseable, Closeable, DataViewer, EventPublisher

public interface DisplayWindow extends DataViewer, Closeable
A DisplayWindow is the interface to Micro-Manager's image display windows.

It is not expected that third-party code implement this interface. If you want to provide your own custom display then you should implement DataViewer instead.

  • Method Details

    • displayStatusString

      void displayStatusString(String status)
      Display a custom string in the window.

      The string will remain displayed until this method is called again to change it.

      Calls are ignored if the display has closed.

      This method can be called from any thread.

      Parameters:
      status - String to display in the window.
    • getZoom

      double getZoom()
      Get the current zoom ratio of the display.

      If the display has closed, the returned value is undefined.

      This method can be called from any thread. However, you should call it from the Swing/AWT event dispatch thread if you want to correctly synchronize with other user interface changes.

      Returns:
      the current zoom ratio (1.0 = actual size)
    • getMagnification

      @Deprecated double getMagnification()
      Deprecated.
      use getZoom() instead
      Obsolete equivalent of getZoom().
      Returns:
      the current zoom level
    • setZoom

      void setZoom(double ratio)
      Set the zoom ratio for this display.

      Calls are ignored if the display has closed.

      This method can be called from any thread. However, you should call it from the Swing/AWT event dispatch thread if you want to correctly synchronize with other user interface changes.

      Parameters:
      ratio - zoom ratio to set (1.0 = actual size)
    • setMagnification

      @Deprecated void setMagnification(double ratio)
      Deprecated.
      use setZoom(double) instead
      Obsolete equivalent of setZoom(double).
      Parameters:
      ratio - Magnification ratio
    • adjustZoom

      void adjustZoom(double factor)
      Multiply the current zoom ratio of the image canvas by the provided factor.

      This is equivalent to setZoom(factor * getZoom()) if called on the Swing/AWT event dispatch thread.

      Calls are ignored if the display has closed.

      This method can be called from any thread. However, you should call it from the Swing/AWT event dispatch thread if you want to correctly synchronize with other user interface changes.

      Parameters:
      factor - the factor to zoom in by
    • autostretch

      void autostretch()
      Performs a one-shot autoscaling of intensities.

      The intensity range of the currently displayed image is used to set the intensity scaling range for all displayed channels.

      Calls are ignored if the display has closed.

      This method can be called from any thread. However, you should call it from the Swing/AWT event dispatch thread if you want to correctly synchronize with other user interface changes.

    • addOverlay

      void addOverlay(Overlay overlay)
      Add a graphical overlay.

      This method can be called from any thread. However, you should call it from the Swing/AWT event dispatch thread if you want to correctly synchronize with other user interface changes.

      Parameters:
      overlay - the overlay to add
      Throws:
      NullPointerException - if overlay is null
      See Also:
    • removeOverlay

      void removeOverlay(Overlay overlay)
      Remove a graphical overlay.

      This method can be called from any thread. However, you should call it from the Swing/AWT event dispatch thread if you want to correctly synchronize with other user interface changes.

      Parameters:
      overlay - the overlay to remove
      See Also:
    • getOverlays

      List<Overlay> getOverlays()
      Get the overlays attached to this display.

      This method can be called from any thread. However, you should call it from the Swing/AWT event dispatch thread if you want to correctly synchronize with other user interface changes.

      Returns:
      the overlays
      See Also:
    • getImagePlus

      @Deprecated ij.ImagePlus getImagePlus()
      Deprecated.
      Directly accessing the ImagePlus of an MMStudio display window will generally result in very fragile code. Consider accessing image data through DataViewer.getDataProvider(). For drawing overlay graphics, see addOverlay(Overlay).
      Return the ImageJ ImagePlus object used by the display window.

      Note that the ImagePlus may be replaced with a new one during the lifetime of the display window.

      It is recommended that this method be called on the Swing/AWT event dispatch thread. If you call it from another thread, make sure that your thread is not obstructing the event dispatch thread (i.e. the event dispatch thread is not waiting for your thread to finish something).

      Returns:
      the ImagePlus used by the window, which may be a CompositeImage, or null if none has been created or if the display has closed.
    • requestToClose

      boolean requestToClose()
      Close this display window, giving its owner a chance to cancel closing.

      For example, the owner may prompt the user to save the data associated with this display. Special display windows may perform other actions.

      Calls are ignored if the display has already closed.

      Returns:
      true if the display is closed, or was already closed; false if it remains open
    • close

      void close()
      Close this display window unconditionally.

      This will skip such actions as prompting the user to save the data. Special display windows may skip other special actions.

      Calls are ignored if the display has already closed.

      This method can be called from any thread. However, you should call it from the Swing/AWT event dispatch thread if you want to correctly synchronize with other user interface changes. In particular, the display may not have closed yet at the moment this method returns if called on another thread.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • setFullScreen

      void setFullScreen(boolean enable)
      Enable or disable full screen mode.

      Calls are ignored if the display has closed.

      This method can be called from any thread. However, you should call it from the Swing/AWT event dispatch thread if you want to correctly synchronize with other user interface changes.

      Parameters:
      enable - whether to enable or disable full screen mode
    • isFullScreen

      boolean isFullScreen()
      Tell whether full screen mode is currently enabled.

      It is recommended that this method be called on the Swing/AWT event dispatch thread. If you call it from another thread, make sure that your thread is not obstructing the event dispatch thread (i.e. the event dispatch thread is not waiting for your thread to finish something).

      Returns:
      whether full screen mode is enabled (false if the display has closed
    • toggleFullScreen

      @Deprecated void toggleFullScreen()
      Deprecated.
      Enable or disable full screen mode.

      Calls are ignored if the display has closed.

    • duplicate

      DisplayWindow duplicate()
      Create a new display window for the same data provider as this one.

      This method can be called from any thread. However, you should call it from the Swing/AWT event dispatch thread if you want to correctly synchronize with other user interface changes.

      Returns:
      the new display window
    • toFront

      void toFront()
      Raise this display window to the front.

      Calls are ignored if the display has closed.

      This method can be called from any thread. However, you should call it from the Swing/AWT event dispatch thread if you want to correctly synchronize with other user interface changes.

    • getWindow

      Window getWindow() throws IllegalStateException
      Get the java.awt.Window used for this image display.

      You should not access the contents of the returned window, but you can set its on-screen position and size, etc.

      If the display is in full screen mode, this method returns the original (hidden) window, not the window used for full-screen display.

      It is recommended that this method be called on the Swing/AWT event dispatch thread. If you call it from another thread, make sure that your thread is not obstructing the event dispatch thread (i.e. the event dispatch thread is not waiting for your thread to finish something).

      Returns:
      the java.awt.Window used by this image display
      Throws:
      IllegalStateException - if the display has closed
    • getAsWindow

      @Deprecated Window getAsWindow()
      Deprecated.
      use getWindow() instead
      Get the java.awt.Window used for this image display.
      Returns:
      the java.awt.Window used by this image display, or null if the display has been closed
    • setCustomTitle

      void setCustomTitle(String title)
      Add a custom extra string to the title of this display.

      The usual format for the window title is "#number: name (zoom ratio) (saved status)". If you call this method, then the name part will be replaced by your custom title. You can call this method with a null argument to revert to the default title, which is what DataViewer.getName() returns.

      Calls are ignored if the display has closed.

      This method can be called from any thread.

      Parameters:
      title - a custom window title, or null to revert to the default
    • setDisplaySettingsProfileKey

      void setDisplaySettingsProfileKey(String key)
      Set the key used to save and restore display settings to the user profile for this display.
      Parameters:
      key - String to use as the key for saving and restoring
    • setWindowPositionKey

      void setWindowPositionKey(String key)
      Sets a key that will be used to remember Window position in the profile.
      Parameters:
      key - Key to use for positioning the DisplayWindow. if called before showing the DisplayWindow, the DisplayWindow will be positioned at the remembered position.
    • show

      void show()
      DisplayWindows are not shown by default. Call this function after construction, and after attaching listeners as needed, to show the Window.