Class InputImageSelectionPanel

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

public class InputImageSelectionPanel extends ImageSelectionPanel implements com.xinapse.util.CanLoadImage
A component that can be used to select a ReadableImage for input. The ReadableImage file can be selected either by pressing a button (with an icon on it) and selecting the file via an ImageFileChooser, or by editing the text fields that select the directory (folder) and file name, or by drag-and-drop.
See Also:
  • Constructor Details

    • InputImageSelectionPanel

      public InputImageSelectionPanel(MessageShower messageShower)
      Creates new InputImageSelectionPanel, with the default Folder set to the System Property user.dir.
      Parameters:
      messageShower - the MessageShower that will show error and status messages, etc.
    • InputImageSelectionPanel

      public InputImageSelectionPanel(MessageShower messageShower, boolean oneLine)
      Creates new InputImageSelectionPanel, with the default Folder set to the System Property user.dir, and with the image file selection field on only one line.
      Parameters:
      messageShower - the MessageShower that will show error and status messages, etc.
      oneLine - if the InputImageSelectionPanel is to appear on only one line.
    • InputImageSelectionPanel

      public InputImageSelectionPanel(MessageShower messageShower, File f, Class<? extends ReadableImage> imageClassToFilter, boolean oneLine)
      Creates new InputImageSelectionPanel, with the default Folder given by argument, and with the image file selection field optionally on only one line.
      Parameters:
      messageShower - the MessageShower that will show error and status messages, etc.
      f - used to set the default folder for the image. If f is a directory, then the default folder is set to f. If f is a regular file, the default folder is set to the parent directory of f. If f is null, then the default folder is set to the System Property user.dir.
      imageClassToFilter - the Class of the image (e.g. com.xinapse.multisliceimage.UNC.UNCImage.class) that will be the default image type to filter on.
      oneLine - if the InputImageSelectionPanel is to appear on only one line.
  • Method Details

    • getPreferredSize

      public Dimension getPreferredSize()
      Override the default getPreferredSize() method.
      Overrides:
      getPreferredSize in class ImageSelectionPanel
      Returns:
      the preferred size of the component.
    • setFile

      public void setFile(File f)
      Description copied from class: ImageSelectionPanel
      Sets the file in this ImageSelectionPanel to the specified file.
      Overrides:
      setFile in class ImageSelectionPanel
      Parameters:
      f - the file to set.
    • setFileText

      public void setFileText(String text)
      Description copied from class: ImageSelectionPanel
      Sets the text for the file selection text field.
      Overrides:
      setFileText in class ImageSelectionPanel
      Parameters:
      text - the text for the file selection text field.
    • getReadableImage

      public ReadableImage getReadableImage() throws UnsetImageException, InvalidImageException
      Returns the ReadableImage that has been set in this InputImageSelectionPanel. If no image has been set, then a UnsetFileException is thrown. If the Folder field is blank, then the File is constructed using the System Property "user.dir" as the parent directory of the returned File.
      Returns:
      the ReadableImage that has been set in this InputImageSelectionPanel.
      Throws:
      UnsetImageException - if no ReadableImage has been set.
      InvalidImageException - if the image set does not yield a valid ReadableImage.
    • getImageName

      public String getImageName() throws UnsetImageException
      Description copied from class: ImageSelectionPanel
      Returns the name of the image set in this ImageSelectionPanel.
      Overrides:
      getImageName in class ImageSelectionPanel
      Returns:
      the name of the image set in this ImageSelectionPanel.
      Throws:
      UnsetImageException - if an image has not been set.
    • setEditable

      public void setEditable(boolean editable)
      Sets whether text for folder/file selection is editable. If it is not editable, then the user must select a new file by pressing the button with the icon on.
      Parameters:
      editable - if true then the text fields will be editable; not editable otherwise.
    • loadImage

      public boolean loadImage(ReadableImage image, com.xinapse.util.ImageLoaderWorker imageLoaderWorker)
      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.
      imageLoaderWorker - the ImageLoaderWorker that loads the image.
      Returns:
      true if the image was loaded successfully; false otherwise.
    • doPostLoad

      public void doPostLoad()
      Does nothing.
      Specified by:
      doPostLoad in interface com.xinapse.util.CanLoadImage
    • unloadImage

      public boolean unloadImage()
      Unloads the image set in this InputImageSelectionPanel.
      Specified by:
      unloadImage in interface com.xinapse.util.CanLoadImage
      Returns:
      true because the image unload is always successful.
    • 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.
    • setEnabled

      public void setEnabled(boolean b)
      Description copied from class: ImageSelectionPanel
      Enables or disables this ImageSelectionPanel, depending on the value of the parameter b. An enabled ImageSelectionPanel can respond to user input and generate events.
      Overrides:
      setEnabled in class ImageSelectionPanel
      Parameters:
      b - if true, this ImageSelectionPanel is enabled; otherwise it is disabled.