net.sf.freecol.common.model
Class Map.CircleIterator

java.lang.Object
  extended by net.sf.freecol.common.model.Map.MapIterator
      extended by net.sf.freecol.common.model.Map.CircleIterator
All Implemented Interfaces:
java.util.Iterator<Map.Position>
Enclosing class:
Map

public final class Map.CircleIterator
extends Map.MapIterator

An interator returning positions in a spiral starting at a given center tile. The center tile is never included in the positions returned, and all returned positions are valid.

See Also:
Map.Position

Field Summary
private  int currentRadius
           
private  int n
           
private  Map.Position nextPosition
           
private  int radius
           
 
Fields inherited from class net.sf.freecol.common.model.Map.MapIterator
directions
 
Constructor Summary
Map.CircleIterator(Map.Position center, boolean isFilled, int radius)
          The constructor to use.
 
Method Summary
private  void determineNextPosition()
          Finds the next position.
 int getCurrentRadius()
          Returns the current radius of the circle.
 boolean hasNext()
          Determine if the iterator has another position in it.
 Map.Position nextPosition()
          Obtains the next position.
 
Methods inherited from class net.sf.freecol.common.model.Map.MapIterator
next, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

radius

private int radius

currentRadius

private int currentRadius

nextPosition

private Map.Position nextPosition

n

private int n
Constructor Detail

Map.CircleIterator

public Map.CircleIterator(Map.Position center,
                          boolean isFilled,
                          int radius)
The constructor to use.

Parameters:
center - The center of the circle
isFilled - True to get all of the positions within the circle
radius - The radius of the circle
Method Detail

getCurrentRadius

public int getCurrentRadius()
Returns the current radius of the circle.

Returns:
The distance from the center tile this CircleIterator was initialized with.

determineNextPosition

private void determineNextPosition()
Finds the next position.


hasNext

public boolean hasNext()
Determine if the iterator has another position in it.

Returns:
true of there is another position and false otherwise.

nextPosition

public Map.Position nextPosition()
Obtains the next position.

Specified by:
nextPosition in class Map.MapIterator
Returns:
The next position. This position is guaranteed to be valid.