|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
com.sas.swing.visuals.tableview.CellSelectionModel
public class CellSelectionModel
| Field Summary | |
|---|---|
protected int |
anchorOrdinal
|
protected java.util.BitSet |
extendedValue
|
protected int |
firstAdjustedOrdinal
|
protected int |
firstChangedOrdinal
|
protected int |
lastAdjustedOrdinal
|
protected int |
lastChangedOrdinal
|
protected int |
leadOrdinal
|
protected static int |
MAX
|
protected int |
maxOrdinal
|
protected static int |
MIN
|
protected int |
minOrdinal
|
protected TableView |
table
|
protected java.util.BitSet |
value
contains a ListSelectionModel for each column |
| Constructor Summary | |
|---|---|
CellSelectionModel()
Constructs a default CellSelectionModel, setting the TableView to null. |
|
CellSelectionModel(TableView table)
Constructs a CellSelectionModel and sets the TableView to the given TableView. |
|
| Method Summary | |
|---|---|
void |
addSelection(int row,
int column)
Adds the given cell to the selection |
void |
addSelectionInterval(int ordinal1,
int ordinal2)
Adds the block of cells defined by the ordinals. |
void |
addSelectionInterval(int row1,
int column1,
int row2,
int column2)
Adds the block of cells defined by the row-column pairs. |
protected void |
changeSelection(java.util.BitSet bits,
int clearMin,
int clearMax,
int setMin,
int setMax,
boolean clearFirst)
|
protected void |
changeSelection(int clearMin,
int clearMax,
int setMin,
int setMax)
Change the selection with the effect of first clearing the values in the inclusive range [clearMin, clearMax] then setting the values in the inclusive range [setMin, setMax]. |
protected void |
changeSelection(int clearMin,
int clearMax,
int setMin,
int setMax,
boolean clearFirst)
|
protected void |
changeTempSelection(int clearMin,
int clearMax,
int setMin,
int setMax)
Change the selection with the effect of first clearing the values in the inclusive range [clearMin, clearMax] then setting the values in the inclusive range [setMin, setMax]. |
protected void |
changeTempSelection(int clearMin,
int clearMax,
int setMin,
int setMax,
boolean clearFirst)
|
protected void |
clear(java.util.BitSet bits,
int ordinal)
|
void |
clearSelection()
Clears all the selected cells |
java.lang.Object |
clone()
Returns a clone of this selection model with the same selection. |
protected boolean |
contains(int a,
int b,
int i)
|
protected int |
createOrdinal(int row,
int column)
Creates the ordinal value for the given row-column pair. |
protected void |
fireValueChanged()
|
protected void |
fireValueChanged(boolean isAdjusting)
Notifies listeners that we have ended a series of adjustments. |
protected void |
fireValueChanged(int firstOrdinal,
int lastOrdinal)
Notifies ListSelectionListeners that the value
of the selection, in the closed interval firstIndex,
lastIndex, has changed. |
protected void |
fireValueChanged(int firstOrdinal,
int lastOrdinal,
boolean isAdjusting)
|
int |
getAnchorSelectionIndex()
Returns the anchor cell for the selected cells. |
int |
getLeadSelectionIndex()
Returns the lead cell for the selected cells. |
int |
getMaxSelectionIndex()
Delegates to getMaxSelectionOrdinal(). |
int |
getMaxSelectionOrdinal()
Returns the last selected oridinal(cell), or -1 if nothing is selected. |
int |
getMinSelectionIndex()
Delegates to getMinSelectionOrdinal(). |
int |
getMinSelectionOrdinal()
Returns the first selected oridinal(cell), or -1 if nothing is selected. |
TableView |
getTable()
Returns the TableView associated with this cell selection model. |
void |
insertIndexInterval(int ordinal,
int length,
boolean before)
Insert length indices beginning before/after ordinal. |
boolean |
isSelected(int row,
int column)
|
boolean |
isSelectedIndex(int ordinal)
Returns true if the griven index(ordinal) is selected or not. |
boolean |
isSelectionEmpty()
Returns true if no cells are selected, false otherwise. |
protected void |
markAsDirty(int ordinal)
|
void |
removeIndexInterval(int ordinal1,
int ordinal2)
Remove the indices in the interval ordinal1,ordinal2 (inclusive) from the selection model. |
void |
removeSelection(int row,
int column)
Removes the given cell to the selection |
void |
removeSelectionInterval(int ordinal1,
int ordinal2)
Removes the block of cells defined by the ordinals. |
void |
removeSelectionInterval(int row1,
int column1,
int row2,
int column2)
Removes the block of cells defined by the row-column pairs. |
protected void |
set(java.util.BitSet bits,
int ordinal)
|
void |
setAnchorSelectionCell(int row,
int column)
Set the anchor selection cell, leaving all selection values unchanged. |
void |
setAnchorSelectionIndex(int ordinal)
Sets the anchor to the given index, updates the selection and fires a selection event. |
void |
setLeadSelectionCell(int row,
int column)
Sets the lead selection index, ensuring that values between the anchor and the new lead are either all selected or all deselected. |
void |
setLeadSelectionIndex(int ordinal)
Sets the lead to the given index, updates the selection and fires a selection event. |
void |
setSelection(int row,
int column)
Sets the selection to the one cell defined by the row-column pair. |
void |
setSelectionInterval(int ordinal1,
int ordinal2)
Selects the block of cells defined by the ordinals. |
void |
setSelectionInterval(int row1,
int column1,
int row2,
int column2)
Selects the block of cells defined by the row-column pairs. |
void |
setTable(TableView newTable)
Sets the TableView associated with this selection model to the given TableView. |
java.lang.String |
toString()
Returns a string that displays and identifies this object's properties. |
protected void |
updateLeadAnchorOrdinals(int anchorOrdinal,
int leadOrdinal)
|
protected void |
updateSelectedValues()
|
protected void |
validateMinAndMaxOrdinal()
|
| Field Detail |
|---|
protected static final int MIN
protected static final int MAX
protected java.util.BitSet value
protected java.util.BitSet extendedValue
protected TableView table
protected int firstAdjustedOrdinal
protected int lastAdjustedOrdinal
protected int firstChangedOrdinal
protected int lastChangedOrdinal
protected int anchorOrdinal
protected int leadOrdinal
protected int minOrdinal
protected int maxOrdinal
| Constructor Detail |
|---|
public CellSelectionModel()
public CellSelectionModel(TableView table)
table - the TableView associated with this selection model| Method Detail |
|---|
public void setTable(TableView newTable)
newTable - the new TableView associated with this selection model.getTable()public TableView getTable()
setTable(TableView)public int getMinSelectionOrdinal()
createOrdinal(int, int)public int getMaxSelectionOrdinal()
createOrdinal(int, int)public boolean isSelectionEmpty()
isSelectionEmpty in interface javax.swing.ListSelectionModelisSelectionEmpty in class javax.swing.DefaultListSelectionModel
public void setSelectionInterval(int ordinal1,
int ordinal2)
setSelectionInterval in interface javax.swing.ListSelectionModelsetSelectionInterval in class javax.swing.DefaultListSelectionModelordinal1 - the upper left corner of the block of cellsordinal2 - the lower right corner of the block of cellscreateOrdinal(int, int)
public void addSelectionInterval(int ordinal1,
int ordinal2)
addSelectionInterval in interface javax.swing.ListSelectionModeladdSelectionInterval in class javax.swing.DefaultListSelectionModelordinal1 - the upper left corner of the block of cellsordinal2 - the lower right corner of the block of cellscreateOrdinal(int, int)
public void removeSelectionInterval(int ordinal1,
int ordinal2)
removeSelectionInterval in interface javax.swing.ListSelectionModelremoveSelectionInterval in class javax.swing.DefaultListSelectionModelordinal1 - the upper left corner of the block of cellsordinal2 - the lower right corner of the block of cellscreateOrdinal(int, int)public int getMinSelectionIndex()
getMinSelectionIndex in interface javax.swing.ListSelectionModelgetMinSelectionIndex in class javax.swing.DefaultListSelectionModelcreateOrdinal(int, int),
getMinSelectionOrdinal()public int getMaxSelectionIndex()
getMaxSelectionIndex in interface javax.swing.ListSelectionModelgetMaxSelectionIndex in class javax.swing.DefaultListSelectionModelcreateOrdinal(int, int),
getMaxSelectionOrdinal()public boolean isSelectedIndex(int ordinal)
isSelectedIndex in interface javax.swing.ListSelectionModelisSelectedIndex in class javax.swing.DefaultListSelectionModelordinal - the ordinal(cell) in question
createOrdinal(int, int)public int getAnchorSelectionIndex()
getAnchorSelectionIndex in interface javax.swing.ListSelectionModelgetAnchorSelectionIndex in class javax.swing.DefaultListSelectionModelsetAnchorSelectionIndex(int),
createOrdinal(int, int)public int getLeadSelectionIndex()
getLeadSelectionIndex in interface javax.swing.ListSelectionModelgetLeadSelectionIndex in class javax.swing.DefaultListSelectionModelsetLeadSelectionIndex(int),
createOrdinal(int, int)public void setAnchorSelectionIndex(int ordinal)
setAnchorSelectionIndex in interface javax.swing.ListSelectionModelsetAnchorSelectionIndex in class javax.swing.DefaultListSelectionModelordinal - the ordinal to set the anchor of the selection togetAnchorSelectionIndex(),
createOrdinal(int, int)public void setLeadSelectionIndex(int ordinal)
setLeadSelectionIndex in interface javax.swing.ListSelectionModelsetLeadSelectionIndex in class javax.swing.DefaultListSelectionModelordinal - the ordinal to set the lead of the selection togetLeadSelectionIndex(),
createOrdinal(int, int)
public void insertIndexInterval(int ordinal,
int length,
boolean before)
insertIndexInterval in interface javax.swing.ListSelectionModelinsertIndexInterval in class javax.swing.DefaultListSelectionModelordinal - the ordinal(cell) to insert before or afterlength - the number of indices to insertbefore - true for before, false for aftercreateOrdinal(int, int)
public void removeIndexInterval(int ordinal1,
int ordinal2)
removeIndexInterval in interface javax.swing.ListSelectionModelremoveIndexInterval in class javax.swing.DefaultListSelectionModelordinal1 - the first ordinalordinal2 - the last ordinalcreateOrdinal(int, int)
public void addSelection(int row,
int column)
row - the row indexcolumn - the column index
public void setSelection(int row,
int column)
row - the row index of the cell to selectcolumn - the column index of the cell to select
public void setSelectionInterval(int row1,
int column1,
int row2,
int column2)
row1 - the row index of the first cellcolumn1 - the column index of the first cellrow2 - the row index of the last cellcolumn2 - the column index of the last cell
public void addSelectionInterval(int row1,
int column1,
int row2,
int column2)
row1 - the row index of the first cellcolumn1 - the column index of the first cellrow2 - the row index of the last cellcolumn2 - the column index of the last cell
public void removeSelection(int row,
int column)
row - the row indexcolumn - the column index
public void removeSelectionInterval(int row1,
int column1,
int row2,
int column2)
row1 - the row index of the first cellcolumn1 - the column index of the first cellrow2 - the row index of the last cellcolumn2 - the column index of the last cell
public void setAnchorSelectionCell(int row,
int column)
row - the row index of the cellcolumn - the column index of the cellgetAnchorSelectionIndex(),
setLeadSelectionIndex(int)
public void setLeadSelectionCell(int row,
int column)
If the value at the anchor index is not selected, do the same thing in reverse selecting values in the old range and deslecting values in the new one.
Generate a single event for this change and notify all listeners. For the purposes of generating minimal bounds in this event, do the operation in a single pass; that way the first and last index inside the ListSelectionEvent that is broadcast will refer to cells that actually changed value because of this method. If, instead, this operation were done in two steps the effect on the selection state would be the same but two events would be generated and the bounds around the changed values would be wider, including cells that had been first cleared only to later be set.
This method can be used in the mouseDragged method
of a UI class to extend a selection.
row - the row index of the cellcolumn - the column index of the cellgetLeadSelectionIndex(),
setAnchorSelectionIndex(int)public void clearSelection()
clearSelection in interface javax.swing.ListSelectionModelclearSelection in class javax.swing.DefaultListSelectionModelprotected void updateSelectedValues()
public boolean isSelected(int row,
int column)
createOrdinal(int, int)
protected void set(java.util.BitSet bits,
int ordinal)
protected void clear(java.util.BitSet bits,
int ordinal)
protected void markAsDirty(int ordinal)
protected boolean contains(int a,
int b,
int i)
protected void updateLeadAnchorOrdinals(int anchorOrdinal,
int leadOrdinal)
protected void validateMinAndMaxOrdinal()
protected void changeSelection(java.util.BitSet bits,
int clearMin,
int clearMax,
int setMin,
int setMax,
boolean clearFirst)
protected void changeSelection(int clearMin,
int clearMax,
int setMin,
int setMax,
boolean clearFirst)
protected void changeSelection(int clearMin,
int clearMax,
int setMin,
int setMax)
protected void changeTempSelection(int clearMin,
int clearMax,
int setMin,
int setMax,
boolean clearFirst)
protected void changeTempSelection(int clearMin,
int clearMax,
int setMin,
int setMax)
protected int createOrdinal(int row,
int column)
getTable().getRowCount() * getTable().getColumnCount() - 1 with the ordinal mapping
to 0 being the cell located at 0, 0. The ordinals increase by 1 going across columns and by
the
row - the row indexcolumn - the column index
getTable().getRowCount() * getTable().getColumnCount() - 1
if the cell is validprotected void fireValueChanged(boolean isAdjusting)
fireValueChanged in class javax.swing.DefaultListSelectionModel
protected void fireValueChanged(int firstOrdinal,
int lastOrdinal)
ListSelectionListeners that the value
of the selection, in the closed interval firstIndex,
lastIndex, has changed.
fireValueChanged in class javax.swing.DefaultListSelectionModel
protected void fireValueChanged(int firstOrdinal,
int lastOrdinal,
boolean isAdjusting)
fireValueChanged in class javax.swing.DefaultListSelectionModelfirstIndex - the first index in the intervallastIndex - the last index in the intervalisAdjusting - true if this is the final change in a series of
adjustmentsEventListenerListprotected void fireValueChanged()
public java.lang.String toString()
toString in class javax.swing.DefaultListSelectionModelString representation of this object
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
listenerLists are not duplicated.
clone in class javax.swing.DefaultListSelectionModeljava.lang.CloneNotSupportedException - if the selection model does not
both (a) implement the Cloneable interface and (b) define a
clone method.
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||