com.eliad.model
Interface GridSelectionModel

All Known Implementing Classes:
AbstractGridSelectionModel

public interface GridSelectionModel
extends GridSelectionConstants, RulerConstants

A model for the selection of cells inside a grid. This also act as as a source of GridSelectionEvents.

Version:
1.0 00/03/26
Author:
Patrick Mérissert-Coffinières

Inner Class Summary
static class GridSelectionModel.Factory
          A factory to create default GridSelectionModel objects.
 
Fields inherited from class com.eliad.util.GridSelectionConstants
COLUMN_RANGE_SELECTION, MULTIPLE_COLUMN_SELECTION, MULTIPLE_RECTANGLE_SELECTION, MULTIPLE_ROW_SELECTION, POLICY_COUNT, POLICY_MASK, POLICY_MULTIRANGE, POLICY_NONE, POLICY_RANGE, POLICY_SINGLE, ROW_RANGE_SELECTION, SINGLE_CELL_SELECTION, SINGLE_COLUMN_SELECTION, SINGLE_RECTANGLE_SELECTION, SINGLE_ROW_SELECTION, UNIT_CELL, UNIT_COLUMN, UNIT_ROW
 
Fields inherited from class com.eliad.util.RulerConstants
AUTO_RESIZE_ALL, AUTO_RESIZE_LAST, AUTO_RESIZE_NEXT, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT, HORIZONTAL, VERTICAL
 
Method Summary
 void addGridSelectionListener(GridSelectionListener l)
          Adds a listener to the list that's notified each time a change to the selection model occurs.
 void addSelectionRange(int topRow, int leftColumn, int bottomRow, int rightColumn)
          Changes the selection to be all the points whose row number is between anchorRow and leadRow included and whose column number is between anchorColumn and leadColumn included.
 void changeSelectionRange(int oldTopRow, int oldLeftColumn, int oldBottomRow, int oldRightColumn, int newTopRow, int newLeftColumn, int newBottomRow, int newRightColumn, boolean clearFirst)
          Extends the selection.
 void clearSelection()
          Changes the selection to the empty set.
 int getAnchorColumn()
          Returns the leftmost coordinate of the anchor column.
 int getAnchorRow()
          Returns the top coordinate of the anchor row.
 int getFirstSelectedColumn()
          Retrieves the index of the first column where at least one cell is selected. shortcut for getFirstSelectedItem(HORIZONTAL)
 int getFirstSelectedItem(int orientation)
          Retrieves the index of the first row/column where at least one unit is selected.
 int getFirstSelectedRow()
          Retrieves the index of the first row where at least one cell is selected. shortcut for getFirstSelectedItem(VERTICAL)
 int getLastSelectedColumn()
          Retrieves the index of the last column where at least one cell is selected. shortcut for getLastSelectedItem(HORIZONTAL)
 int getLastSelectedItem(int orientation)
          Retrieves the index of the last row/column where at least one unit is selected.
 int getLastSelectedRow()
          Retrieves the index of the last row where at least one cell is selected. shortcut for getLastSelectedItem(VERTICAL)
 int getLeadColumn()
          Returns the rightmost coordinate of the lead column.
 int getLeadRow()
          Returns the bottom coordinate of the lead row.
 int getSelectionCount()
          Returns the number of selected units
 int getSelectionPolicy()
          Gets the selection policy.
 int getSelectionUnit()
          Gets the selection unit.
 boolean getValueIsAdjusting()
          Returns true if the value is undergoing a series of changes.
 void insertColumns(int column, int length)
          Inserts length columns before column.
 void insertRows(int row, int length)
          Inserts length rows before row.
 boolean isSelected(int row, int column)
          Returns true if the specified unit is selected.
 boolean isSelectionEmpty()
          Returns true if no cells are selected.
 java.util.Iterator iterator()
          This method returns a non-null iterator for the individual selected units.
 void removeColumns(int column, int length)
          Removes length columns beginning at column.
 void removeGridSelectionListener(GridSelectionListener l)
          Removes a listener from the list that's notified each time a change to the selection model occurs.
 void removeRows(int row, int length)
          Removes length rows beginning at row.
 void removeSelectionRange(int topRow, int leftColumn, int bottomRow, int rightColumn)
          Changes the selection to be the set difference of all the points whose row number is between anchorRow and leadRow included and whose column number is between anchorColumn and leadColumn included.
 void setAnchor(int topRow, int leftColumn)
          Sets the anchor selection point.
 void setLead(int topRow, int leftColumn)
          Sets the lead selection point.
 void setSelectionPolicy(int policy)
          Sets the selection policy.
 void setSelectionRange(int topRow, int leftColumn, int bottomRow, int leadColumn)
          Changes the selection to be all the points whose row number is between anchorRow and leadRow included and whose column number is between anchorColumn and leadColumn included.
 void setSelectionUnit(int unit)
          Sets the selection unit.
 void setValueIsAdjusting(boolean isAdjusting)
          This property is true if upcoming changes to the value of the model should be considered a single event.
 

Method Detail

getSelectionUnit

public int getSelectionUnit()
Gets the selection unit.

setSelectionUnit

public void setSelectionUnit(int unit)
Sets the selection unit. The following values are allowed:
See Also:
getSelectionUnit()

getSelectionPolicy

public int getSelectionPolicy()
Gets the selection policy.
See Also:
setSelectionPolicy(int)

setSelectionPolicy

public void setSelectionPolicy(int policy)
Sets the selection policy. The following values are allowed:

isSelectionEmpty

public boolean isSelectionEmpty()
Returns true if no cells are selected.

isSelected

public boolean isSelected(int row,
                          int column)
Returns true if the specified unit is selected.
Parameters:
row - the row of the queried unit, ignored if the unit is COLUMN
column - the column of the queried unit, ignored if the unit is ROW

getSelectionCount

public int getSelectionCount()
Returns the number of selected units

getFirstSelectedItem

public int getFirstSelectedItem(int orientation)
Retrieves the index of the first row/column where at least one unit is selected.
Preconditions:
orientation == HORIZONTAL || orientation ==VERTICAL
getSelectionUnit() == UNIT_ROW implies orientation == VERTICAL
getSelectionUnit() == UNIT_COLUMN implies orientation == HORIZONTAL

getLastSelectedItem

public int getLastSelectedItem(int orientation)
Retrieves the index of the last row/column where at least one unit is selected.
Preconditions:
orientation == HORIZONTAL || orientation ==VERTICAL
getSelectionUnit() == UNIT_ROW implies orientation == VERTICAL
getSelectionUnit() == UNIT_COLUMN implies orientation == HORIZONTAL

getFirstSelectedRow

public int getFirstSelectedRow()
Retrieves the index of the first row where at least one cell is selected. shortcut for getFirstSelectedItem(VERTICAL)

getFirstSelectedColumn

public int getFirstSelectedColumn()
Retrieves the index of the first column where at least one cell is selected. shortcut for getFirstSelectedItem(HORIZONTAL)

getLastSelectedRow

public int getLastSelectedRow()
Retrieves the index of the last row where at least one cell is selected. shortcut for getLastSelectedItem(VERTICAL)

getLastSelectedColumn

public int getLastSelectedColumn()
Retrieves the index of the last column where at least one cell is selected. shortcut for getLastSelectedItem(HORIZONTAL)

iterator

public java.util.Iterator iterator()
This method returns a non-null iterator for the individual selected units. The elements, if any, of this iterator, will be int[2]: If the selection unit is UNIT_CELL, the element will represent a cell, and the first int will be the row index, and the second will be the column index If the selection unit is UNIT_ROW, the element will represent a row, and the first int will be the row index, and the second will be -1 If the selection unit is UNIT_COLUMN, the element will represent a column, and the first int will be -1, and the second will be the column index
Returns:
An iterattor for the selected units.
Postconditions:
return != null

clearSelection

public void clearSelection()
Changes the selection to the empty set. If this represents a change to the current selection then notify each GridSelectionListener.
See Also:
addGridSelectionListener(com.eliad.model.GridSelectionListener)

setSelectionRange

public void setSelectionRange(int topRow,
                              int leftColumn,
                              int bottomRow,
                              int leadColumn)
Changes the selection to be all the points whose row number is between anchorRow and leadRow included and whose column number is between anchorColumn and leadColumn included. If this represents a change to the current selection, then notify each GridSelectionListener. If the mode is GridSelectionConstants.SINGLE_CELL_SELECTION range will be restrained to its top-left cell.

Parameters:
anchorRow - one row boundary of the selected range
anchorColumn - one column boundary of the selected range
leadRow - the other row boundary of the selected range
leadColumn - the other column boundary of the selected range
Preconditions:
topRow >= 0
leftColumn >= 0
bottomRow >= 0
rightColumn >= 0
See Also:
addGridSelectionListener(com.eliad.model.GridSelectionListener)

addSelectionRange

public void addSelectionRange(int topRow,
                              int leftColumn,
                              int bottomRow,
                              int rightColumn)
Changes the selection to be all the points whose row number is between anchorRow and leadRow included and whose column number is between anchorColumn and leadColumn included. If this represents a change to the current selection, then notify each GridSelectionListener. If the mode is not GridSelectionConstants.MULTIPLE_RECTANGLE_SELECTION the resulting selection set may be reshaped to conform.
Parameters:
anchorRow - one row boundary of the added range
anchorColumn - one column boundary of the added range
leadRow - the other row boundary of the added range
leadColumn - the other column boundary of the added range
Preconditions:
topRow >= 0
leftColumn >= 0
bottomRow >= 0
rightColumn >= 0
See Also:
addGridSelectionListener(com.eliad.model.GridSelectionListener)

removeSelectionRange

public void removeSelectionRange(int topRow,
                                 int leftColumn,
                                 int bottomRow,
                                 int rightColumn)
Changes the selection to be the set difference of all the points whose row number is between anchorRow and leadRow included and whose column number is between anchorColumn and leadColumn included. If this represents a change to the current selection, then notify each GridSelectionListener. If the mode is not GridSelectionConstants.MULTIPLE_RECTANGLE_SELECTION the resulting selection set may be reshaped to conform.
Parameters:
anchorRow - one row boundary of the removed range
anchorColumn - one column boundary of the removed range
leadRow - the other row boundary of the removed range
leadColumn - the other column boundary of the removed range
Preconditions:
topRow >= 0
leftColumn >= 0
bottomRow >= 0
rightColumn >= 0
See Also:
addGridSelectionListener(com.eliad.model.GridSelectionListener)

changeSelectionRange

public void changeSelectionRange(int oldTopRow,
                                 int oldLeftColumn,
                                 int oldBottomRow,
                                 int oldRightColumn,
                                 int newTopRow,
                                 int newLeftColumn,
                                 int newBottomRow,
                                 int newRightColumn,
                                 boolean clearFirst)
Extends the selection.
See Also:
getLeadRow(), getLeadColumn()

insertRows

public void insertRows(int row,
                       int length)
Inserts length rows before row. Sets the newly inserted cells as selected if atleast one of the following conditions is respected: the cell is inside a selected column; the cell at (row-1-1,column) exists and is selected; the whole row is inside the selection. This method is typically called to synchronize the selection model with a corresponding change in the data model.
Parameters:
row - the insertion position.
length - the number of rows to insert.
Preconditions:
row >= 0
length > 0

insertColumns

public void insertColumns(int column,
                          int length)
Inserts length columns before column. Sets the newly inserted cells as selected if atleast one of the following conditions is respected: the cell is inside a selected row; the cell at (row,column-1) exists and is selected; the whole column is inside the selection. This method is typically called to synchronize the selection model with a corresponding change in the data model.
Parameters:
column - the insertion position.
length - the number of columns to insert.
Preconditions:
column >= 0
length > 0

removeRows

public void removeRows(int row,
                       int length)
Removes length rows beginning at row. This is typically called to sync the selection model with a corresponding change in the data model.
Parameters:
row - the deletion position.
length - the number of rows to remove.-1 means remove all rows.
Preconditions:
row >= 0
length > 0 || length == -1

removeColumns

public void removeColumns(int column,
                          int length)
Removes length columns beginning at column. This is typically called to sync the selection model with a corresponding change in the data model.
Parameters:
column - the deletion position.
length - the number of columns to remove. -1 means remove all rows.
Preconditions:
column >= 0
length > 0 || length == -1

getValueIsAdjusting

public boolean getValueIsAdjusting()
Returns true if the value is undergoing a series of changes.
Returns:
true if the value is currently adjusting
See Also:
setValueIsAdjusting(boolean)

setValueIsAdjusting

public void setValueIsAdjusting(boolean isAdjusting)
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 to false when the drag is finished. This property allows listeners to to update only when a change has been finalized, rather than handling all of the intermediate values.
Parameters:
valueIsAdjusting - The new value of the property.
See Also:
getValueIsAdjusting()

getAnchorRow

public int getAnchorRow()
Returns the top coordinate of the anchor row. The "anchor" is the most recent top-left cell and the most recent bottom-right cell is considered the "lead". Some interfaces may display these points specially.
See Also:
getLeadRow(), setSelectionRange(int, int, int, int), addSelectionRange(int, int, int, int)

getAnchorColumn

public int getAnchorColumn()
Returns the leftmost coordinate of the anchor column. The most recent top-left cell is considered the "anchor" and the most recent bottom-right cell is considered the "lead". Some interfaces may display these points specially.
See Also:
getLeadColumn(), setSelectionRange(int, int, int, int), addSelectionRange(int, int, int, int)

getLeadRow

public int getLeadRow()
Returns the bottom coordinate of the lead row. The most recent top-left cell is considered the "anchor" and the most recent bottom-right cell is considered the "lead". Some interfaces may display these points specially.
See Also:
getAnchorRow(), setSelectionRange(int, int, int, int), addSelectionRange(int, int, int, int)

getLeadColumn

public int getLeadColumn()
Returns the rightmost coordinate of the lead column. The most recent top-left cell is considered the "anchor" and the most recent bottom-right cell is considered the "lead". Some interfaces may display these points specially.
See Also:
getAnchorColumn(), setSelectionRange(int, int, int, int), addSelectionRange(int, int, int, int)

setAnchor

public void setAnchor(int topRow,
                      int leftColumn)
Sets the anchor selection point.
See Also:
getAnchorRow(), getAnchorColumn()

setLead

public void setLead(int topRow,
                    int leftColumn)
Sets the lead selection point.
See Also:
getLeadRow(), getLeadColumn()

addGridSelectionListener

public void addGridSelectionListener(GridSelectionListener l)
Adds a listener to the list that's notified each time a change to the selection model occurs.
Parameters:
l - the GridSelectionListener

removeGridSelectionListener

public void removeGridSelectionListener(GridSelectionListener l)
Removes a listener from the list that's notified each time a change to the selection model occurs.
Parameters:
l - the GridSelectionListener