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.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FileThe current working directory.protected final JLabelThe JLabel to display along side the image file.protected final JPanelA JPanel displayed to allow an image file to be selected.protected final JTextFieldThe JTextField to set the image file.protected final JLabelThe JLabel to display along side the image folder, or null if the image folder isn't shown separately.protected final JTextFieldThe JTextField to set the image folder, or null if the image folder isn't shown separately.protected ImageFileChooserThe 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.ButtonThe 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_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedImageSelectionPanel(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 TypeMethodDescriptionvoidAdd aChangeListenerto thisImageSelectionPanel.voidAdd aChangeListenerto thisImageSelectionPanel.voidSets 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.voidSets the cursor for this MessageShower to indicate that it is ready for user input.voidRemove aChangeListenerfrom thisImageSelectionPanel.voidRemove aChangeListenerfrom thisImageSelectionPanel.voidsetEnabled(boolean b) Enables or disables thisImageSelectionPanel, depending on the value of the parameterb.voidSets the file in thisImageSelectionPanelto the specified file.voidsetFileLabel(String label) Sets the label for the file selection text field.voidsetFileText(String text) Sets the text for the file selection text field.voidsetFileToolTipText(String text) Sets the tool tip text for the file selection text field.voidsetFolderLabel(String label) Sets the label for the folder selection text field.voidsetFolderText(String text) Sets the text for the folder selection text field.voidsetFolderToolTipText(String text) Sets the tool tip text for the folder selection text field.voidSets the tool tip text for the button that pops up anImageFileChooserto select the image.voidsetImageFilterClass(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.voidsetToolTipText(String text) Sets the tool tip text for the file selection text field.voidSets the "current working directory" for thisImageSelectionPanel.voidDisplays an error message, typically in a pop-up dialog.voidDisplays a multi-line error message, typically in a pop-up dialog.voidshowStatus(String message) Displays a status message.booleanshowSuppressibleError(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, updateUIMethods 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, updateMethods 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, validateTreeMethods 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- theMessageShowerfor showing messages to the user.f- used to set the default folder for the image. Iffis a directory, then the default folder is set tof. Iffis a regular file, the default folder is set to the parent directory off. Iffis null, then the default folder is set to the System Propertyuser.dir.imageClassToFilter- theClassof the image (e.g.com.xinapse.multisliceimage.UNC.UNCImage.class) that will be the default image type to filter on.oneLine- whether theImageSelectionPanelis to appear on only one line.
-
-
Method Details
-
setFile
Sets the file in thisImageSelectionPanelto 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, theImageFileChooserused 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, theImageFileChooserused 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. TheImageFileChooserused 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 enabledImageSelectionPanelcan respond to user input and generate events.- Overrides:
setEnabledin classJComponent- Parameters:
b- iftrue, thisImageSelectionPanelis 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:MessageShowerDisplays a status message.- Specified by:
showStatusin interfaceMessageShower- Parameters:
message- the status message to display.
-
showError
Description copied from interface:MessageShowerDisplays an error message, typically in a pop-up dialog.- Specified by:
showErrorin interfaceMessageShower- Parameters:
message- the error message to display.
-
showError
Description copied from interface:MessageShowerDisplays a multi-line error message, typically in a pop-up dialog.- Specified by:
showErrorin interfaceMessageShower- Parameters:
messages- the multi-line error message to display.
-
showSuppressibleError
Description copied from interface:MessageShowerDisplays an error message, allowing the user to suppress future errors like this.- Specified by:
showSuppressibleErrorin 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:MessageShowerSets the cursor for this MessageShower to indicate that an operation is in progress.- Specified by:
busyCursorsin interfaceMessageShower
-
readyCursors
public void readyCursors()Description copied from interface:MessageShowerSets the cursor for this MessageShower to indicate that it is ready for user input.- Specified by:
readyCursorsin interfaceMessageShower
-
getParentWindow
Description copied from interface:MessageShowerReturns the parent of this MessageShower.- Specified by:
getParentWindowin interfaceMessageShower- Returns:
- the parent Window of this MessageShower.
-
setImageButtonToolTipText
Sets the tool tip text for the button that pops up anImageFileChooserto 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:
setToolTipTextin 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 aChangeListenerto thisImageSelectionPanel. All listeners are notified with aChangeEventwhen 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 aChangeListenerfrom thisImageSelectionPanel.- Parameters:
l- the listener to be removed.
-
addFileTextEditListener
Add aChangeListenerto thisImageSelectionPanel. All listeners are notified with aChangeEventwhen the image file text is edited by the user.- Parameters:
l- the listener to be added.
-
removeFileTextEditListener
Remove aChangeListenerfrom 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:
getPreferredSizein classJComponent- Returns:
- the preferred size of the component.
-