1.1 --- a/src/de/uapcore/sudoku/Field.java Sat Jan 26 18:43:49 2013 +0100 1.2 +++ b/src/de/uapcore/sudoku/Field.java Sat Jan 26 19:34:31 2013 +0100 1.3 @@ -62,7 +62,6 @@ 1.4 1.5 @Override 1.6 public void paint(Graphics graphics) { 1.7 - super.paint(graphics); 1.8 final int w = getWidth(); 1.9 final int h = getHeight(); 1.10 final int cw = w / 9; 1.11 @@ -90,6 +89,7 @@ 1.12 } 1.13 1.14 graphics.drawImage(img, 0, 0, this); 1.15 + super.paintChildren(graphics); 1.16 } 1.17 1.18 public int getCellValue(int x, int y) { 1.19 @@ -126,4 +126,45 @@ 1.20 } 1.21 } 1.22 } 1.23 + 1.24 + public int[][] getSquare(int x, int y) { 1.25 + if (x < 0 || x > 2 || y < 0 || y > 2) { 1.26 + throw new IllegalArgumentException("Invalid square coordinates"); 1.27 + } 1.28 + int[][] square = new int[3][3]; 1.29 + 1.30 + for (int u = 0 ; u < 3 ; u++) { 1.31 + for (int v = 0 ; v < 3 ; v++) { 1.32 + square[u][v] = getCellValue(3*x+u, 3*y+v); 1.33 + } 1.34 + } 1.35 + 1.36 + return square; 1.37 + } 1.38 + 1.39 + public int[] getRow(int y) { 1.40 + if (y < 0 || y > 8) { 1.41 + throw new IllegalArgumentException("Invalid row number"); 1.42 + } 1.43 + int row[] = new int[9]; 1.44 + 1.45 + for (int x = 0 ; x < 9 ; x++) { 1.46 + row[x] = getCellValue(x, y); 1.47 + } 1.48 + 1.49 + return row; 1.50 + } 1.51 + 1.52 + public int[] getColumn(int x) { 1.53 + if (x < 0 || x > 8) { 1.54 + throw new IllegalArgumentException("Invalid column number"); 1.55 + } 1.56 + int column[] = new int[9]; 1.57 + 1.58 + for (int y = 0 ; y < 9 ; y++) { 1.59 + column[y] = getCellValue(x, y); 1.60 + } 1.61 + 1.62 + return column; 1.63 + } 1.64 }