com.act365.sudoku
Class GridContainer

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended bycom.act365.awt.Container
              extended bycom.act365.sudoku.GridContainer
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class GridContainer
extends Container

The GridContainer class displays a Su Doku grid.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GridContainer(Grid grid)
          Creates a new GridContainer instance.
 
Method Summary
 int evaluate()
          Evaluates the complexity of the grid.
 java.awt.Dimension getBestSize()
          A GridContainer should display each square as 40x40 pixels.
 int getBoxesAcross()
          Returns number of boxes across one row of the Su Doku grid.
 int getBoxesDown()
          Returns number of boxes down one column of the Su Doku grid.
 int getComplexity()
          Returns the number of unwinds used to solve the grid as a measure of its complexity.
 int getHintValue()
          Returns hint value in the range [1,cellsInRow].
 int getHintX()
          Returns hint x-coordinate in the range [1,cellsInRow].
 int getHintY()
          Returns hint y-coordinate in the range [1,cellsInRow].
 double getSolveTime()
          Returns the time (in milliseconds) taken to complete the most recent solve.
 IStrategy getStrategy()
          Returns the currently selected stratey object.
 boolean hint()
          Solves the grid and returns the first step of the solution.
 void paste(java.lang.String s)
          Pastes data onto the grid.
 void reset()
          Resets the grid.
 void setBoxes(int boxesAcross, int boxesDown)
          Resizes the grid.
 void setGrid(Grid grid)
          Sets the underlying grid to be a clone of the given grid.
 void setStrategy(int strategyCode)
          Sets the strategy to be used to solve the grid.
 void shuffle()
          Shuffles the grid.
 void solve()
          Solves the grid.
 void startComposer(int filledCells)
          Composes a puzzle, with rotational symmetry and a unique solution, based upon the initial values in the grid.
 void stopComposer()
          Interrupts any ComposerThread that might have been started by startComposer().
 java.lang.String toString()
          A GridContainer returns a string representation of the underlying grid.
 void unsolve()
          Unsolves the grid (reverts its state to that prior to the most recent solve).
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, getAccessibleContext, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GridContainer

public GridContainer(Grid grid)
Creates a new GridContainer instance.

Method Detail

getBestSize

public java.awt.Dimension getBestSize()
A GridContainer should display each square as 40x40 pixels.


solve

public void solve()
Solves the grid.


evaluate

public int evaluate()
Evaluates the complexity of the grid. Establishes that just a single solution exists and, if so, calculates the number of thread unwinds used to solve the problem.

Returns:
number of solutions

hint

public boolean hint()
Solves the grid and returns the first step of the solution.

Returns:
whether a solution could be found

unsolve

public void unsolve()
Unsolves the grid (reverts its state to that prior to the most recent solve).


reset

public void reset()
Resets the grid.


shuffle

public void shuffle()
Shuffles the grid.


setGrid

public void setGrid(Grid grid)
Sets the underlying grid to be a clone of the given grid.

Parameters:
grid - new grid

setBoxes

public void setBoxes(int boxesAcross,
                     int boxesDown)
Resizes the grid.

Parameters:
boxesAcross - - number of boxes across one row of the Su Doku grid
boxesDown - - number of boxes down one column of the Su Doku grid

paste

public void paste(java.lang.String s)
Pastes data onto the grid.

Parameters:
s - data to be pasted, which should be in the form created by Copy

startComposer

public void startComposer(int filledCells)
Composes a puzzle, with rotational symmetry and a unique solution, based upon the initial values in the grid.

Parameters:
filledCells - - number of filled cells to appear in the puzzle

stopComposer

public void stopComposer()
Interrupts any ComposerThread that might have been started by startComposer().


getBoxesAcross

public int getBoxesAcross()
Returns number of boxes across one row of the Su Doku grid.


getBoxesDown

public int getBoxesDown()
Returns number of boxes down one column of the Su Doku grid.


getComplexity

public int getComplexity()
Returns the number of unwinds used to solve the grid as a measure of its complexity.


getSolveTime

public double getSolveTime()
Returns the time (in milliseconds) taken to complete the most recent solve.


getHintX

public int getHintX()
Returns hint x-coordinate in the range [1,cellsInRow].


getHintY

public int getHintY()
Returns hint y-coordinate in the range [1,cellsInRow].


getHintValue

public int getHintValue()
Returns hint value in the range [1,cellsInRow].


setStrategy

public void setStrategy(int strategyCode)
Sets the strategy to be used to solve the grid.

Parameters:
strategyCode - - strategy code as defined in Strategy class
See Also:
Strategy

getStrategy

public IStrategy getStrategy()
Returns the currently selected stratey object.


toString

public java.lang.String toString()
A GridContainer returns a string representation of the underlying grid.