Package com.xinapse.image
Class MultipleImageSelectionPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.xinapse.image.MultipleImageSelectionPanel
- All Implemented Interfaces:
com.xinapse.util.CanLoadImage
,ImageObserver
,MenuContainer
,Serializable
,Accessible
A
As images are added, the new images are sorted lexically and added to the list Usually used to select a set of input images for processing.
MultipleImageSelectionPanel
shows a list of images,
and contains the mechanism for selecting a new list of images, adding images to the list,
removing images from the list, and changing the order of images in the list.
As images are added, the new images are sorted lexically and added to the list Usually used to select a set of input images for processing.
For an example of the use of a MultipleImageSelectionPanel
, see the
Perfusion/Permeability Tool in Jim.
- 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 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
ConstructorDescriptionCreates a newMultipleImageSelectionPanel
with an empty list of images.MultipleImageSelectionPanel
(Window parent) Creates a newMultipleImageSelectionPanel
, that is contained within a parent Window, and with an empty list of images. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add aChangeListener
to thisMultipleImageSelectionPanel
.void
void
Set busy cursors.void
Removes all files from the list.void
Do things that need to be done on the event dispatch thread after the image has been loaded.Returns the class of image that will be filtered when the user chooses a new image to set in the panel.int
Returns the number of images currently set in this MultipleImageSelectionPanel.Get the Window which implements thisCanLoadImage
.Override the default getPreferredSize() method.getReadableImage
(int index) Returns the ReadableImage for the MultipleImageSelectionPanel at particular location in the list of images.Returns an array of ReadableImages with each array member being an image currently set in the MultipleImageSelectionPanel.getTitle()
Returns the title for the list of images.Returns the "current working directory" for thisMultipleImageSelectionPanel
.boolean
Tests whether thisCanLoadImage
is currently loading an image.boolean
loadImage
(ReadableImage image, com.xinapse.util.ImageLoaderWorker worker) Load an image into thisCanLoadImage
.void
Set ready cursors.void
Remove aChangeListener
from thisMultipleImageSelectionPanel
.void
setImageFilterClass
(Class<? extends WritableImage> c) Sets the class of image that will be filtered when the user chooses a new image to set in the panel.void
setParentWindow
(Window parent) Sets the parent Window for thisMultipleImageSelectionPanel
.void
Sets the title for the list of images.void
Show an error message.void
Show a multi-line error message.void
showStatus
(String msg) Show a status message.boolean
Unload any current image from this CanLoadImage.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, 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, setEnabled, 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, 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
-
Constructor Details
-
MultipleImageSelectionPanel
public MultipleImageSelectionPanel()Creates a newMultipleImageSelectionPanel
with an empty list of images. -
MultipleImageSelectionPanel
Creates a newMultipleImageSelectionPanel
, that is contained within a parent Window, and with an empty list of images.- Parameters:
parent
- the parent Window that contains thisMultipleImageSelectionPanel
. If parent is non-null, it will have its cursor set appropriately when theMultipleImageSelectionPanel
is busy.
-
-
Method Details
-
setParentWindow
Sets the parent Window for thisMultipleImageSelectionPanel
.- Parameters:
parent
- the parentMessageShower
that contains thisMultipleImageSelectionPanel
. If parent is non-null, it will have its cursor set appropriately when theMultipleImageSelectionPanel
is busy.
-
getNImages
public int getNImages()Returns the number of images currently set in this MultipleImageSelectionPanel.- Returns:
- the number of images currently set in this MultipleImageSelectionPanel.
-
getReadableImage
public ReadableImage getReadableImage(int index) throws IndexOutOfBoundsException, IOException, InvalidImageException Returns the ReadableImage for the MultipleImageSelectionPanel at particular location in the list of images.- Parameters:
index
- the position in the list (indexed from zero).- Returns:
- the ReadableImage set for the MultipleImageSelectionPanel at the given position.
- Throws:
IndexOutOfBoundsException
- if the index is less than zero or greater than or equal to the number of images in the list.IOException
- if an I/O error occurs while reading the image.InvalidImageException
- if the image at the given index is invalid.
-
getReadableImages
Returns an array of ReadableImages with each array member being an image currently set in the MultipleImageSelectionPanel.- Returns:
- an array of ReadableImages, one array element for each file set in the
MultipleImageSelectionPanel. Returns
null
if there are are no images currently set. - Throws:
InvalidImageException
- if any of the images is invalid.IOException
- if an I/O error occurs while reading the images.
-
getWorkingDirectory
Returns the "current working directory" for thisMultipleImageSelectionPanel
. 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. When the user, using the ImageFileChooser, moves to a different directory, the current working directory is set to the new directory.- Returns:
- the current working directory for this
MultipleImageSelectionPanel
.
-
setImageFilterClass
Sets the class of image that will be filtered when the user 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
Returns the class of image that will be filtered when the user 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 chooses a new image to set in the panel.
-
addChangeListener
Add aChangeListener
to thisMultipleImageSelectionPanel
. All listeners are notified with aChangeEvent
when the image file is changed 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 (after pressing carriage return).- Parameters:
l
- the listener to be added.
-
removeChangeListener
Remove aChangeListener
from thisMultipleImageSelectionPanel
.- Parameters:
l
- the listener to be removed.
-
getTitle
Returns the title for the list of images. The title appears just above the list.- Returns:
- the current title for the list, or
null
if there is no title.
-
setTitle
Sets the title for the list of images. The title appears just above the list.- Parameters:
title
- the new title for the list. Iftitle
isnull
, then no title is shown.
-
clearFiles
public void clearFiles()Removes all files from the list. -
getPreferredSize
Override the default getPreferredSize() method. We don't want theMultipleImageSelectionPanel
to resize itsself when files with long names are selected and the Component 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
-
getMinimumSize
- Overrides:
getMinimumSize
in classJComponent
-
addFiles
-
getParentWindow
Description copied from interface:com.xinapse.util.CanLoadImage
Get the Window which implements thisCanLoadImage
.- Specified by:
getParentWindow
in interfacecom.xinapse.util.CanLoadImage
- Returns:
- the
Window
which implements theCanLoadImage
.
-
busyCursors
public void busyCursors()Description copied from interface:com.xinapse.util.CanLoadImage
Set busy cursors.- Specified by:
busyCursors
in interfacecom.xinapse.util.CanLoadImage
-
readyCursors
public void readyCursors()Description copied from interface:com.xinapse.util.CanLoadImage
Set ready cursors.- Specified by:
readyCursors
in interfacecom.xinapse.util.CanLoadImage
-
showStatus
Description copied from interface:com.xinapse.util.CanLoadImage
Show a status message.- Specified by:
showStatus
in interfacecom.xinapse.util.CanLoadImage
- Parameters:
msg
- the message to show.
-
showError
Description copied from interface:com.xinapse.util.CanLoadImage
Show an error message.- Specified by:
showError
in interfacecom.xinapse.util.CanLoadImage
- Parameters:
errorMsg
- the error message to show.
-
showError
Description copied from interface:com.xinapse.util.CanLoadImage
Show a multi-line error message.- Specified by:
showError
in interfacecom.xinapse.util.CanLoadImage
- Parameters:
errorMsg
- the array of error messages to show - one per line.
-
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.worker
- the ImageLoaderWorker that loads the image.- Returns:
- true if the image was loaded successfully; false otherwise.
-
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.
-
unloadImage
public boolean unloadImage()Description copied from interface:com.xinapse.util.CanLoadImage
Unload any current image from this CanLoadImage.- Specified by:
unloadImage
in interfacecom.xinapse.util.CanLoadImage
- Returns:
true
if the image unloads successfully;false
if the image does not unload successfully.
-
doPostLoad
public void doPostLoad()Description copied from interface:com.xinapse.util.CanLoadImage
Do things that need to be done on the event dispatch thread after the image has been loaded.- Specified by:
doPostLoad
in interfacecom.xinapse.util.CanLoadImage
-