protected void setGrid() {
        String line;
        int count = 0;
        
        // update geometry
        this.updateDataSize();

        grid = new DataGridCel[numberOfRows][numberOfCols + 1];
        LineScanner scan = new LineScanner(dataBuffer.toString());

        for (int r = 0; r < numberOfRows; r++) {
            if (scan.hasNext()) {
                line = scan.nextLine();
            } else {
                line = new String();
            }

            for (int c = 0; c < numberOfCols; c++) {
                if (c < line.length()) {
                    grid[r][c] = new DataGridCel(line.charAt(c), count);
                    count++;
                } else {
                    if (r == (numberOfRows - 1) && c > 0 && c == line.length()) {
                        grid[r][c] = new DataGridCel(count);
                    } else {
                        grid[r][c] = new DataGridCel(-1);
                    }
                }
            }
        }
    }