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.event.AdjustmentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class GridContainer
extends Container
implements java.awt.event.AdjustmentListener

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
 void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt)
          Reacts to scrollbar presses.
 int evaluate()
          Evaluates the complexity of the grid.
 java.awt.Dimension getBestSize()
          Returns the best display size for a GridContainer.
 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.
 double getSolveTime()
          Returns the time taken to solve.
 LeastCandidatesHybrid getStrategy()
          Returns the current strategy.
 void paste(java.lang.String s)
          Pastes data onto the grid.
 void reset()
          Resets the grid.
 void setBoxes(int boxesAcross, int boxesDown)
          Resizes the drawn grid.
 void setGrid(Grid grid)
          Sets the underlying grid to be a clone of the given grid.
 void setSize(int boxesAcross, int boxesDown)
          Sets the size of the underlying 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).
 void unsolve(int move)
          Resets the grid to the partial solution prior to the given move.
 
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, 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()
Returns the best display size for a GridContainer.


solve

public void solve()
Solves the grid.


getSolveTime

public double getSolveTime()
Returns the time taken to solve.


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

unsolve

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


unsolve

public void unsolve(int move)
Resets the grid to the partial solution prior to the given move.


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

setSize

public void setSize(int boxesAcross,
                    int boxesDown)
Sets the size of the underlying grid.


setBoxes

public void setBoxes(int boxesAcross,
                     int boxesDown)
Resizes the drawn 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.


getStrategy

public LeastCandidatesHybrid getStrategy()
Returns the current strategy.


toString

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


adjustmentValueChanged

public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt)
Reacts to scrollbar presses.

Specified by:
adjustmentValueChanged in interface java.awt.event.AdjustmentListener