org.cb.jset.client.ui
Class JSetBoardComponent

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.cb.jset.client.ui.JSetBoardComponent
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class JSetBoardComponent
extends javax.swing.JPanel

The component representing the set board in the graphical client. FIXME think about using Accessible

Version:
$Id: JSetBoardComponent.java 130 2004-04-15 05:18:07Z jerome $
Author:
jerome@coffeebreaks.org - last modified by $LastChangedBy: jerome $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
JSetBoardComponent(Card[] listData)
          Constructs a JCardBoardComponent that displays the elements in the specified array.
JSetBoardComponent(CardBoardModel dataModel)
          Constructs a Board component using the specified dataModel.
 
Method Summary
 void addBoardSelectionListener(BoardSelectionListener listener)
          Adds a listener to the cardBoard that's notified each time a change to the selection occurs.
 void addSelectionInterval(int anchor, int lead)
          Sets the selection to be the union of the specified interval with current selection.
 void clearSelection()
          Clears the selection - after calling this method isSelectionEmpty will return true.
protected  void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
          Notifies JCardBoardComponent BoardSelectionListeners that the selection model has changed.
 int getAnchorSelectionIndex()
          Returns the first index argument from the most recent addSelectionModel or setSelectionInterval call.
 BoardSelectionListener[] getBoardSelectionListeners()
          Returns an array of all the BoardSelectionListeners added to this JCardBoardComponent with addBoardSelectionListener().
 int getLeadSelectionIndex()
          Returns the second index argument from the most recent addSelectionInterval or setSelectionInterval call.
 int getMaxSelectionIndex()
          Returns the largest selected cell index.
 int getMinSelectionIndex()
          Returns the smallest selected cell index.
 CardBoardModel getModel()
           
 int[] getSelectedIndices()
          Returns an array of all of the selected indices in increasing order.
 java.lang.Object[] getSelectedValues()
          Returns an array of the values for the selected cells.
 int getSelectionMode()
          Returns whether single-item or multiple-item selections are allowed.
 BoardSelectionModel getSelectionModel()
           
 boolean isSelectedIndex(int index)
          Returns true if the specified index is selected.
 boolean isSelectionEmpty()
          Returns true if nothing is selected.
 void removeBoardSelectionListener(BoardSelectionListener listener)
          Removes a listener from the list that's notified each time a change to the selection occurs.
 void removeSelectionInterval(int index0, int index1)
          Sets the selection to be the set difference of the specified interval and the current selection.
 void setModel(CardBoardModel model)
          Sets a new model for that board.
 void setSelectedIndex(int index)
          Selects a single cell.
 void setSelectedIndices(int[] indices)
          Selects a set of cells.
 void setSelectionInterval(int anchor, int lead)
          Selects the specified interval.
 void setSelectionMode(int selectionMode)
          Determines whether single-item or multiple-item selections are allowed.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, 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
 

Constructor Detail

JSetBoardComponent

public JSetBoardComponent(CardBoardModel dataModel)
Constructs a Board component using the specified dataModel.

Parameters:
dataModel - the model for that component

JSetBoardComponent

public JSetBoardComponent(Card[] listData)
Constructs a JCardBoardComponent that displays the elements in the specified array. This constructor just delegates to the ListModel constructor.

Parameters:
listData - the array of Objects to be loaded into the data model
Method Detail

getModel

public CardBoardModel getModel()
Returns:
the model for that board.

getSelectionModel

public BoardSelectionModel getSelectionModel()
Returns:
the selection model for that board.

setModel

public void setModel(CardBoardModel model)
Sets a new model for that board. A property change event with name "model" will be fired.

Parameters:
model - the new model

setSelectionMode

public void setSelectionMode(int selectionMode)
Determines whether single-item or multiple-item selections are allowed. The following selectionMode values are allowed:

Parameters:
selectionMode - an integer specifying the type of selections that are permissible
See Also:
getSelectionMode()

getSelectionMode

public int getSelectionMode()
Returns whether single-item or multiple-item selections are allowed.

Returns:
the value of the selectionMode property
See Also:
setSelectionMode(int)

getAnchorSelectionIndex

public int getAnchorSelectionIndex()
Returns the first index argument from the most recent addSelectionModel or setSelectionInterval call. This is a convenience method that just delegates to the selectionModel.

Returns:
the index that most recently anchored an interval selection
See Also:
BoardSelectionModel.getAnchorSelectionIndex(), addSelectionInterval(int, int), setSelectionInterval(int, int), addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

getLeadSelectionIndex

public int getLeadSelectionIndex()
Returns the second index argument from the most recent addSelectionInterval or setSelectionInterval call. This is a convenience method that just delegates to the selectionModel.

Returns:
the index that most recently ended a interval selection
See Also:
BoardSelectionModel.getLeadSelectionIndex(), addSelectionInterval(int, int), setSelectionInterval(int, int), addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

getMinSelectionIndex

public int getMinSelectionIndex()
Returns the smallest selected cell index. This is a convenience method that just delegates to the selectionModel.

Returns:
the smallest selected cell index
See Also:
BoardSelectionModel.getMinSelectionIndex(), addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

getMaxSelectionIndex

public int getMaxSelectionIndex()
Returns the largest selected cell index. This is a convenience method that just delegates to the selectionModel.

Returns:
the largest selected cell index
See Also:
BoardSelectionModel.getMaxSelectionIndex(), addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

isSelectedIndex

public boolean isSelectedIndex(int index)
Returns true if the specified index is selected. This is a convenience method that just delegates to the selectionModel.

Parameters:
index - index to be queried for selection state
Returns:
true if the specified index is selected
See Also:
BoardSelectionModel.isSelectedIndex(int), setSelectedIndex(int), addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

isSelectionEmpty

public boolean isSelectionEmpty()
Returns true if nothing is selected. This is a convenience method that just delegates to the selectionModel.

Returns:
true if nothing is selected
See Also:
BoardSelectionModel.isSelectionEmpty(), clearSelection(), addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

getSelectedIndices

public int[] getSelectedIndices()
Returns an array of all of the selected indices in increasing order.

Returns:
all of the selected indices, in increasing order
See Also:
removeSelectionInterval(int, int), addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

setSelectedIndex

public void setSelectedIndex(int index)
Selects a single cell.

Parameters:
index - the index of the one cell to select
See Also:
BoardSelectionModel.setSelectionInterval(int, int), isSelectedIndex(int), addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

setSelectedIndices

public void setSelectedIndices(int[] indices)
Selects a set of cells.

Parameters:
indices - an array of the indices of the cells to select
See Also:
BoardSelectionModel.addSelectionInterval(int, int), isSelectedIndex(int), addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

getSelectedValues

public java.lang.Object[] getSelectedValues()
Returns an array of the values for the selected cells. The returned values are sorted in increasing index order.

Returns:
the selected values or an empty list if nothing is selected
See Also:
isSelectedIndex(int), getModel(), addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

addBoardSelectionListener

public void addBoardSelectionListener(BoardSelectionListener listener)
Adds a listener to the cardBoard that's notified each time a change to the selection occurs. Listeners added directly to the JCardBoardComponent will have their ListSelectionEvent.getSource() == this JCardBoardComponent (instead of the BoardSelectionModel).

Parameters:
listener - the ListSelectionListener to add
See Also:
getSelectionModel(), getBoardSelectionListeners()

removeBoardSelectionListener

public void removeBoardSelectionListener(BoardSelectionListener listener)
Removes a listener from the list that's notified each time a change to the selection occurs.

Parameters:
listener - the BoardSelectionListener to remove
See Also:
addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener), getSelectionModel()

getBoardSelectionListeners

public BoardSelectionListener[] getBoardSelectionListeners()
Returns an array of all the BoardSelectionListeners added to this JCardBoardComponent with addBoardSelectionListener().

Returns:
all of the BoardSelectionListeners added or an empty array if no listeners have been added
Since:
1.4
See Also:
addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

fireSelectionValueChanged

protected void fireSelectionValueChanged(int firstIndex,
                                         int lastIndex,
                                         boolean isAdjusting)
Notifies JCardBoardComponent BoardSelectionListeners that the selection model has changed. It's used to forward BoardSelectionEvents from the selectionModel to the BoardSelectionListeners added directly to the JCardBoardComponent.

Parameters:
firstIndex - the first selected index
lastIndex - the last selected index
isAdjusting - true if multiple changes are being made
See Also:
addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener), removeBoardSelectionListener(BoardSelectionListener), EventListenerList

clearSelection

public void clearSelection()
Clears the selection - after calling this method isSelectionEmpty will return true. This is a convenience method that just delegates to the selectionModel.

See Also:
BoardSelectionModel.clearSelection(), isSelectionEmpty(), addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

setSelectionInterval

public void setSelectionInterval(int anchor,
                                 int lead)
Selects the specified interval. Both the anchor and lead indices are included. It's not necessary for anchor to be less than lead. This is a convenience method that just delegates to the selectionModel. The DefaultBoardSelectionModel implementation will do nothing if either anchor or lead are -1. If anchor or lead are less than -1, IndexOutOfBoundsException is thrown.

Parameters:
anchor - the first index to select
lead - the last index to select
Throws:
java.lang.IndexOutOfBoundsException - if either anchor or lead are less than -1
See Also:
BoardSelectionModel.setSelectionInterval(int, int), addSelectionInterval(int, int), removeSelectionInterval(int, int), addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

addSelectionInterval

public void addSelectionInterval(int anchor,
                                 int lead)
Sets the selection to be the union of the specified interval with current selection. Both the anchor and lead indices are included. It's not necessary for anchor to be less than lead. This is a convenience method that just delegates to the selectionModel. The DefaultBoardSelectionModel implementation will do nothing if either anchor or lead are -1. If anchor or lead are less than -1, IndexOutOfBoundsException is thrown.

Parameters:
anchor - the first index to add to the selection
lead - the last index to add to the selection
Throws:
java.lang.IndexOutOfBoundsException - if either anchor or lead are less than -1
See Also:
BoardSelectionModel.addSelectionInterval(int, int), setSelectionInterval(int, int), removeSelectionInterval(int, int), addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

removeSelectionInterval

public void removeSelectionInterval(int index0,
                                    int index1)
Sets the selection to be the set difference of the specified interval and the current selection. Both the index0 and index1 indices are removed. It's not necessary for index0 to be less than index1. This is a convenience method that just delegates to the selectionModel. The DefaultBoardSelectionModel implementation will do nothing if either index0 or index1 are -1. If index0 or index1 are less than -1, IndexOutOfBoundsException is thrown.

Parameters:
index0 - the first index to remove from the selection
index1 - the last index to remove from the selection
Throws:
java.lang.IndexOutOfBoundsException - if either index0 or index1 are less than -1
See Also:
BoardSelectionModel.removeSelectionInterval(int, int), setSelectionInterval(int, int), addSelectionInterval(int, int), addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)


Copyright © 2004 CoffeeBreaks. All Rights Reserved.