/** * Gets all the cells on the specified column * * @param col the column whose cells are to be returned * @return the cells on the specified column */ public Cell[] getColumn(int col) { // Find the last non-null cell boolean found = false; int row = numRows - 1; while (row >= 0 && !found) { if (getCell(col, row).getType() != CellType.EMPTY) { found = true; } else { row--; } } // Only create entries for non-empty cells Cell[] cells = new Cell[row+1]; for (int i = 0; i <= row; i++) { cells[i] = getCell(col, i); } return cells; }
/** * Gets all the cells on the specified row * * @param row the rows whose cells are to be returned * @return the cells on the given row */ public Cell[] getRow(int row) { // Find the last non-null cell boolean found = false; int col = numColumns - 1; while (col >= 0 && !found) { if (getCell(col, row).getType() != CellType.EMPTY) { found = true; } else { col--; } } // Only create entries for non-empty cells Cell[] cells = new Cell[col+1]; for (int i = 0; i <= col; i++) { cells[i] = getCell(i, row); } return cells; }
/** * Gets all the cells on the specified column * * @param col the column whose cells are to be returned * @return the cells on the specified column */ public Cell[] getColumn(int col) { // Find the last non-null cell boolean found = false; int row = numRows - 1; while (row >= 0 && !found) { if (getCell(col, row).getType() != CellType.EMPTY) { found = true; } else { row--; } } // Only create entries for non-empty cells Cell[] cells = new Cell[row+1]; for (int i = 0; i <= row; i++) { cells[i] = getCell(col, i); } return cells; }
/** * Gets all the cells on the specified row * * @param row the rows whose cells are to be returned * @return the cells on the given row */ public Cell[] getRow(int row) { // Find the last non-null cell boolean found = false; int col = numColumns - 1; while (col >= 0 && !found) { if (getCell(col, row).getType() != CellType.EMPTY) { found = true; } else { col--; } } // Only create entries for non-empty cells Cell[] cells = new Cell[col+1]; for (int i = 0; i <= col; i++) { cells[i] = getCell(i, row); } return cells; }
/** * Returns the cell for the specified location eg. "A4", using the * CellReferenceHelper * * @param loc the cell reference * @return the cell at the specified co-ordinates */ public Cell getCell(String loc) { return getCell(CellReferenceHelper.getColumn(loc), CellReferenceHelper.getRow(loc)); }
/** * Returns the cell for the specified location eg. "A4", using the * CellReferenceHelper * * @param loc the cell reference * @return the cell at the specified co-ordinates */ public Cell getCell(String loc) { return getCell(CellReferenceHelper.getColumn(loc), CellReferenceHelper.getRow(loc)); }
Cell c = getCell(h.getColumn(), h.getRow());
Cell c = getCell(h.getColumn(), h.getRow());