Package com.xinapse.image
Class ImageSelectionPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.xinapse.image.ImageSelectionPanel
- All Implemented Interfaces:
MessageShower
,ImageObserver
,MenuContainer
,Serializable
,Accessible
- Direct Known Subclasses:
InputImageSelectionPanel
,OutputImageSelectionPanel
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Modifier and TypeFieldDescriptionprotected File
The current working directory.protected final JLabel
The JLabel to display along side the image file.protected final JPanel
A JPanel displayed to allow an image file to be selected.protected final JTextField
The JTextField to set the image file.protected final JLabel
The JLabel to display along side the image folder, or null if the image folder isn't shown separately.protected final JTextField
The JTextField to set the image folder, or null if the image folder isn't shown separately.protected ImageFileChooser
The ImageFileChooser that can be popped up to select a new image.protected Class<? extends ReadableImage>
The class of image that will intially be filtered when the user first selects the image.protected final com.xinapse.util.SVG.Button
The SVG.Button to set the image file.Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
ModifierConstructorDescriptionprotected
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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add aChangeListener
to thisImageSelectionPanel
.void
Add aChangeListener
to thisImageSelectionPanel
.void
Sets the cursor for this MessageShower to indicate that an operation is in progress.getFile()
Returns the image File set in this ImageSelectionPanel.Returns the name of the image set in this ImageSelectionPanel.Returns the parent of this MessageShower.Overrides the default getPreferredSize() method.Returns the "current working directory" for thisImageSelectionPanel
.void
Sets the cursor for this MessageShower to indicate that it is ready for user input.void
Remove aChangeListener
from thisImageSelectionPanel
.void
Remove aChangeListener
from thisImageSelectionPanel
.void
setEnabled
(boolean b) Enables or disables thisImageSelectionPanel
, depending on the value of the parameterb
.void
Sets the file in thisImageSelectionPanel
to the specified file.void
setFileLabel
(String label) Sets the label for the file selection text field.void
setFileText
(String text) Sets the text for the file selection text field.void
setFileToolTipText
(String text) Sets the tool tip text for the file selection text field.void
setFolderLabel
(String label) Sets the label for the folder selection text field.void
setFolderText
(String text) Sets the text for the folder selection text field.void
setFolderToolTipText
(String text) Sets the tool tip text for the folder selection text field.void
Sets the tool tip text for the button that pops up anImageFileChooser
to select the image.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.void
setToolTipText
(String text) Sets the tool tip text for the file selection text field.void
Sets the "current working directory" for thisImageSelectionPanel
.void
Displays an error message, typically in a pop-up dialog.void
Displays a multi-line error message, typically in a pop-up dialog.void
showStatus
(String message) Displays a status message.boolean
showSuppressibleError
(String message) Displays an error message, allowing the user to suppress future errors like this.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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
setImageButton
protected final com.xinapse.util.SVG.Button setImageButtonThe SVG.Button to set the image file. -
folderLabel
The JLabel to display along side the image folder, or null if the image folder isn't shown separately. -
folderTextField
The JTextField to set the image folder, or null if the image folder isn't shown separately. -
fileLabel
The JLabel to display along side the image file. -
fileTextField
The JTextField to set the image file. -
fileSelectionPanel
A JPanel displayed to allow an image file to be selected. -
imageChooser
The ImageFileChooser that can be popped up to select a new image. -
currentWorkingDirectory
The current working directory. -
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
- theMessageShower
for showing messages to the user.f
- used to set the default folder for the image. Iff
is a directory, then the default folder is set tof
. Iff
is a regular file, the default folder is set to the parent directory off
. Iff
is null, then the default folder is set to the System Propertyuser.dir
.imageClassToFilter
- theClass
of the image (e.g.com.xinapse.multisliceimage.UNC.UNCImage.class
) that will be the default image type to filter on.oneLine
- whether theImageSelectionPanel
is to appear on only one line.
-
-
Method Details
-
setFile
Sets the file in thisImageSelectionPanel
to the specified file.- Parameters:
f
- the file to set.
-
setWorkingDirectory
Sets the "current working directory" for thisImageSelectionPanel
. When the user chooses a new image to set in the panel, theImageFileChooser
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
Returns the "current working directory" for thisImageSelectionPanel
. When the user chooses a new image to set in the panel, theImageFileChooser
used to select the image starts with the directory set to the current working directory.- Returns:
- the "current working directory" for this
ImageSelectionPanel
.
-
setImageFilterClass
Sets the class of image that will be filtered when the user first chooses a new image to set in the panel. TheImageFileChooser
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 thisImageSelectionPanel
, depending on the value of the parameterb
. An enabledImageSelectionPanel
can respond to user input and generate events.- Overrides:
setEnabled
in classJComponent
- Parameters:
b
- iftrue
, thisImageSelectionPanel
is enabled; otherwise it is disabled.
-
getImageName
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
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
Description copied from interface:MessageShower
Displays a status message.- Specified by:
showStatus
in interfaceMessageShower
- Parameters:
message
- the status message to display.
-
showError
Description copied from interface:MessageShower
Displays an error message, typically in a pop-up dialog.- Specified by:
showError
in interfaceMessageShower
- Parameters:
message
- the error message to display.
-
showError
Description copied from interface:MessageShower
Displays a multi-line error message, typically in a pop-up dialog.- Specified by:
showError
in interfaceMessageShower
- Parameters:
messages
- the multi-line error message to display.
-
showSuppressibleError
Description copied from interface:MessageShower
Displays an error message, allowing the user to suppress future errors like this.- Specified by:
showSuppressibleError
in interfaceMessageShower
- 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 interfaceMessageShower
-
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 interfaceMessageShower
-
getParentWindow
Description copied from interface:MessageShower
Returns the parent of this MessageShower.- Specified by:
getParentWindow
in interfaceMessageShower
- Returns:
- the parent Window of this MessageShower.
-
setImageButtonToolTipText
Sets the tool tip text for the button that pops up anImageFileChooser
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
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
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
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 classJComponent
- Parameters:
text
- the tool tip text for the file selection text field.
-
setFileToolTipText
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
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
Sets the text for the file selection text field.- Parameters:
text
- the text for the file selection text field.
-
setFolderText
Sets the text for the folder selection text field.- Parameters:
text
- the text for the folder selection text field.
-
addFileChangeCommitListener
Add aChangeListener
to thisImageSelectionPanel
. All listeners are notified with aChangeEvent
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 theImageFileChooser
, or by the user editing the folder or file text (and pressing carriage return).- Parameters:
l
- the listener to be added.
-
removeFileChangeCommitListener
Remove aChangeListener
from thisImageSelectionPanel
.- Parameters:
l
- the listener to be removed.
-
addFileTextEditListener
Add aChangeListener
to thisImageSelectionPanel
. All listeners are notified with aChangeEvent
when the image file text is edited by the user.- Parameters:
l
- the listener to be added.
-
removeFileTextEditListener
Remove aChangeListener
from thisImageSelectionPanel
.- Parameters:
l
- the listener to be removed.
-
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 classJComponent
- Returns:
- the preferred size of the component.
-