loci.formats.gui

## Class ImageViewer

- java.lang.Object
- - java.awt.Component
  - - java.awt.Container
    - - java.awt.Window
      - - java.awt.Frame
        - - javax.swing.JFrame
          - - loci.formats.gui.ImageViewer

- All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.MouseMotionListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener, javax.swing.RootPaneContainer, javax.swing.WindowConstants

      public class ImageViewer
      extends javax.swing.JFrame
      implements java.awt.event.ActionListener, javax.swing.event.ChangeListener, java.awt.event.KeyListener, java.awt.event.MouseMotionListener, java.lang.Runnable, java.awt.event.WindowListener

  ImageViewer is a simple viewer/converter for the Bio-Formats image formats.
  Author:
    Curtis Rueden ctrueden at wisc.edu
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class javax.swing.JFrame

      `javax.swing.JFrame.AccessibleJFrame`

    - ### Nested classes/interfaces inherited from class java.awt.Frame

      `java.awt.Frame.AccessibleAWTFrame`

    - ### Nested classes/interfaces inherited from class java.awt.Window

      `java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type`

    - ### Nested classes/interfaces inherited from class java.awt.Container

      `java.awt.Container.AccessibleAWTContainer`

    - ### Nested classes/interfaces inherited from class java.awt.Component

      `java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `anim`
    `protected static char` | `ANIMATION_KEY`
    `protected boolean` | `canCloseReader`
    `protected javax.swing.JSlider` | `cSlider`
    `protected java.lang.String` | `filename`
    `protected IFormatReader` | `fileReader` Reader for files on disk.
    `protected javax.swing.JMenuItem` | `fileSave`
    `protected javax.swing.JMenuItem` | `fileView`
    `protected IFormatWriter` | `fileWriter` Writer for files on disk.
    `protected int` | `fps`
    `protected javax.swing.ImageIcon` | `icon`
    `protected javax.swing.JLabel` | `iconLabel`
    `protected java.awt.image.BufferedImage[]` | `images`
    `protected IFormatReader` | `in`
    `private static org.slf4j.Logger` | `LOGGER`
    `protected BufferedImageReader` | `myReader` Current format reader.
    `protected BufferedImageWriter` | `myWriter` Current format writer.
    `protected javax.swing.JSlider` | `nSlider`
    `protected MetadataStore` | `omeMeta` Attached OME metadata store, if available.
    `protected OMEXMLService` | `omexmlService` Service for working with OME-XML metadata.
    `protected javax.swing.JPanel` | `pane`
    `protected javax.swing.JLabel` | `probeLabel`
    `protected java.lang.StringBuilder` | `sb`
    `protected int` | `sizeC`
    `protected int` | `sizeT`
    `protected int` | `sizeZ`
    `protected javax.swing.JPanel` | `sliderPanel`
    `protected static java.lang.String` | `TITLE`
    `protected javax.swing.JSlider` | `tSlider`
    `protected javax.swing.JSlider` | `zSlider`

    - ### Fields inherited from class javax.swing.JFrame

      `accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled`

    - ### Fields inherited from class java.awt.Frame

      `CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR`

    - ### Fields inherited from class java.awt.Component

      `BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

    - ### Fields inherited from interface javax.swing.WindowConstants

      `DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE`

    - ### Fields inherited from interface java.awt.image.ImageObserver

      `ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ImageViewer()` Constructs an image viewer.
    `ImageViewer(boolean canCloseReader)` Constructs an image viewer.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `actionPerformed(java.awt.event.ActionEvent e)` Handles menu commands.
    `int` | `getC()` Gets the C value of the currently displayed image.
    `java.awt.image.BufferedImage` | `getImage()` Gets the currently displayed image.
    `int` | `getImageIndex()` Gets the index of the currently displayed image.
    `int` | `getT()` Gets the T value of the currently displayed image.
    `int` | `getZ()` Gets the Z value of the currently displayed image.
    `void` | `keyPressed(java.awt.event.KeyEvent e)` Handles key presses.
    `void` | `keyReleased(java.awt.event.KeyEvent e)`
    `void` | `keyTyped(java.awt.event.KeyEvent e)`
    `static void` | `main(java.lang.String[] args)`
    `void` | `mouseDragged(java.awt.event.MouseEvent e)` Handles cursor probes.
    `void` | `mouseMoved(java.awt.event.MouseEvent e)` Handles cursor probes.
    `void` | `open(java.lang.String id)` Opens the given data source using the current format reader.
    `protected void` | `open(java.lang.String id, IFormatReader r)` Opens from the given data source using the specified reader in a separate thread.
    `void` | `run()` Handles animation.
    `void` | `save(java.lang.String id)` Saves the current images to the given destination using the current format writer.
    `protected void` | `save(java.lang.String id, IFormatWriter w)` Saves to the given data destination using the specified writer in a separate thread.
    `void` | `setImages(java.awt.image.BufferedImage[] img)` Sets the viewer to display the given images.
    `void` | `setImages(IFormatReader reader, java.awt.image.BufferedImage[] img)` Sets the viewer to display the given images, obtaining corresponding core metadata from the specified format reader.
    `void` | `setVisible(boolean visible)`
    `void` | `stateChanged(javax.swing.event.ChangeEvent e)` Handles slider events.
    `protected void` | `updateLabel(int x, int y)` Updates cursor probe label.
    `protected void` | `wait(boolean wait)` Toggles wait cursor.
    `void` | `windowActivated(java.awt.event.WindowEvent e)`
    `void` | `windowClosed(java.awt.event.WindowEvent e)`
    `void` | `windowClosing(java.awt.event.WindowEvent e)`
    `void` | `windowDeactivated(java.awt.event.WindowEvent e)`
    `void` | `windowDeiconified(java.awt.event.WindowEvent e)`
    `void` | `windowIconified(java.awt.event.WindowEvent e)`
    `void` | `windowOpened(java.awt.event.WindowEvent e)`

    - ### Methods inherited from class javax.swing.JFrame

      `addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update`

    - ### Methods inherited from class java.awt.Frame

      `addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated`

    - ### Methods inherited from class java.awt.Window

      `addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, show, toBack, toFront`

    - ### Methods inherited from class java.awt.Container

      `add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree`

    - ### Methods inherited from class java.awt.Component

      `action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.awt.MenuContainer

      `getFont, postEvent`

- - ### Field Detail

    - #### LOGGER

          private static final org.slf4j.Logger LOGGER

    - #### TITLE

          protected static final java.lang.String TITLE

      See Also:
        Constant Field Values

    - #### ANIMATION_KEY

          protected static final char ANIMATION_KEY

      See Also:
        Constant Field Values

    - #### pane

          protected javax.swing.JPanel pane

    - #### icon

          protected javax.swing.ImageIcon icon

    - #### iconLabel

          protected javax.swing.JLabel iconLabel

    - #### sliderPanel

          protected javax.swing.JPanel sliderPanel

    - #### nSlider

          protected javax.swing.JSlider nSlider

    - #### zSlider

          protected javax.swing.JSlider zSlider

    - #### tSlider

          protected javax.swing.JSlider tSlider

    - #### cSlider

          protected javax.swing.JSlider cSlider

    - #### probeLabel

          protected javax.swing.JLabel probeLabel

    - #### fileView

          protected javax.swing.JMenuItem fileView

    - #### fileSave

          protected javax.swing.JMenuItem fileSave

    - #### omeMeta

          protected MetadataStore omeMeta

      Attached OME metadata store, if available.

    - #### myReader

          protected BufferedImageReader myReader

      Current format reader.

    - #### myWriter

          protected BufferedImageWriter myWriter

      Current format writer.

    - #### fileReader

          protected IFormatReader fileReader

      Reader for files on disk.

    - #### fileWriter

          protected IFormatWriter fileWriter

      Writer for files on disk.

    - #### filename

          protected java.lang.String filename

    - #### in

          protected IFormatReader in

    - #### images

          protected java.awt.image.BufferedImage[] images

    - #### sizeZ

          protected int sizeZ

    - #### sizeT

          protected int sizeT

    - #### sizeC

          protected int sizeC

    - #### anim

          protected boolean anim

    - #### fps

          protected int fps

    - #### canCloseReader

          protected boolean canCloseReader

    - #### omexmlService

          protected OMEXMLService omexmlService

      Service for working with OME-XML metadata.

    - #### sb

          protected final java.lang.StringBuilder sb

  - ### Constructor Detail

    - #### ImageViewer

          public ImageViewer()

      Constructs an image viewer.

    - #### ImageViewer

          public ImageViewer(boolean canCloseReader)

      Constructs an image viewer.
      Parameters:
        `canCloseReader` - whether or not the underlying reader can be closed

  - ### Method Detail

    - #### open

          public void open(java.lang.String id)

      Opens the given data source using the current format reader.

    - #### save

          public void save(java.lang.String id)

      Saves the current images to the given destination using the current format writer.

    - #### setImages

          public void setImages(java.awt.image.BufferedImage[] img)

      Sets the viewer to display the given images.

    - #### setImages

          public void setImages(IFormatReader reader,
                                java.awt.image.BufferedImage[] img)

      Sets the viewer to display the given images, obtaining corresponding core metadata from the specified format reader.

    - #### getImage

          public java.awt.image.BufferedImage getImage()

      Gets the currently displayed image.

    - #### getImageIndex

          public int getImageIndex()

      Gets the index of the currently displayed image.

    - #### getZ

          public int getZ()

      Gets the Z value of the currently displayed image.

    - #### getT

          public int getT()

      Gets the T value of the currently displayed image.

    - #### getC

          public int getC()

      Gets the C value of the currently displayed image.

    - #### setVisible

          public void setVisible(boolean visible)

      Overrides:
        `setVisible` in class `java.awt.Window`

    - #### actionPerformed

          public void actionPerformed(java.awt.event.ActionEvent e)

      Handles menu commands.
      Specified by:
        `actionPerformed` in interface `java.awt.event.ActionListener`

    - #### stateChanged

          public void stateChanged(javax.swing.event.ChangeEvent e)

      Handles slider events.
      Specified by:
        `stateChanged` in interface `javax.swing.event.ChangeListener`

    - #### keyPressed

          public void keyPressed(java.awt.event.KeyEvent e)

      Handles key presses.
      Specified by:
        `keyPressed` in interface `java.awt.event.KeyListener`

    - #### keyReleased

          public void keyReleased(java.awt.event.KeyEvent e)

      Specified by:
        `keyReleased` in interface `java.awt.event.KeyListener`

    - #### keyTyped

          public void keyTyped(java.awt.event.KeyEvent e)

      Specified by:
        `keyTyped` in interface `java.awt.event.KeyListener`

    - #### mouseDragged

          public void mouseDragged(java.awt.event.MouseEvent e)

      Handles cursor probes.
      Specified by:
        `mouseDragged` in interface `java.awt.event.MouseMotionListener`

    - #### mouseMoved

          public void mouseMoved(java.awt.event.MouseEvent e)

      Handles cursor probes.
      Specified by:
        `mouseMoved` in interface `java.awt.event.MouseMotionListener`

    - #### run

          public void run()

      Handles animation.
      Specified by:
        `run` in interface `java.lang.Runnable`

    - #### windowClosing

          public void windowClosing(java.awt.event.WindowEvent e)

      Specified by:
        `windowClosing` in interface `java.awt.event.WindowListener`

    - #### windowActivated

          public void windowActivated(java.awt.event.WindowEvent e)

      Specified by:
        `windowActivated` in interface `java.awt.event.WindowListener`

    - #### windowDeactivated

          public void windowDeactivated(java.awt.event.WindowEvent e)

      Specified by:
        `windowDeactivated` in interface `java.awt.event.WindowListener`

    - #### windowOpened

          public void windowOpened(java.awt.event.WindowEvent e)

      Specified by:
        `windowOpened` in interface `java.awt.event.WindowListener`

    - #### windowIconified

          public void windowIconified(java.awt.event.WindowEvent e)

      Specified by:
        `windowIconified` in interface `java.awt.event.WindowListener`

    - #### windowDeiconified

          public void windowDeiconified(java.awt.event.WindowEvent e)

      Specified by:
        `windowDeiconified` in interface `java.awt.event.WindowListener`

    - #### windowClosed

          public void windowClosed(java.awt.event.WindowEvent e)

      Specified by:
        `windowClosed` in interface `java.awt.event.WindowListener`

    - #### updateLabel

          protected void updateLabel(int x,
                                     int y)

      Updates cursor probe label.

    - #### wait

          protected void wait(boolean wait)

      Toggles wait cursor.

    - #### open

          protected void open(java.lang.String id,
                              IFormatReader r)

      Opens from the given data source using the specified reader in a separate thread.

    - #### save

          protected void save(java.lang.String id,
                              IFormatWriter w)

      Saves to the given data destination using the specified writer in a separate thread.

    - #### main

          public static void main(java.lang.String[] args)

Copyright © 2026 Open Microscopy Environment