20 package net.sf.gridarta.model.mapmodel;
22 import java.awt.Point;
23 import java.util.Iterator;
24 import java.util.NoSuchElementException;
29 import org.jetbrains.annotations.NotNull;
30 import org.jetbrains.annotations.Nullable;
83 if (direction != -1 && direction != +1) {
84 throw new IllegalArgumentException();
88 final Size2D mapSize = mapModel.getMapArchObject().getMapSize();
92 point = start.x + start.y *
mapWidth;
93 }
else if (direction > 0) {
96 point = mapWidth * mapHeight - 1;
98 remainingMapSquares = mapWidth *
mapHeight;
105 public void remove() {
106 throw new UnsupportedOperationException();
111 return remainingMapSquares > 0;
116 if (remainingMapSquares <= 0) {
117 throw new NoSuchElementException();
119 remainingMapSquares--;
133 }
else if (point >= mapWidth * mapHeight) {
int remainingMapSquares
The number of remaining map square to return from next().
MapSquare< G, A, R > next()
final MapModel< G, A, R > mapModel
The MapModel to iterate over.
final int mapWidth
The mapModel's map width.
final int direction
The direction to iterate:
Base package of all Gridarta classes.
Reflects a game object (object on a map).
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
Get the square at a specified location.
GameObjects are the objects based on Archetypes found on maps.
int getWidth()
Returns the width of the area.
MapSquareIterator(@NotNull final MapModel< G, A, R > mapModel, @Nullable final Point start, final int direction, final boolean skipFirst)
Creates a new instance.
final int mapHeight
The mapModel's map height.
int point
Index of current map square.
int getHeight()
Returns the height of the area.
Interface for MapArchObjects.
void nextMapSquare()
Updates point to the next map square.
The class Size2D represents a 2d rectangular area.
Iterator for iterating over all squares of a model.