com.xinapse.multisliceimage
Class ImageSelectionPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.xinapse.multisliceimage.ImageSelectionPanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
Direct Known Subclasses:
OutputImageSelectionPanel

public class ImageSelectionPanel
extends javax.swing.JPanel

An ImageSelectioPanel is a javax.swing.JPanel that can be used to select a MultiSliceImage for input. The MultiSliceImage 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:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
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
protected  ImageFileChooser imageChooser
          The ImageFileChooser that can be popped up to select a new image.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ImageSelectionPanel()
          Creates new ImageSelectionPanel, with the default Folder set to the System Property user.dir.
ImageSelectionPanel(boolean acceptDicom)
          Creates new ImageSelectionPanel, with the default Folder set to the System Property user.dir.
ImageSelectionPanel(boolean oneLine, boolean acceptDicom)
          Creates new ImageSelectionPanel, with the default Folder set to the System Property user.dir, and with the image file selection field on only one line.
ImageSelectionPanel(java.io.File f, java.lang.Class imageClassToFilter, boolean acceptDicom)
          Creates new ImageSelectionPanel, with the default Folder given by argument.
ImageSelectionPanel(java.io.File f, java.lang.Class imageClassToFilter, boolean oneLine, boolean acceptDicom)
          Creates new ImageSelectionPanel, with the default Folder given by argument, and with the image file selection field on only one line.
 
Method Summary
 void addFileChangeCommitListener(javax.swing.event.ChangeListener l)
          Add a ChangeListener to this ImageSelectionPanel.
 void addFileTextEditListener(javax.swing.event.ChangeListener l)
          Add a ChangeListener to this ImageSelectionPanel.
 java.io.File getFile()
          Returns the java.io.File that has been set in this ImageSelectionPanel.
 java.lang.Class getImageFilterClass()
          Returns the class of image that will be filtered when the user first chooses a new image to set in the panel.
 java.awt.Dimension getPreferredSize()
          Override the default getPreferredSize() method.
 java.io.File getWorkingDirectory()
          Returns the "current working directory" for this ImageSelectionPanel.
 void removeFileChangeCommitListener(javax.swing.event.ChangeListener l)
          Remove a ChangeListener from this ImageSelectionPanel.
 void removeFileTextEditListener(javax.swing.event.ChangeListener l)
          Remove a ChangeListener from this ImageSelectionPanel.
 void setEditable(boolean editable)
          Sets whether text for folder/file selection is editable.
 void setEnabled(boolean b)
          Enables or disables this ImageSelectionPanel, depending on the value of the parameter b.
 void setFile(java.io.File f)
          Sets the file in this ImageSelectionPanel to the specified file.
 void setFileLabel(java.lang.String label)
          Sets the label for the file selection text field.
 void setFileText(java.lang.String text)
          Sets the text for the file selection text field.
 void setFileToolTipText(java.lang.String text)
          Sets the tool tip text for the file selection text field.
 void setFolderLabel(java.lang.String label)
          Sets the label for the folder selection text field.
 void setFolderText(java.lang.String text)
          Sets the text for the folder selection text field.
 void setFolderToolTipText(java.lang.String text)
          Sets the tool tip text for the folder selection text field.
 void setImageButtonToolTipText(java.lang.String text)
          Sets the tool tip text for the button that pops up an ImageFileChooser to select the image.
 void setImageFilterClass(java.lang.Class c)
          Sets the class of image that will be filtered when the user first chooses a new image to set in the panel.
 void setWorkingDirectory(java.io.File f)
          Sets the "current working directory" for this ImageSelectionPanel.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

imageChooser

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

Constructor Detail

ImageSelectionPanel

public ImageSelectionPanel()
Creates new ImageSelectionPanel, with the default Folder set to the System Property user.dir. DICOM image files may not be selected.


ImageSelectionPanel

public ImageSelectionPanel(boolean acceptDicom)
Creates new ImageSelectionPanel, with the default Folder set to the System Property user.dir.

Parameters:
acceptDicom - whether to allow selection of DICOM image files.

ImageSelectionPanel

public ImageSelectionPanel(boolean oneLine,
                           boolean acceptDicom)
Creates new ImageSelectionPanel, with the default Folder set to the System Property user.dir, and with the image file selection field on only one line.

Parameters:
oneLine - if the ImageSelectionPanel is to appear on only one line.

ImageSelectionPanel

public ImageSelectionPanel(java.io.File f,
                           java.lang.Class imageClassToFilter,
                           boolean acceptDicom)
Creates new ImageSelectionPanel, with the default Folder given by argument.

Parameters:
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 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.
acceptDicom - whether to allow selection of DICOM image files.

ImageSelectionPanel

public ImageSelectionPanel(java.io.File f,
                           java.lang.Class imageClassToFilter,
                           boolean oneLine,
                           boolean acceptDicom)
Creates new ImageSelectionPanel, with the default Folder given by argument, and with the image file selection field on only one line.

Parameters:
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 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 ImageSelectionPanel is to appear on only one line.
acceptDicom - whether to allow selection of DICOM image files.
Method Detail

setFile

public void setFile(java.io.File f)
Sets the file in this ImageSelectionPanel to the specified file.

Parameters:
f - the file to set.

setWorkingDirectory

public void setWorkingDirectory(java.io.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 java.io.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(java.lang.Class 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.

getImageFilterClass

public java.lang.Class getImageFilterClass()
Returns 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.

Returns:
the class of image that will be filtered when the user first chooses a new image to set in the panel.

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 javax.swing.JComponent
Parameters:
b - if true, this ImageSelectionPanel is enabled; otherwise it is disabled.

getFile

public java.io.File getFile()
                     throws UnsetFileException
Returns the java.io.File that has been set in this ImageSelectionPanel. If no File has been set, then a com.xinapse/io.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 java.io.File that has been set in this ImageSelectionPanel.
Throws:
UnsetFileException - if no File has been set.

setImageButtonToolTipText

public void setImageButtonToolTipText(java.lang.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(java.lang.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(java.lang.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.

setFileToolTipText

public void setFileToolTipText(java.lang.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(java.lang.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(java.lang.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(java.lang.String text)
Sets the text for the folder selection text field.

Parameters:
text - the text for the folder selection text field.

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.

addFileChangeCommitListener

public void addFileChangeCommitListener(javax.swing.event.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(javax.swing.event.ChangeListener l)
Remove a ChangeListener from this ImageSelectionPanel.

Parameters:
l - the listener to be removed.

addFileTextEditListener

public void addFileTextEditListener(javax.swing.event.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(javax.swing.event.ChangeListener l)
Remove a ChangeListener from this ImageSelectionPanel.

Parameters:
l - the listener to be removed.

getPreferredSize

public java.awt.Dimension getPreferredSize()
Override the default getPreferredSize() method. We don't want the ImageSelectionPanel to resize itsself when files with long names are selected and the 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 javax.swing.JComponent


Copyright 2006-2008 Xinapse Systems Limited. All Rights Reserved.