|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JList com.isti.util.gui.SortedValuesJList
public class SortedValuesJList
Class SortedValuesJList extends JList to implement a sorted-table model and to enforce the paradigm that list changes should only happen via the event-dispatch thread. Elements in the list are sorted according to the natural ordering of the value objects (not the keys) in the table model.
Nested Class Summary | |
---|---|
static interface |
SortedValuesJList.ListSelKeyChangeCallBack
Interface ListSelKeyChangeCallBack defines a call-back method that is invoked when the selected list item has changed (and its key has changed). |
Nested classes/interfaces inherited from class javax.swing.JList |
---|
javax.swing.JList.AccessibleJList, javax.swing.JList.DropLocation |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected SortedValuesJList.ListSelKeyChangeCallBack |
listSelKeyChangeCallBackObj
Call-back object used when list selection changes. |
protected java.lang.Object |
selectedKeyObject
Key object for currently selected item. |
protected java.lang.Object |
selectedKeySyncObj
Thread-synchronization object for 'selectedKeyObject'. |
protected static boolean |
SORT_DIR_FLAG
Direction-of-sort flag for 'FifoHashListModel' used by list (true). |
protected FifoHashListModel |
sortedListModelObj
FifoHashtable-based model for list. |
Fields inherited from class javax.swing.JList |
---|
HORIZONTAL_WRAP, VERTICAL, VERTICAL_WRAP |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, 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 |
---|
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 | |
---|---|
SortedValuesJList()
Creates a sorted JList with a sorted-table model. |
|
SortedValuesJList(javax.swing.ListCellRenderer cellRendererObj)
Creates a sorted JList with a sorted-table model. |
|
SortedValuesJList(javax.swing.ListCellRenderer cellRendererObj,
java.util.Map tableMapObj)
Creates a sorted JList with a sorted-values-table model. |
|
SortedValuesJList(javax.swing.ListCellRenderer cellRendererObj,
java.util.Map tableMapObj,
boolean sortDirFlag)
Creates a sorted JList with a sorted-values-table model. |
|
SortedValuesJList(javax.swing.ListCellRenderer cellRendererObj,
java.util.Map tableMapObj,
boolean sortDirFlag,
int sortType)
Creates a sorted JList with a sorted-values-table model. |
|
SortedValuesJList(java.util.Map tableMapObj)
Creates a sorted JList with a sorted-values-table model. |
Method Summary | |
---|---|
void |
clearSelection()
Clears the selection. |
protected void |
doSelectLastItemInList(boolean ensureVisibleFlag)
Sets the selected index for the list. |
protected void |
doSetColors(java.awt.Color foregroundColor,
java.awt.Color backgroundColor,
java.awt.Color selForegroundColor,
java.awt.Color selBackgroundColor)
Sets the list colors. |
protected void |
doSetSelectedIndex(int val,
boolean ensureVisibleFlag)
Sets the selected index for the list. |
void |
ensureSelectionVisible()
Ensures that the current list selection is visible. |
void |
fireContentsChanged()
Fires a contents-changed event to the list model. |
java.lang.Object |
getCellAt(int indexVal)
Returns the object associated with the given index on the list. |
java.lang.Object |
getSelectedKeyObj()
Returns the key for the currently selected item. |
java.lang.String |
getSelectedKeyString()
Returns the key string for the currently selected item. |
boolean |
getSortFlag()
Gets the direction-of-sort flag for 'FifoHashListModel' used by list. |
int |
getSortType()
Gets the sort type for 'FifoHashListModel' used by list. |
boolean |
isSelectionVisible()
Determines whether or not the current list selection is visible. |
java.lang.Object |
locationToValue(java.awt.Point pointObj)
Returns the object associated with the cell closest to the given location. |
protected void |
processListSelectionChange()
Processes a change in the selected list item. |
void |
put(java.lang.Object key,
java.lang.Object value)
Adds a key/value pair to the list, placing it in sorted order according to the value. |
void |
put(java.lang.Object key,
java.lang.Object value,
boolean sortFlag)
Adds a key/value pair to the list, optionally placing it in sorted order according to the value. |
void |
putAll(java.util.Map mapObj)
Copies all of the mappings from the specified map into the list, placing them in sorted order according to the values. |
void |
putAll(java.util.Map mapObj,
boolean sortFlag)
Copies all of the mappings from the specified map into the list, placing them in sorted order according to the values. |
void |
removeKey(java.lang.Object key)
Removes the mapping for the given key from the list (if present). |
void |
repaint()
Called after updates to the list have occurred to repaint the list. |
void |
requestFocus()
Requests that this list have the keyboard focus. |
void |
reSortList(boolean sortDirFlag,
int sortType)
Resorts the list with the specified direction and type. |
protected void |
resyncSelectedItem()
Resynchronizes the selected list item by reselecting the selected-key tracker object. |
void |
selectLastItemInList(boolean ensureVisibleFlag)
Sets the selected index for the list. |
void |
selectLastItemInList(boolean ensureVisibleFlag,
boolean alwaysQueueFlag)
Sets the selected index for the list. |
void |
setColors(java.awt.Color foregroundColor,
java.awt.Color backgroundColor,
java.awt.Color selForegroundColor,
java.awt.Color selBackgroundColor)
Sets the list colors. |
void |
setColors(java.awt.Color foregroundColor,
java.awt.Color backgroundColor,
java.awt.Color selForegroundColor,
java.awt.Color selBackgroundColor,
boolean directFlag)
Sets the list colors. |
void |
setListData(java.util.Map tableMapObj)
Clears any current list data and enters the items from the given Map object. |
void |
setListenersEnabled(boolean flgVal)
Sets whether or not 'ListDataListener' objects attached to the list model are called when changes occur. |
void |
setListSelKeyChangeCallBack(SortedValuesJList.ListSelKeyChangeCallBack cbObj)
Sets the ListSelKeyChangeCallBack object whose call-back method is invoked when the selected list item has changed (and its key has changed). |
void |
setSelectedIndex(int val)
Sets the selected index for the list. |
void |
setSelectedIndex(int val,
boolean ensureVisibleFlag)
Sets the selected index for the list. |
void |
setSelectedKey(java.lang.Object keyObj)
Selects the item corresponding to the given key. |
void |
setSelectedKey(java.lang.Object keyObj,
boolean ensureVisibleFlag)
Selects the item corresponding to the given key. |
Methods inherited from class javax.swing.JList |
---|
addListSelectionListener, addSelectionInterval, createSelectionModel, ensureIndexIsVisible, fireSelectionValueChanged, getAccessibleContext, getAnchorSelectionIndex, getCellBounds, getCellRenderer, getDragEnabled, getDropLocation, getDropMode, getFirstVisibleIndex, getFixedCellHeight, getFixedCellWidth, getLastVisibleIndex, getLayoutOrientation, getLeadSelectionIndex, getListSelectionListeners, getMaxSelectionIndex, getMinSelectionIndex, getModel, getNextMatch, getPreferredScrollableViewportSize, getPrototypeCellValue, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedIndex, getSelectedIndices, getSelectedValue, getSelectedValues, getSelectionBackground, getSelectionForeground, getSelectionMode, getSelectionModel, getToolTipText, getUI, getUIClassID, getValueIsAdjusting, getVisibleRowCount, indexToLocation, isSelectedIndex, isSelectionEmpty, locationToIndex, paramString, removeListSelectionListener, removeSelectionInterval, setCellRenderer, setDragEnabled, setDropMode, setFixedCellHeight, setFixedCellWidth, setLayoutOrientation, setListData, setListData, setModel, setPrototypeCellValue, setSelectedIndices, setSelectedValue, setSelectionBackground, setSelectionForeground, setSelectionInterval, setSelectionMode, setSelectionModel, setUI, setValueIsAdjusting, setVisibleRowCount, 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, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, 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, transferFocusBackward, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final FifoHashListModel sortedListModelObj
protected static final boolean SORT_DIR_FLAG
protected java.lang.Object selectedKeyObject
protected final java.lang.Object selectedKeySyncObj
protected SortedValuesJList.ListSelKeyChangeCallBack listSelKeyChangeCallBackObj
Constructor Detail |
---|
public SortedValuesJList(javax.swing.ListCellRenderer cellRendererObj, java.util.Map tableMapObj, boolean sortDirFlag, int sortType)
cellRendererObj
- list-cell renderer to use, or null to
use the default list-cell renderer.tableMapObj
- the map object to use, or null for none.sortDirFlag
- true for ascending sort order, false for
descending.sortType
- the sort type.
java.lang.ClassCastException
- if the values in the map are not
Comparable, or are not mutually comparable.public SortedValuesJList(javax.swing.ListCellRenderer cellRendererObj, java.util.Map tableMapObj, boolean sortDirFlag)
cellRendererObj
- list-cell renderer to use, or null to
use the default list-cell renderer.tableMapObj
- the map object to use, or null for none.sortDirFlag
- true for ascending sort order, false for
descending.
java.lang.ClassCastException
- if the values in the map are not
Comparable, or are not mutually comparable.public SortedValuesJList(javax.swing.ListCellRenderer cellRendererObj, java.util.Map tableMapObj)
cellRendererObj
- list-cell renderer to use, or null to
use the default list-cell renderer.tableMapObj
- the map object to use, or null for none.
java.lang.ClassCastException
- if the values in the map are not
Comparable, or are not mutually comparable.public SortedValuesJList(javax.swing.ListCellRenderer cellRendererObj)
cellRendererObj
- list-cell renderer to use, or null to
use the default list-cell renderer.public SortedValuesJList(java.util.Map tableMapObj)
tableMapObj
- the map object to use, or null for none.
java.lang.ClassCastException
- if the values in the map are not
Comparable, or are not mutually comparable.public SortedValuesJList()
Method Detail |
---|
public boolean getSortFlag()
public int getSortType()
public void reSortList(boolean sortDirFlag, int sortType)
sortDirFlag
- true for ascending sort order, false for
descending.sortType
- the sort type.public void put(java.lang.Object key, java.lang.Object value)
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.public void put(java.lang.Object key, java.lang.Object value, boolean sortFlag)
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.sortFlag
- true to sort the values, false otherwise.public void putAll(java.util.Map mapObj)
mapObj
- mappings to be stored in this map.public void putAll(java.util.Map mapObj, boolean sortFlag)
mapObj
- mappings to be stored in this map.sortFlag
- true to sort the values, false otherwise.public void removeKey(java.lang.Object key)
key
- key whose mapping is to be removed from the hashtable.public void setListData(java.util.Map tableMapObj)
tableMapObj
- a Map object containing the items to display in
the list, or null for no items.public void repaint()
repaint
in class java.awt.Component
public void requestFocus()
requestFocus
in class javax.swing.JComponent
public void setSelectedKey(java.lang.Object keyObj, boolean ensureVisibleFlag)
keyObj
- the key object to use.ensureVisibleFlag
- if true then the selected item will be made
visible.public void setSelectedKey(java.lang.Object keyObj)
keyObj
- the key object to use.public void setSelectedIndex(int val, boolean ensureVisibleFlag)
val
- the index value.ensureVisibleFlag
- if true then the selected item will be made
visible.public void setSelectedIndex(int val)
setSelectedIndex
in class javax.swing.JList
val
- the index value.protected void doSetSelectedIndex(int val, boolean ensureVisibleFlag)
val
- the index value.ensureVisibleFlag
- if true then the selected item will be made
visible.public void selectLastItemInList(boolean ensureVisibleFlag, boolean alwaysQueueFlag)
ensureVisibleFlag
- if true then the selected item will be made
visible.alwaysQueueFlag
- if true then the action will be put on the
queue of events to be performed later by the event-dispatch thread;
if false then this will only happen if the calling thread is not
the event-dispatch thread.public void selectLastItemInList(boolean ensureVisibleFlag)
ensureVisibleFlag
- if true then the selected item will be made
visible.protected void doSelectLastItemInList(boolean ensureVisibleFlag)
ensureVisibleFlag
- if true then the selected item will be made
visible.public void ensureSelectionVisible()
public void clearSelection()
clearSelection
in class javax.swing.JList
public java.lang.Object getCellAt(int indexVal)
indexVal
- the index value to use.
public java.lang.Object locationToValue(java.awt.Point pointObj)
pointObj
- the coordinates to use, relative to the list object.
public java.lang.Object getSelectedKeyObj()
public java.lang.String getSelectedKeyString()
public boolean isSelectionVisible()
public void setListenersEnabled(boolean flgVal)
flgVal
- true to enable calling of 'ListDataListener' objects,
false to disable.public void fireContentsChanged()
public void setColors(java.awt.Color foregroundColor, java.awt.Color backgroundColor, java.awt.Color selForegroundColor, java.awt.Color selBackgroundColor, boolean directFlag)
foregroundColor
- the foreground color to set, or null to leave
the color unchanged.backgroundColor
- the background color to set, or null to leave
the color unchanged.selForegroundColor
- the selection foreground color to set, or
null to leave the color unchanged.selBackgroundColor
- the selection background color to set, or
null to leave the color unchanged.directFlag
- if true then the color setting is always done
immediately; if false and the thread calling this method is not
the event-dispatch thread then the action is queued and invoked
later by the event-dispatch thread.public void setColors(java.awt.Color foregroundColor, java.awt.Color backgroundColor, java.awt.Color selForegroundColor, java.awt.Color selBackgroundColor)
foregroundColor
- the foreground color to set, or null to leave
the color unchanged.backgroundColor
- the background color to set, or null to leave
the color unchanged.selForegroundColor
- the selection foreground color to set, or
null to leave the color unchanged.selBackgroundColor
- the selection background color to set, or
null to leave the color unchanged.protected void doSetColors(java.awt.Color foregroundColor, java.awt.Color backgroundColor, java.awt.Color selForegroundColor, java.awt.Color selBackgroundColor)
foregroundColor
- the foreground color to set, or null to leave
the color unchanged.backgroundColor
- the background color to set, or null to leave
the color unchanged.selForegroundColor
- the selection foreground color to set, or
null to leave the color unchanged.selBackgroundColor
- the selection background color to set, or
null to leave the color unchanged.protected void resyncSelectedItem()
protected void processListSelectionChange()
public void setListSelKeyChangeCallBack(SortedValuesJList.ListSelKeyChangeCallBack cbObj)
cbObj
- the 'ListSelKeyChangeCallBack' object to be used,
or null to clear the call-back object.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |