Package com.xinapse.image
Class InputImageSelectionPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.xinapse.image.ImageSelectionPanel
com.xinapse.image.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:
-
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
Fields inherited from class com.xinapse.image.ImageSelectionPanel
currentWorkingDirectory, fileLabel, fileSelectionPanel, fileTextField, folderLabel, folderTextField, imageChooser, imageClassToFilter, setImageButton
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
ConstructorDescriptionInputImageSelectionPanel
(MessageShower messageShower) Creates new InputImageSelectionPanel, with the default Folder set to the System Propertyuser.dir
.InputImageSelectionPanel
(MessageShower messageShower, boolean oneLine) Creates new InputImageSelectionPanel, with the default Folder set to the System Propertyuser.dir
, and with the image file selection field on only one line.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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Does nothing.Returns the name of the image set in this ImageSelectionPanel.Override the default getPreferredSize() method.Returns theReadableImage
that has been set in thisInputImageSelectionPanel
.boolean
Tests whether thisCanLoadImage
is currently loading an image.boolean
loadImage
(ReadableImage image, com.xinapse.util.ImageLoaderWorker imageLoaderWorker) Load an image into thisCanLoadImage
.void
setEditable
(boolean editable) Sets whether text for folder/file selection is editable.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
setFileText
(String text) Sets the text for the file selection text field.boolean
Unloads the image set in this InputImageSelectionPanel.Methods inherited from class com.xinapse.image.ImageSelectionPanel
addFileChangeCommitListener, addFileTextEditListener, busyCursors, getFile, getParentWindow, getWorkingDirectory, readyCursors, removeFileChangeCommitListener, removeFileTextEditListener, setFileLabel, setFileToolTipText, setFolderLabel, setFolderText, setFolderToolTipText, setImageButtonToolTipText, setImageFilterClass, setToolTipText, setWorkingDirectory, showError, showError, showStatus, showSuppressibleError
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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.xinapse.util.CanLoadImage
busyCursors, getParentWindow, readyCursors, showError, showError, showStatus
-
Constructor Details
-
InputImageSelectionPanel
Creates new InputImageSelectionPanel, with the default Folder set to the System Propertyuser.dir
.- Parameters:
messageShower
- the MessageShower that will show error and status messages, etc.
-
InputImageSelectionPanel
Creates new InputImageSelectionPanel, with the default Folder set to the System Propertyuser.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. 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
- if theInputImageSelectionPanel
is to appear on only one line.
-
-
Method Details
-
getPreferredSize
Override the default getPreferredSize() method.- Overrides:
getPreferredSize
in classImageSelectionPanel
- Returns:
- the preferred size of the component.
-
setFile
Description copied from class:ImageSelectionPanel
Sets the file in thisImageSelectionPanel
to the specified file.- Overrides:
setFile
in classImageSelectionPanel
- Parameters:
f
- the file to set.
-
setFileText
Description copied from class:ImageSelectionPanel
Sets the text for the file selection text field.- Overrides:
setFileText
in classImageSelectionPanel
- Parameters:
text
- the text for the file selection text field.
-
getReadableImage
Returns theReadableImage
that has been set in thisInputImageSelectionPanel
. If no image has been set, then aUnsetFileException
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 thisInputImageSelectionPanel
. - Throws:
UnsetImageException
- if no ReadableImage has been set.InvalidImageException
- if the image set does not yield a valid ReadableImage.
-
getImageName
Description copied from class:ImageSelectionPanel
Returns the name of the image set in this ImageSelectionPanel.- Overrides:
getImageName
in classImageSelectionPanel
- 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
- iftrue
then the text fields will be editable; not editable otherwise.
-
loadImage
Description copied from interface:com.xinapse.util.CanLoadImage
Load an image into thisCanLoadImage
.- Specified by:
loadImage
in interfacecom.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 interfacecom.xinapse.util.CanLoadImage
-
unloadImage
public boolean unloadImage()Unloads the image set in this InputImageSelectionPanel.- Specified by:
unloadImage
in interfacecom.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 thisCanLoadImage
is currently loading an image.- Specified by:
isLoadInProgress
in interfacecom.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 thisImageSelectionPanel
, depending on the value of the parameterb
. An enabledImageSelectionPanel
can respond to user input and generate events.- Overrides:
setEnabled
in classImageSelectionPanel
- Parameters:
b
- iftrue
, thisImageSelectionPanel
is enabled; otherwise it is disabled.
-