diff -r b8588e318001 -r 8ddf4af937d7 src/de/uapcore/sudoku/Field.java --- a/src/de/uapcore/sudoku/Field.java Sat Jan 26 18:43:49 2013 +0100 +++ b/src/de/uapcore/sudoku/Field.java Sat Jan 26 19:34:31 2013 +0100 @@ -62,7 +62,6 @@ @Override public void paint(Graphics graphics) { - super.paint(graphics); final int w = getWidth(); final int h = getHeight(); final int cw = w / 9; @@ -90,6 +89,7 @@ } graphics.drawImage(img, 0, 0, this); + super.paintChildren(graphics); } public int getCellValue(int x, int y) { @@ -126,4 +126,45 @@ } } } + + public int[][] getSquare(int x, int y) { + if (x < 0 || x > 2 || y < 0 || y > 2) { + throw new IllegalArgumentException("Invalid square coordinates"); + } + int[][] square = new int[3][3]; + + for (int u = 0 ; u < 3 ; u++) { + for (int v = 0 ; v < 3 ; v++) { + square[u][v] = getCellValue(3*x+u, 3*y+v); + } + } + + return square; + } + + public int[] getRow(int y) { + if (y < 0 || y > 8) { + throw new IllegalArgumentException("Invalid row number"); + } + int row[] = new int[9]; + + for (int x = 0 ; x < 9 ; x++) { + row[x] = getCellValue(x, y); + } + + return row; + } + + public int[] getColumn(int x) { + if (x < 0 || x > 8) { + throw new IllegalArgumentException("Invalid column number"); + } + int column[] = new int[9]; + + for (int y = 0 ; y < 9 ; y++) { + column[y] = getCellValue(x, y); + } + + return column; + } }