org.cb.cardboard
Class DefaultBoardSelectionModel

java.lang.Object
  extended byorg.cb.cardboard.DefaultBoardSelectionModel
All Implemented Interfaces:
BoardSelectionModel, java.util.EventListener

public class DefaultBoardSelectionModel
extends java.lang.Object
implements BoardSelectionModel

Default data model for board selections.

we shamely reuse the DefaultListSelectionModel interface & adapts its implementation.

Version:
$Id: DefaultBoardSelectionModel.java 123 2004-04-14 23:45:53Z jerome $
Author:
jerome@coffeebreaks.org - last modified by $LastModifiedBy$

Field Summary
 
Fields inherited from interface org.cb.cardboard.BoardSelectionModel
MULTIPLE_INTERVAL_SELECTION, SINGLE_INTERVAL_SELECTION, SINGLE_SELECTION
 
Constructor Summary
DefaultBoardSelectionModel()
           
 
Method Summary
 void addBoardSelectionListener(BoardSelectionListener x)
          Add a listener to the list that's notified each time a change to the selection occurs.
 void addSelectionInterval(int index0, int index1)
          Change the selection to be the set union of the current selection and the indices between index0 and index1 inclusive.
 void clearSelection()
          Change the selection to the empty set.
 int getAnchorSelectionIndex()
          Return the first index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().
 int getLeadSelectionIndex()
          Return the second index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().
 int getMaxSelectionIndex()
           
 int getMinSelectionIndex()
           
 int getSelectionMode()
          Returns the current selection mode.
 boolean getValueIsAdjusting()
          Returns true if the value is undergoing a series of changes.
 void insertIndexInterval(int index, int length, boolean before)
          Insert length indices beginning before/after index.
 boolean isSelectedIndex(int index)
           
 boolean isSelectionEmpty()
           
 void removeBoardSelectionListener(BoardSelectionListener x)
          Remove a listener from the list that's notified each time a change to the selection occurs.
 void removeIndexInterval(int index0, int index1)
          Remove the indices in the interval index0,index1 (inclusive) from the selection model.
 void removeSelectionInterval(int index0, int index1)
          Change the selection to be the set difference of the current selection and the indices between index0 and index1 inclusive.
 void setAnchorSelectionIndex(int index)
          Set the anchor selection index.
 void setLeadSelectionIndex(int index)
          Set the lead selection index.
 void setSelectionInterval(int index0, int index1)
          Change the selection to be between index0 and index1 inclusive.
 void setSelectionMode(int selectionMode)
          Set the selection mode.
 void setValueIsAdjusting(boolean valueIsAdjusting)
          This property is true if upcoming changes to the value of the model should be considered a single event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultBoardSelectionModel

public DefaultBoardSelectionModel()
Method Detail

setSelectionInterval

public void setSelectionInterval(int index0,
                                 int index1)
Description copied from interface: BoardSelectionModel
Change the selection to be between index0 and index1 inclusive. If this represents a change to the current selection, then notify each ListSelectionListener. Note that index0 doesn't have to be less than or equal to index1.

Specified by:
setSelectionInterval in interface BoardSelectionModel
Parameters:
index0 - one end of the interval.
index1 - other end of the interval
See Also:
BoardSelectionModel.addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

addSelectionInterval

public void addSelectionInterval(int index0,
                                 int index1)
Description copied from interface: BoardSelectionModel
Change the selection to be the set union of the current selection and the indices between index0 and index1 inclusive. If this represents a change to the current selection, then notify each ListSelectionListener. Note that index0 doesn't have to be less than or equal to index1.

Specified by:
addSelectionInterval in interface BoardSelectionModel
Parameters:
index0 - one end of the interval.
index1 - other end of the interval
See Also:
BoardSelectionModel.addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

removeSelectionInterval

public void removeSelectionInterval(int index0,
                                    int index1)
Description copied from interface: BoardSelectionModel
Change the selection to be the set difference of the current selection and the indices between index0 and index1 inclusive. If this represents a change to the current selection, then notify each ListSelectionListener. Note that index0 doesn't have to be less than or equal to index1.

Specified by:
removeSelectionInterval in interface BoardSelectionModel
Parameters:
index0 - one end of the interval.
index1 - other end of the interval
See Also:
BoardSelectionModel.addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

getMinSelectionIndex

public int getMinSelectionIndex()
Specified by:
getMinSelectionIndex in interface BoardSelectionModel
Returns:
the first selected index or -1 if the selection is empty.

getMaxSelectionIndex

public int getMaxSelectionIndex()
Specified by:
getMaxSelectionIndex in interface BoardSelectionModel
Returns:
the last selected index or -1 if the selection is empty.

isSelectedIndex

public boolean isSelectedIndex(int index)
Specified by:
isSelectedIndex in interface BoardSelectionModel
Returns:
true if the specified index is selected.

getAnchorSelectionIndex

public int getAnchorSelectionIndex()
Description copied from interface: BoardSelectionModel
Return the first index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval(). The most recent index0 is considered the "anchor" and the most recent index1 is considered the "lead". Some interfaces display these indices specially, e.g. Windows95 displays the lead index with a dotted yellow outline.

Specified by:
getAnchorSelectionIndex in interface BoardSelectionModel
Returns:
the anchor selection index
See Also:
BoardSelectionModel.getLeadSelectionIndex(), BoardSelectionModel.setSelectionInterval(int, int), BoardSelectionModel.addSelectionInterval(int, int)

setAnchorSelectionIndex

public void setAnchorSelectionIndex(int index)
Description copied from interface: BoardSelectionModel
Set the anchor selection index.

Specified by:
setAnchorSelectionIndex in interface BoardSelectionModel
See Also:
BoardSelectionModel.getAnchorSelectionIndex()

getLeadSelectionIndex

public int getLeadSelectionIndex()
Description copied from interface: BoardSelectionModel
Return the second index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().

Specified by:
getLeadSelectionIndex in interface BoardSelectionModel
See Also:
BoardSelectionModel.getAnchorSelectionIndex(), BoardSelectionModel.setSelectionInterval(int, int), BoardSelectionModel.addSelectionInterval(int, int)

setLeadSelectionIndex

public void setLeadSelectionIndex(int index)
Description copied from interface: BoardSelectionModel
Set the lead selection index.

Specified by:
setLeadSelectionIndex in interface BoardSelectionModel
See Also:
BoardSelectionModel.getLeadSelectionIndex()

clearSelection

public void clearSelection()
Description copied from interface: BoardSelectionModel
Change the selection to the empty set. If this represents a change to the current selection then notify each ListSelectionListener.

Specified by:
clearSelection in interface BoardSelectionModel
See Also:
BoardSelectionModel.addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)

isSelectionEmpty

public boolean isSelectionEmpty()
Specified by:
isSelectionEmpty in interface BoardSelectionModel
Returns:
true if no indices are selected.

insertIndexInterval

public void insertIndexInterval(int index,
                                int length,
                                boolean before)
Description copied from interface: BoardSelectionModel
Insert length indices beginning before/after index. This is typically called to sync the selection model with a corresponding change in the data model.

Specified by:
insertIndexInterval in interface BoardSelectionModel

removeIndexInterval

public void removeIndexInterval(int index0,
                                int index1)
Description copied from interface: BoardSelectionModel
Remove the indices in the interval index0,index1 (inclusive) from the selection model. This is typically called to sync the selection model width a corresponding change in the data model.

Specified by:
removeIndexInterval in interface BoardSelectionModel

setValueIsAdjusting

public void setValueIsAdjusting(boolean valueIsAdjusting)
Description copied from interface: BoardSelectionModel
This property is true if upcoming changes to the value of the model should be considered a single event. For example if the model is being updated in response to a user drag, the value of the valueIsAdjusting property will be set to true when the drag is initiated and be set to false when the drag is finished. This property allows listeners to to update only when a change has been finalized, rather than always handling all of the intermediate values.

Specified by:
setValueIsAdjusting in interface BoardSelectionModel
Parameters:
valueIsAdjusting - The new value of the property.
See Also:
BoardSelectionModel.getValueIsAdjusting()

getValueIsAdjusting

public boolean getValueIsAdjusting()
Description copied from interface: BoardSelectionModel
Returns true if the value is undergoing a series of changes.

Specified by:
getValueIsAdjusting in interface BoardSelectionModel
Returns:
true if the value is currently adjusting
See Also:
BoardSelectionModel.setValueIsAdjusting(boolean)

setSelectionMode

public void setSelectionMode(int selectionMode)
Description copied from interface: BoardSelectionModel
Set the selection mode. The following selectionMode values are allowed:
  • SINGLE_SELECTION Only one list index can be selected at a time. In this mode the setSelectionInterval and addSelectionInterval methods are equivalent, and only the second index argument (the "lead index") is used.
  • SINGLE_INTERVAL_SELECTION One contiguous index interval can be selected at a time. In this mode setSelectionInterval and addSelectionInterval are equivalent.
  • MULTIPLE_INTERVAL_SELECTION In this mode, there's no restriction on what can be selected.

Specified by:
setSelectionMode in interface BoardSelectionModel
See Also:
BoardSelectionModel.getSelectionMode()

getSelectionMode

public int getSelectionMode()
Description copied from interface: BoardSelectionModel
Returns the current selection mode.

Specified by:
getSelectionMode in interface BoardSelectionModel
Returns:
The value of the selectionMode property.
See Also:
BoardSelectionModel.setSelectionMode(int)

addBoardSelectionListener

public void addBoardSelectionListener(BoardSelectionListener x)
Description copied from interface: BoardSelectionModel
Add a listener to the list that's notified each time a change to the selection occurs.

Specified by:
addBoardSelectionListener in interface BoardSelectionModel
Parameters:
x - the ListSelectionListener
See Also:
BoardSelectionModel.removeBoardSelectionListener(org.cb.cardboard.BoardSelectionListener), BoardSelectionModel.setSelectionInterval(int, int), BoardSelectionModel.addSelectionInterval(int, int), BoardSelectionModel.removeSelectionInterval(int, int), BoardSelectionModel.clearSelection(), BoardSelectionModel.insertIndexInterval(int, int, boolean), BoardSelectionModel.removeIndexInterval(int, int)

removeBoardSelectionListener

public void removeBoardSelectionListener(BoardSelectionListener x)
Description copied from interface: BoardSelectionModel
Remove a listener from the list that's notified each time a change to the selection occurs.

Specified by:
removeBoardSelectionListener in interface BoardSelectionModel
Parameters:
x - the ListSelectionListener
See Also:
BoardSelectionModel.addBoardSelectionListener(org.cb.cardboard.BoardSelectionListener)


Copyright © 2004 CoffeeBreaks. All Rights Reserved.