public void showAllCandidates() { for (int row = 0; row < grid.getCellsPerEdge(); row++) { for (int col = 0; col < grid.getCellsPerEdge(); col++) { showCandidates(row, col); } } notifyObservers(); }
public void solve() { boolean result; result = grid.solve(); if (result) { statusLine = "The Sudoku was solved successfully"; } else { statusLine = "Can not solve this Sudoku within " + grid.getSteps() + " steps"; } notifyObservers(); }
public void setValue(int row, int column, int value) { ICell cell = grid.getICell(row, column); if (cell.isUnSet()) { cell.setValue(value); undoManager.addEdit(new SetValueCommand(cell)); statusLine = "The cell " + cell.mkString() + " was successfully set"; } else { statusLine = "The cell " + cell.mkString() + " is already set"; } notifyObservers(); }
public void paste() { Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) { String input; try { input = (String) transferable.getTransferData(DataFlavor.stringFlavor); grid.parseStringToGrid(input); } catch (UnsupportedFlavorException e1) { statusLine = "Could not read from Clipboard"; } catch (IOException e1) { statusLine = "Could not read from Clipboard"; } } statusLine = "Pasted Sudoku"; notifyObservers(); }
public void reset() { grid.reset(); statusLine = "Sudoku was reset"; notifyObservers(); }
@Override public void parseStringToGrid(String gridString) { grid.parseStringToGrid(gridString); notifyObservers(); }
public boolean isCandidate(int row, int column, int candidate) { return grid.candidates(row, column).get(candidate); }
public boolean isShowCandidates(int row, int column) { return grid.getICell(row, column).isShowCandidates(); }
public boolean isHighlighted(int row, int column) { return grid.candidates(row, column).get(highlighted); }
public int getBlockSize() { return grid.getBlockSize(); }
public int blockAt(int row, int column) { return grid.blockAt(row, column); }
public int getCellsPerRow() { return grid.getCellsPerEdge(); }
public void showCandidates(int row, int column) { grid.getICell(row, column).toggleShowCandidates(); BitSet set = grid.candidates(row, column); statusLine = "Candidates at (" + row + "," + column + ") are " + set.toString(); notifyObservers(); }
public int getValue(int row, int column) { return grid.getICell(row, column).getValue(); }
public void create() { grid.create(); highlighted = 0; statusLine = "New Sudoku Puzzle created"; notifyObservers(); }
public boolean isSet(int row, int column) { return grid.getICell(row, column).isSet(); }
public String getGridString() { return grid.toString(); }
public void copy() { StringSelection gridString = new StringSelection(grid.toString("0")); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(gridString, null); statusLine = "Copied Sudoku"; notifyObservers(); }