boolean withShiftMask, boolean withControlMask) {
if (!withShiftMask && !withControlMask) {
selectionLayer.clear(false);
}
ILayerCell cell = selectionLayer.getCellByPosition(columnPosition,
rowPosition);
if (cell != null) {
selectionLayer.setLastSelectedCell(cell.getOriginColumnPosition(),
cell.getOriginRowPosition());
// Shift pressed + row selected
if (selectionLayer.getSelectionModel().isMultipleSelectionAllowed()
&& withShiftMask
&& selectionLayer.getLastSelectedRegion() != null
&& selectionLayer.hasRowSelection()
&& (selectionLayer.getSelectionAnchor().rowPosition != SelectionLayer.NO_SELECTION)
&& (selectionLayer.getSelectionAnchor().columnPosition != SelectionLayer.NO_SELECTION)) {
// if cell.rowPosition > getSelectionAnchor().rowPositon, then
// use cell.rowPosition + span - 1 (maxRowPosition)
// else use cell.originRowPosition (minRowPosition)
// and compare with selectionAnchor.rowPosition
if (cell.getRowPosition() > selectionLayer.getSelectionAnchor().rowPosition) {
int maxRowPosition = cell.getOriginRowPosition()
+ cell.getRowSpan() - 1;
selectionLayer.getLastSelectedRegion().height = Math
.abs(selectionLayer.getSelectionAnchor().rowPosition
- maxRowPosition) + 1;
} else {
int minRowPosition = cell.getOriginRowPosition();
selectionLayer.getLastSelectedRegion().height = Math
.abs(selectionLayer.getSelectionAnchor().rowPosition
- minRowPosition) + 1;
}
selectionLayer.getLastSelectedRegion().y = Math.min(
selectionLayer.getSelectionAnchor().rowPosition,
cell.getOriginRowPosition());
if (cell.getColumnPosition() > selectionLayer
.getSelectionAnchor().columnPosition) {
int maxColumnPosition = cell.getOriginColumnPosition()
+ cell.getColumnSpan() - 1;
selectionLayer.getLastSelectedRegion().width = Math
.abs(selectionLayer.getSelectionAnchor().columnPosition
- maxColumnPosition) + 1;
} else {
int minColumnPosition = cell.getOriginColumnPosition();
selectionLayer.getLastSelectedRegion().width = Math
.abs(selectionLayer.getSelectionAnchor().columnPosition
- minColumnPosition) + 1;
}
selectionLayer.getLastSelectedRegion().x = Math.min(
selectionLayer.getSelectionAnchor().columnPosition,
cell.getOriginColumnPosition());
selectionLayer.addSelection(selectionLayer
.getLastSelectedRegion());
} else {
selectionLayer.setLastSelectedRegion(null);
Rectangle selection = new Rectangle(
cell.getOriginColumnPosition(),
cell.getOriginRowPosition(), cell.getColumnSpan(),
cell.getRowSpan());
selectionLayer.addSelection(selection);
}
}
}