Class MultipleImageSelectionPanel

All Implemented Interfaces:
com.xinapse.util.CanLoadImage, ImageObserver, MenuContainer, Serializable, Accessible

public class MultipleImageSelectionPanel extends JPanel implements com.xinapse.util.CanLoadImage
A MultipleImageSelectionPanel shows a list of images, and contains the mechanism for selecting a new list of images, adding images to the list, removing images from the list, and changing the order of images in the list.
As images are added, the new images are sorted lexically and added to the list Usually used to select a set of input images for processing.

For an example of the use of a MultipleImageSelectionPanel, see the Perfusion/Permeability Tool in Jim.

See Also:
  • Constructor Details

  • Method Details

    • setParentWindow

      public void setParentWindow(Window parent)
      Sets the parent Window for this MultipleImageSelectionPanel.
      Parameters:
      parent - the parent MessageShower that contains this MultipleImageSelectionPanel. If parent is non-null, it will have its cursor set appropriately when the MultipleImageSelectionPanel is busy.
    • getNImages

      public int getNImages()
      Returns the number of images currently set in this MultipleImageSelectionPanel.
      Returns:
      the number of images currently set in this MultipleImageSelectionPanel.
    • getReadableImage

      public ReadableImage getReadableImage(int index) throws IndexOutOfBoundsException, IOException, InvalidImageException
      Returns the ReadableImage for the MultipleImageSelectionPanel at particular location in the list of images.
      Parameters:
      index - the position in the list (indexed from zero).
      Returns:
      the ReadableImage set for the MultipleImageSelectionPanel at the given position.
      Throws:
      IndexOutOfBoundsException - if the index is less than zero or greater than or equal to the number of images in the list.
      IOException - if an I/O error occurs while reading the image.
      InvalidImageException - if the image at the given index is invalid.
    • getReadableImages

      public ReadableImage[] getReadableImages() throws IOException, InvalidImageException
      Returns an array of ReadableImages with each array member being an image currently set in the MultipleImageSelectionPanel.
      Returns:
      an array of ReadableImages, one array element for each file set in the MultipleImageSelectionPanel. Returns null if there are are no images currently set.
      Throws:
      InvalidImageException - if any of the images is invalid.
      IOException - if an I/O error occurs while reading the images.
    • getWorkingDirectory

      public File getWorkingDirectory()
      Returns the "current working directory" for this MultipleImageSelectionPanel. When the user chooses a new image to set in the panel, the ImageFileChooser used to select the image starts with the directory set to the current working directory. When the user, using the ImageFileChooser, moves to a different directory, the current working directory is set to the new directory.
      Returns:
      the current working directory for this MultipleImageSelectionPanel.
    • setImageFilterClass

      public void setImageFilterClass(Class<? extends WritableImage> c)
      Sets the class of image that will be filtered when the user chooses a new image to set in the panel. The ImageFileChooser used to select the image starts with the correct image filter set.
      Parameters:
      c - the class of a valid image type to filter, e.g. com.xinapse.multisliceimage.UNC.UNCImage.class.
    • getImageFilterClass

      public Class getImageFilterClass()
      Returns the class of image that will be filtered when the user chooses a new image to set in the panel. The ImageFileChooser used to select the image starts with the correct image filter set.
      Returns:
      the class of image that will be filtered when the user chooses a new image to set in the panel.
    • addChangeListener

      public void addChangeListener(ChangeListener l)
      Add a ChangeListener to this MultipleImageSelectionPanel. All listeners are notified with a ChangeEvent when the image file is changed by the user. The image file is changed either by the user pressing the button and selecting a new file via the ImageFileChooser, or by the user editing the folder or file text (after pressing carriage return).
      Parameters:
      l - the listener to be added.
    • removeChangeListener

      public void removeChangeListener(ChangeListener l)
      Parameters:
      l - the listener to be removed.
    • getTitle

      public String getTitle()
      Returns the title for the list of images. The title appears just above the list.
      Returns:
      the current title for the list, or null if there is no title.
    • setTitle

      public void setTitle(String title)
      Sets the title for the list of images. The title appears just above the list.
      Parameters:
      title - the new title for the list. If title is null, then no title is shown.
    • clearFiles

      public void clearFiles()
      Removes all files from the list.
    • getPreferredSize

      public Dimension getPreferredSize()
      Override the default getPreferredSize() method. We don't want the MultipleImageSelectionPanel to resize itsself when files with long names are selected and the Component in which this component is embedded is packed(). Once the initial size has been set (and is non-zero), then this component will always have the same preferred size.
      Overrides:
      getPreferredSize in class JComponent
    • getMinimumSize

      public Dimension getMinimumSize()
      Overrides:
      getMinimumSize in class JComponent
    • addFiles

      public void addFiles(List<File> files)
      Parameters:
      files - the List of Files to add.
    • getParentWindow

      public Window getParentWindow()
      Description copied from interface: com.xinapse.util.CanLoadImage
      Get the Window which implements this CanLoadImage.
      Specified by:
      getParentWindow in interface com.xinapse.util.CanLoadImage
      Returns:
      the Window which implements the CanLoadImage.
    • busyCursors

      public void busyCursors()
      Description copied from interface: com.xinapse.util.CanLoadImage
      Set busy cursors.
      Specified by:
      busyCursors in interface com.xinapse.util.CanLoadImage
    • readyCursors

      public void readyCursors()
      Description copied from interface: com.xinapse.util.CanLoadImage
      Set ready cursors.
      Specified by:
      readyCursors in interface com.xinapse.util.CanLoadImage
    • showStatus

      public void showStatus(String msg)
      Description copied from interface: com.xinapse.util.CanLoadImage
      Show a status message.
      Specified by:
      showStatus in interface com.xinapse.util.CanLoadImage
      Parameters:
      msg - the message to show.
    • showError

      public void showError(String errorMsg)
      Description copied from interface: com.xinapse.util.CanLoadImage
      Show an error message.
      Specified by:
      showError in interface com.xinapse.util.CanLoadImage
      Parameters:
      errorMsg - the error message to show.
    • showError

      public void showError(String[] errorMsg)
      Description copied from interface: com.xinapse.util.CanLoadImage
      Show a multi-line error message.
      Specified by:
      showError in interface com.xinapse.util.CanLoadImage
      Parameters:
      errorMsg - the array of error messages to show - one per line.
    • loadImage

      public boolean loadImage(ReadableImage image, com.xinapse.util.ImageLoaderWorker worker)
      Description copied from interface: com.xinapse.util.CanLoadImage
      Load an image into this CanLoadImage.
      Specified by:
      loadImage in interface com.xinapse.util.CanLoadImage
      Parameters:
      image - the image to load.
      worker - the ImageLoaderWorker that loads the image.
      Returns:
      true if the image was loaded successfully; false otherwise.
    • isLoadInProgress

      public boolean isLoadInProgress()
      Description copied from interface: com.xinapse.util.CanLoadImage
      Tests whether this CanLoadImage is currently loading an image.
      Specified by:
      isLoadInProgress in interface com.xinapse.util.CanLoadImage
      Returns:
      true if an image is currently being loaded; false otherwise.
    • unloadImage

      public boolean unloadImage()
      Description copied from interface: com.xinapse.util.CanLoadImage
      Unload any current image from this CanLoadImage.
      Specified by:
      unloadImage in interface com.xinapse.util.CanLoadImage
      Returns:
      true if the image unloads successfully; false if the image does not unload successfully.
    • doPostLoad

      public void doPostLoad()
      Description copied from interface: com.xinapse.util.CanLoadImage
      Do things that need to be done on the event dispatch thread after the image has been loaded.
      Specified by:
      doPostLoad in interface com.xinapse.util.CanLoadImage