-
- /*
- * leftCellX now contains the basic left offset necessary to draw
- * the cells such that the selected cell (column) is fully
- * visible within this widget's given width. Or, if the widget
- * is too narrow to display the full cell, leftCellX is 0 or
- * ROW_LABEL_WIDTH.
- *
- * Now reset all of the X positions of the other cells so that
- * the selected cell X is leftCellX.
- */
- for (int y = 0; y < rows.size(); y++) {
- // All cells to the left of selected cell.
- int newCellX = leftCellX;
- left = selectedColumn - 1;
- for (int x = selectedColumn - 1; x >= 0; x--) {
- newCellX -= rows.get(y).get(x).getWidth() + 1;
- rows.get(y).get(x).setX(newCellX);
- if (newCellX >= (showRowLabels ? ROW_LABEL_WIDTH : 0)) {
- if ((rows.get(y).get(0).getY() < (showColumnLabels ? COLUMN_LABEL_HEIGHT : 0))
- || (rows.get(y).get(0).getY() >= getHeight())
- ) {
- // This row isn't visible.
- rows.get(y).get(x).setVisible(false);
- } else {
- rows.get(y).get(x).setVisible(true);
- }
- left--;
- } else {
- // This cell won't be visible.
- rows.get(y).get(x).setVisible(false);
- }
- }
+ if (right < selectedColumn) {
+ // selectedColumn is outside the view range. Push left over,
+ // and calculate again.
+ left++;
+ } else if (left == selectedColumn) {
+ // selectedColumn doesn't fit inside the view range, but we
+ // can't go over any further either. Bail out.
+ done = true;
+ } else if (selectedIsVisible == false) {
+ // selectedColumn doesn't fit inside the view range, continue
+ // on.