Package com.xinapse.image
Class ImageGrid
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.xinapse.image.ImageGrid
- All Implemented Interfaces:
PreferencesSettable,ImageObserver,MenuContainer,Serializable,Accessible
An
ImageGrid allows the selection of a 2-D 'matrix' of
ReadableImages and contains the mechanism for adding images to the matrix,
removing images from the matrix, etc.- 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
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
ConstructorsConstructorDescriptionImageGrid(MessageShower parent, Preferences prefs) Creates a new ImageGrid, that is contained within a parent MessageShower, and with initially one image in the set of images, and a minimum of one image in the set.ImageGrid(MessageShower parent, Preferences prefs, int initialNCols, int minNCols, int maxNCols, int defaultNCols, int initialNRows, int minNRows, int maxNRows, int defaultNRows, boolean rowsSelectable, boolean columnsSelectable) Creates a new ImageGrid, that is contained within a parent JFrame, and with minimum number and initial number of images in the set given by the argument. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCol()Adds another column of images.voidAdd an ActionListener that is to be notified when the number of columns in the ImageGrid changes.voidAdd an ActionListener that is to be notified when the number of rows in the ImageGrid changes.voidaddRow()Adds another row of images.voidClear all images from thisImageGrid.Class<? extends ReadableImage>Returns the class of image that will be filtered when the user first chooses a new image to set in the panel.intgetNCols()Returns the number of columns in the ImageGrid.intgetNRows()Returns the number of rows in the ImageGrid.getReadableImage(int col, int row) Returns the ReadableImage for the InputImageSelectionPanel at particular location in the ImageGrid.ReadableImage[][]Returns a 2-D array of images that is set in the grid.Returns the indices of the grid columns that have been selected by the user.Returns the index of the grid row that has been selected by the user.Returns the "current working directory" for this ImageGrid.static voidRuns the self-test on this Class.voidRemoves the last column of images.voidRemove an ActionListener to be notified when the number of columns in the ImageGrid changes.voidRemove an ActionListener to be notified when the number of rows in the ImageGrid changes.voidRemoves the last row of images.voidsavePreferences(Preferences prefs) Save the current settings to the user Preferences at the given node name.voidselectColumn(int col) Select a grid column.voidsetColumnLabel(String label) Sets the column label to "Number oflabels".voidsetColumnSelectionLabel(String label) Sets the labels for the JCheckBoxes that are used to select the grid columns.voidsetColumnSelectionToolTipText(String toolTipText) Sets the tool tip text for the JCheckBoxes that are used to select the grid columns.voidSet the default values.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.voidsetMaximumColumnsSelectable(int max) Set the maximum number of columns that is simultaneously selectable by the user.voidsetNCols(int nCols) Sets the number of columns in the ImageGrid.voidsetNRows(int nRows) Sets the number of rows in the ImageGrid.voidsetRowLabel(String label) Sets the row label to "Number oflabels".voidsetRowLabel(String label, int row) Sets the row label to "Number oflabels".voidsetRowSelectionLabel(String label) Sets the labels for the JRadioButtons that are used to select the grid row.voidsetRowSelectionToolTipText(String toolTipText) Sets the tool tip text for the JRadioButtons that are used to select the grid row.voidShow an error message (in case the current settings are invalid).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, getPreferredSize, 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, 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
-
Constructor Details
-
ImageGrid
Creates a new ImageGrid, that is contained within a parent MessageShower, and with initially one image in the set of images, and a minimum of one image in the set. However, if the ImageGrid setup is specified in the user preferences, this will be used to set the grid layout.- Parameters:
parent- the parent MessageShower that contains this ImageGrid. If parent is non-null, it will have its cursor set appropriately when the ImageGrid is busy.prefs- if non-null, the user preferences from which the layout of the ImageGrid will be set.
-
ImageGrid
public ImageGrid(MessageShower parent, Preferences prefs, int initialNCols, int minNCols, int maxNCols, int defaultNCols, int initialNRows, int minNRows, int maxNRows, int defaultNRows, boolean rowsSelectable, boolean columnsSelectable) throws IllegalArgumentException Creates a new ImageGrid, that is contained within a parent JFrame, and with minimum number and initial number of images in the set given by the argument.- Parameters:
parent- the parent MessageShower that contains this ImageGrid. If parent is non-null, it will have its cursor set appropriately when the ImageGrid is busy.prefs- the user Preferences from which the initial number of rows and columns of theImageGridwill be set.initialNCols- the initial number of columns of images.minNCols- the minimum number of columns of images.maxNCols- the maximum number of columns of images.defaultNCols- the default number of columns that will be set by the setDefaults() method.initialNRows- the initial number of rows of images.minNRows- the minimum number of rows of images.maxNRows- the maximum number of rows of images.defaultNRows- the default number of rows that will be set by the setDefaults() method.rowsSelectable- whether rows can be selected using JRadioButtons.columnsSelectable- whether columns can be selected using JCheckBoxes.- Throws:
IllegalArgumentException- if the default number of rows or columns is outside the man/max range specified.
-
-
Method Details
-
getNRows
public int getNRows()Returns the number of rows in the ImageGrid.- Returns:
- the number of rows in the ImageGrid.
-
getNCols
public int getNCols()Returns the number of columns in the ImageGrid.- Returns:
- the number of columns in the ImageGrid.
-
setColumnLabel
Sets the column label to "Number oflabels".- Parameters:
label- the label for a column.
-
setRowLabel
Sets the row label to "Number oflabels".- Parameters:
label- the label for a row.
-
setRowLabel
Sets the row label to "Number oflabels".- Parameters:
label- the label for a row.row- the row number.
-
setRowSelectionLabel
Sets the labels for the JRadioButtons that are used to select the grid row.- Parameters:
label- the label to display.
-
setColumnSelectionLabel
Sets the labels for the JCheckBoxes that are used to select the grid columns.- Parameters:
label- the label to display.
-
setRowSelectionToolTipText
Sets the tool tip text for the JRadioButtons that are used to select the grid row.- Parameters:
toolTipText- the tool top to display; if the toolTipText is null, the tool tip is turned off for these components.
-
setColumnSelectionToolTipText
Sets the tool tip text for the JCheckBoxes that are used to select the grid columns.- Parameters:
toolTipText- the tool top to display; if the toolTipText is null, the tool tip is turned off for these components.
-
setNCols
public void setNCols(int nCols) Sets the number of columns in the ImageGrid.- Parameters:
nCols- the new number of columns in the ImageGrid,
-
setNRows
public void setNRows(int nRows) Sets the number of rows in the ImageGrid.- Parameters:
nRows- the new number of rows in the ImageGrid,
-
addCol
public void addCol()Adds another column of images. -
removeCol
public void removeCol()Removes the last column of images. -
addRow
public void addRow()Adds another row of images. -
removeRow
public void removeRow()Removes the last row of images. -
getSelectedRow
Returns the index of the grid row that has been selected by the user. The user may be able to make a selection using the JRadioButton at the end of the row.- Returns:
- the index of the grid row that has been selected by the user. Returns
nullif the row is not selectable, or if the user has not made a selection.
-
getSelectedColumns
Returns the indices of the grid columns that have been selected by the user. The user may be able to make selections using the JCheckBoxes underneath the columns.- Returns:
- the indices of the grid columns that have been selected by the user.
Returns
nullif the columns are not selectable, or if the user has not made a selection.
-
setMaximumColumnsSelectable
public void setMaximumColumnsSelectable(int max) Set the maximum number of columns that is simultaneously selectable by the user.- Parameters:
max- the maximum number of columns that is simultaneously selectable by the user.
-
selectColumn
public void selectColumn(int col) Select a grid column.- Parameters:
col- the column to select.- Throws:
IndexOutOfBoundsException- if the column number is negative, or if this ImageGrid does not have enough columns to select the specified column.
-
addNColumnsChangeActionListener
Add an ActionListener that is to be notified when the number of columns in the ImageGrid changes.- Parameters:
l- the ActionListener to be added to the list of ActionListeners to be notified.
-
removeNColumnsChangeActionListener
Remove an ActionListener to be notified when the number of columns in the ImageGrid changes.- Parameters:
l- the ActionListener to be removed from the list of ActionListeners to be notified.
-
addNRowsChangeActionListener
Add an ActionListener that is to be notified when the number of rows in the ImageGrid changes.- Parameters:
l- the ActionListener to be added to the list of ActionListeners to be notified.
-
removeNRowsChangeActionListener
Remove an ActionListener to be notified when the number of rows in the ImageGrid changes.- Parameters:
l- the ActionListener to be removed from the list of ActionListeners to be notified.
-
getReadableImage
public ReadableImage getReadableImage(int col, int row) throws IndexOutOfBoundsException, UnsetImageException, InvalidImageException Returns the ReadableImage for the InputImageSelectionPanel at particular location in the ImageGrid.- Parameters:
col- the column number (indexed from zero).row- the row number (indexed from zero).- Returns:
- the com.xinapse.image.ReadableImage at the given position.
- Throws:
IndexOutOfBoundsException- if the row or column number are outside the bounds of the ImageGrid.UnsetImageException- if no image has been set in the panel at the given position.InvalidImageException- if the image set at the given position does not yield a valid image.
-
clearAllImages
public void clearAllImages()Clear all images from thisImageGrid. All file fields are set to the current working directory. -
setDefaults
public void setDefaults()Description copied from interface:PreferencesSettableSet the default values.- Specified by:
setDefaultsin interfacePreferencesSettable
-
savePreferences
Description copied from interface:PreferencesSettableSave the current settings to the user Preferences at the given node name.- Specified by:
savePreferencesin interfacePreferencesSettable- Parameters:
prefs- thePreferencesto which the current settings will be saved.
-
showError
Description copied from interface:PreferencesSettableShow an error message (in case the current settings are invalid).- Specified by:
showErrorin interfacePreferencesSettable- Parameters:
message- the message to show.
-
getWorkingDirectory
Returns the "current working directory" for this ImageGrid. 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 ImageGrid.
-
setImageFilterClass
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.
-
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.
-
getReadableImages
Returns a 2-D array of images that is set in the grid. The first index refers to the grid row, and the second index refers to the grid column.- Returns:
- a 2-D array of images that is set in the grid.
- Throws:
UnsetImageException- if any of the images in the grid has not yet been selected.InvalidImageException- if any of the images in the grid is not a valid ReadableImage.
-
main
Runs the self-test on this Class.- Parameters:
args- ignored.
-