int[] selColPos = selectionLayer
.getFullySelectedColumnPositions();
for (int col : selColPos) {
columnPosition = Math.max(columnPosition, col);
}
return new PositionCoordinate(freezeLayer, columnPosition, -1);
} else if (selectionLayer.getFullySelectedRowPositions().length > 0) {
// if rows are fully selected we will freeze the rows to the top
// including the selected row with the greatest index
int rowPosition = 0;
int[] selRowPos = selectionLayer.getFullySelectedRowPositions();
for (int row : selRowPos) {
rowPosition = Math.max(rowPosition, row);
}
return new PositionCoordinate(freezeLayer, -1, rowPosition);
} else {
// find the selected cell that is most to the left and to the
// top of the selection
int columnPosition = -1;
int rowPosition = -1;
PositionCoordinate[] coords = selectionLayer
.getSelectedCellPositions();
for (PositionCoordinate coord : coords) {
if (columnPosition < 0) {
columnPosition = coord.columnPosition;
} else {
columnPosition = Math.min(columnPosition,
coord.columnPosition);
}
if (rowPosition < 0) {
rowPosition = coord.rowPosition;
} else {
rowPosition = Math.min(rowPosition, coord.rowPosition);
}
}
return new PositionCoordinate(freezeLayer, columnPosition - 1,
rowPosition - 1);
}
} else {
PositionCoordinate selectionAnchor = selectionLayer
.getSelectionAnchor();
if (selectionAnchor != null) {
return new PositionCoordinate(freezeLayer,
selectionAnchor.columnPosition - 1,
selectionAnchor.rowPosition - 1);
}
}
return null;