public void clearSelection() {
    if (!cellSelectionTableModel.isSomethingSelected()) return;

    cellSelectionTableModel.clear();
    fireValueChanged(
        0,
        getRowCount(),
        0,
        getColumnCount(),
        getAnchorSelectionRowIndex(),
        getAnchorSelectionColumnIndex());
  }
 public boolean toggleSelection(int row, int column) {
   boolean wasSelected = isCellSelected(row, column);
   cellSelectionTableModel.setValueAt(wasSelected, row, column);
   fireValueChanged(
       row, row, column, column, getAnchorSelectionRowIndex(), getAnchorSelectionColumnIndex());
   return wasSelected;
 }
  private void invertSelectionIntervals(
      int rowIndex, int rowIndex2, int columnIndex, int columnIndex2) {
    if (rowIndex == -1 || rowIndex2 == -1 || columnIndex == -1 || columnIndex2 == -1) {
      return;
    }
    int minRowIndex = Math.min(rowIndex, rowIndex2);
    int maxRowIndex = Math.max(rowIndex, rowIndex2);
    int minColumnIndex = Math.min(columnIndex, columnIndex2);
    int maxColumnIndex = Math.max(columnIndex, columnIndex2);

    for (int row = minRowIndex; row <= maxRowIndex; row++) {
      for (int column = minColumnIndex; column <= maxColumnIndex; column++) {
        cellSelectionTableModel.setValueAt(
            !(Boolean) cellSelectionTableModel.getValueAt(row, column), row, column);
      }
    }
    fireValueChanged(
        minRowIndex,
        maxRowIndex,
        minColumnIndex,
        maxColumnIndex,
        getAnchorSelectionRowIndex(),
        getAnchorSelectionColumnIndex());
  }
 public boolean isCellSelected(int row, int column) {
   return (Boolean) cellSelectionTableModel.getValueAt(row, column);
 }
 public void setSize(int rowCount, int columnCount) {
   cellSelectionTableModel.setSize(rowCount, columnCount);
 }
 public int getRowCount() {
   return cellSelectionTableModel.getRowCount();
 }
 public int getColumnCount() {
   return cellSelectionTableModel.getColumnCount();
 }