Class ImageSelectionPanel

All Implemented Interfaces:
MessageShower, ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
InputImageSelectionPanel, OutputImageSelectionPanel

public abstract class ImageSelectionPanel extends JPanel implements MessageShower
An ImageSelectionPanel is a JPanel that can be used to select an image, either for reading or for writing. The image 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.
See Also:
  • Field Details

    • setImageButton

      protected final com.xinapse.util.SVG.Button setImageButton
      The SVG.Button to set the image file.
    • folderLabel

      protected final JLabel folderLabel
      The JLabel to display along side the image folder, or null if the image folder isn't shown separately.
    • folderTextField

      protected final JTextField folderTextField
      The JTextField to set the image folder, or null if the image folder isn't shown separately.
    • fileLabel

      protected final JLabel fileLabel
      The JLabel to display along side the image file.
    • fileTextField

      protected final JTextField fileTextField
      The JTextField to set the image file.
    • fileSelectionPanel

      protected final JPanel fileSelectionPanel
      A JPanel displayed to allow an image file to be selected.
    • imageChooser

      protected ImageFileChooser imageChooser
      The ImageFileChooser that can be popped up to select a new image.
    • currentWorkingDirectory

      protected File currentWorkingDirectory
      The current working directory.
    • imageClassToFilter

      protected Class<? extends ReadableImage> imageClassToFilter
      The class of image that will intially be filtered when the user first selects the image.
  • Constructor Details

    • ImageSelectionPanel

      protected ImageSelectionPanel(MessageShower messageShower, File f, Class<? extends ReadableImage> imageClassToFilter, boolean oneLine)
      Creates new ImageSelectionPanel, with the default Folder given by argument, and with the image file selection field optionally on only one line.
      Parameters:
      messageShower - the MessageShower for showing messages to the user.
      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 - whether the ImageSelectionPanel is to appear on only one line.
  • Method Details

    • setFile

      public void setFile(File f)
      Sets the file in this ImageSelectionPanel to the specified file.
      Parameters:
      f - the file to set.
    • setWorkingDirectory

      public void setWorkingDirectory(File f)
      Sets the "current working directory" for this ImageSelectionPanel. 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.
      Parameters:
      f - if a directory, the current working directory is set to f; if a regular file, the current working directory is set to the directory containing f. If f is null, the current working directory is set to null.
    • getWorkingDirectory

      public File getWorkingDirectory()
      Returns the "current working directory" for this ImageSelectionPanel. 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.
      Returns:
      the "current working directory" for this ImageSelectionPanel.
    • setImageFilterClass

      public void setImageFilterClass(Class<? extends ReadableImage> c)
      Sets the class of image that will be filtered when the user first 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.
    • setEnabled

      public void setEnabled(boolean b)
      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 JComponent
      Parameters:
      b - if true, this ImageSelectionPanel is enabled; otherwise it is disabled.
    • getImageName

      public String getImageName() throws UnsetImageException
      Returns the name of the image set in this ImageSelectionPanel.
      Returns:
      the name of the image set in this ImageSelectionPanel.
      Throws:
      UnsetImageException - if an image has not been set.
    • getFile

      public File getFile() throws UnsetImageException
      Returns the image File set in this ImageSelectionPanel.
      Returns:
      the image file set in this ImageSelectionPanel.
      Throws:
      UnsetImageException - if an image has not been set.
    • showStatus

      public void showStatus(String message)
      Description copied from interface: MessageShower
      Displays a status message.
      Specified by:
      showStatus in interface MessageShower
      Parameters:
      message - the status message to display.
    • showError

      public void showError(String message)
      Description copied from interface: MessageShower
      Displays an error message, typically in a pop-up dialog.
      Specified by:
      showError in interface MessageShower
      Parameters:
      message - the error message to display.
    • showError

      public void showError(String[] messages)
      Description copied from interface: MessageShower
      Displays a multi-line error message, typically in a pop-up dialog.
      Specified by:
      showError in interface MessageShower
      Parameters:
      messages - the multi-line error message to display.
    • showSuppressibleError

      public boolean showSuppressibleError(String message)
      Description copied from interface: MessageShower
      Displays an error message, allowing the user to suppress future errors like this.
      Specified by:
      showSuppressibleError in interface MessageShower
      Parameters:
      message - the error message to display.
      Returns:
      true if the user has selected to suppress future errors like this; false if not.
    • busyCursors

      public void busyCursors()
      Description copied from interface: MessageShower
      Sets the cursor for this MessageShower to indicate that an operation is in progress.
      Specified by:
      busyCursors in interface MessageShower
    • readyCursors

      public void readyCursors()
      Description copied from interface: MessageShower
      Sets the cursor for this MessageShower to indicate that it is ready for user input.
      Specified by:
      readyCursors in interface MessageShower
    • getParentWindow

      public Window getParentWindow()
      Description copied from interface: MessageShower
      Returns the parent of this MessageShower.
      Specified by:
      getParentWindow in interface MessageShower
      Returns:
      the parent Window of this MessageShower.
    • setImageButtonToolTipText

      public void setImageButtonToolTipText(String text)
      Sets the tool tip text for the button that pops up an ImageFileChooser to select the image. By default this tool tip is "Load an image".
      Parameters:
      text - the tool tip text for the set image button.
    • setFileLabel

      public void setFileLabel(String label)
      Sets the label for the file selection text field. By default this label is "File:".
      Parameters:
      label - the label for the file selection text field.
    • setFolderLabel

      public void setFolderLabel(String label)
      Sets the label for the folder selection text field. By default this label is "Folder:".
      Parameters:
      label - the label for the folder selection text field.
    • setToolTipText

      public void setToolTipText(String text)
      Sets the tool tip text for the file selection text field. By default this tool tip is "Shows the current image name - edit to select a new image".
      Overrides:
      setToolTipText in class JComponent
      Parameters:
      text - the tool tip text for the file selection text field.
    • setFileToolTipText

      public void setFileToolTipText(String text)
      Sets the tool tip text for the file selection text field. By default this tool tip is "Shows the current image name - edit to select a new image".
      Parameters:
      text - the tool tip text for the file selection text field.
    • setFolderToolTipText

      public void setFolderToolTipText(String text)
      Sets the tool tip text for the folder selection text field. By default this tool tip is "Shows the directory of the current image".
      Parameters:
      text - the tool tip text for the folder selection text field.
    • setFileText

      public void setFileText(String text)
      Sets the text for the file selection text field.
      Parameters:
      text - the text for the file selection text field.
    • setFolderText

      public void setFolderText(String text)
      Sets the text for the folder selection text field.
      Parameters:
      text - the text for the folder selection text field.
    • addFileChangeCommitListener

      public void addFileChangeCommitListener(ChangeListener l)
      Add a ChangeListener to this ImageSelectionPanel. All listeners are notified with a ChangeEvent when the image file change is committed 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 (and pressing carriage return).
      Parameters:
      l - the listener to be added.
    • removeFileChangeCommitListener

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

      public void addFileTextEditListener(ChangeListener l)
      Add a ChangeListener to this ImageSelectionPanel. All listeners are notified with a ChangeEvent when the image file text is edited by the user.
      Parameters:
      l - the listener to be added.
    • removeFileTextEditListener

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

      public Dimension getPreferredSize()
      Overrides the default getPreferredSize() method. We don't want the ImageSelectionPanel to have a different preferred size, for example, when files with long names are selected and the Frame 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
      Returns:
      the preferred size of the component.