tipgame.util
Class RectangularGridIterator

java.lang.Object
  extended by tipgame.util.RectangularGridIterator
All Implemented Interfaces:
java.util.Iterator

public class RectangularGridIterator
extends java.lang.Object
implements java.util.Iterator

iterates over the bounds of a rectangle for a given grid.

Author:
Jam Jenkins

Field Summary
private  java.awt.geom.Rectangle2D.Double bounds
          the size of the rectangle to contain the points
private  java.awt.Point pointIndex
          the index of the current point in the iterator
private  java.awt.Dimension points
          the number of rows and columns of points to create
 
Constructor Summary
RectangularGridIterator(java.awt.geom.Rectangle2D.Double bound, java.awt.Dimension elements)
          constructs the iterator over the bounds for a given number of rows and columns.
 
Method Summary
 boolean hasNext()
           
 java.lang.Object next()
          gets the points staring at the top left going left to right, then top to bottom
 void remove()
          goes to the next point
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bounds

private java.awt.geom.Rectangle2D.Double bounds
the size of the rectangle to contain the points


points

private java.awt.Dimension points
the number of rows and columns of points to create


pointIndex

private java.awt.Point pointIndex
the index of the current point in the iterator

Constructor Detail

RectangularGridIterator

public RectangularGridIterator(java.awt.geom.Rectangle2D.Double bound,
                               java.awt.Dimension elements)
constructs the iterator over the bounds for a given number of rows and columns. The points given by the iterator are the center positions of the cells specified by elements.

Parameters:
bound - how large an area is available for the cells
elements - the number of rows and columns in bounds
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator
Returns:
true if not all cell centers have been iterated over, false otherwise
See Also:
Iterator.hasNext()

next

public java.lang.Object next()
gets the points staring at the top left going left to right, then top to bottom

Specified by:
next in interface java.util.Iterator
Returns:
the next point
See Also:
Iterator.next()

remove

public void remove()
goes to the next point

Specified by:
remove in interface java.util.Iterator
See Also:
Iterator.remove()