Class IterationController

java.lang.Object
  |
  +--edu.kzoo.grid.gui.GridAppController
        |
        +--edu.kzoo.grid.gui.ActiveGridAppController
              |
              +--IterationController

public class IterationController
extends edu.kzoo.grid.gui.ActiveGridAppController

Grid Iterator Lab:
The IterationController class provides the methods for stepping through a grid using one of a number of iterators (which must be registered using the register method). It places colored blocks in the cells of the grid as it goes to illustrate the traversal.

Version:
1 January 2003
Author:
Alyce Brady

Constructor Summary
IterationController()
           
 
Method Summary
 void empty(edu.kzoo.grid.BoundedGrid grid)
          Empties the grid.
static java.util.List getAlgNames()
          Gets the list of registered algorithm names.
static GridIterator getIterator(java.lang.String name, edu.kzoo.grid.BoundedGrid grid)
          Constructs the iterator with the specified name.
 boolean hasReachedStoppingState()
          Determines whether the iteration has reached a desired stopping state.
static void register(java.lang.String name, java.lang.Class iteratorClass)
          Registers the specified class with a name.
 void startIteration(java.lang.String name, edu.kzoo.grid.BoundedGrid grid, java.awt.Color color)
          Starts the iteration with the given name through the specified grid.
 void step()
           
 
Methods inherited from class edu.kzoo.grid.gui.GridAppController
getGrid, restart, setGrid
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IterationController

public IterationController()
Method Detail

register

public static void register(java.lang.String name,
                            java.lang.Class iteratorClass)
Registers the specified class with a name.

Parameters:
name - name (button label) of traversal or drawing algorithm
iteratorClass - class that implements the associated iterator

getAlgNames

public static java.util.List getAlgNames()
Gets the list of registered algorithm names.

Returns:
name (button label) of traversal or drawing algorithm

getIterator

public static GridIterator getIterator(java.lang.String name,
                                       edu.kzoo.grid.BoundedGrid grid)
Constructs the iterator with the specified name.

Parameters:
name - name of traversal or drawing algorithm
Returns:
iterator that traverses in the specified order

startIteration

public void startIteration(java.lang.String name,
                           edu.kzoo.grid.BoundedGrid grid,
                           java.awt.Color color)
Starts the iteration with the given name through the specified grid.

Parameters:
name - name of the iteration technique to use
grid - grid through which to iterate
color - color to use to mark the traversal

step

public void step()
Overrides:
step in class edu.kzoo.grid.gui.ActiveGridAppController

hasReachedStoppingState

public boolean hasReachedStoppingState()
Determines whether the iteration has reached a desired stopping state. Will return true if the traversal has finished or if it appears to be in an unproductive loop (it has visited more locations than exist in the grid).

Overrides:
hasReachedStoppingState in class edu.kzoo.grid.gui.GridAppController
Returns:
true if the application should stop

empty

public void empty(edu.kzoo.grid.BoundedGrid grid)
Empties the grid.

Parameters:
grid - grid to empty