|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.util.AbstractCollection
jas.space.Grid
jas.space.ObjGrid
public class ObjGrid
A bidimensional grid containing one object per cell.
Title: JAS
Description: Java Agent-based Simulation library
Copyright (C) 2002 Michele Sonnessa
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
| Constructor Summary | |
|---|---|
ObjGrid(Grid grid)
Create a copy of the given grid. |
|
ObjGrid(int xSize,
int ySize)
Create a grid with given size. |
|
| Method Summary | |
|---|---|
boolean |
add(java.lang.Object o)
Add an object implementing IGridPosition interface to the grid. |
boolean |
addGridPosition(IGridPosition object)
Add an object implementing IGridPosition interface to the grid. |
void |
clear()
Set all cells to the null value. |
int |
countObjectsAt(int x,
int y)
Returns the number of objects allocated in cell (x,y). |
java.lang.Object |
get(int x,
int y)
Return the object stored at the given position. |
java.lang.Object[][] |
getMatrix()
Return the matrix of objects representing the grid. |
java.lang.Object[] |
getMooreNeighbors(int x,
int y)
Gets the Moore neighbors of the specified coordinate. doubles are returned by row starting with the "NW corner" and ending with the "SE corner." |
java.lang.Object[] |
getMooreNeighbors(int x,
int y,
int xExtent,
int yExtent)
Gets the extended Moore neighbors of the specified coordinate. |
java.lang.Object[] |
getVonNeumannNeighbors(int x,
int y)
Gets the von Neumann neighbors of the specified coordinate. |
java.lang.Object[] |
getVonNeumannNeighbors(int x,
int y,
int xExtent,
int yExtent)
Gets the extended von Neumann neighbors of the specified coordinate. |
boolean |
moveGridPosition(IGridPosition object,
int destinationX,
int destinationY)
Move a IGridPosition object from its current position to the specified destination, only if the destination cell is empty. |
boolean |
removeGridPosition(IGridPosition object)
Remove the IGridPosition object from the grid. |
void |
set(int x,
int y,
java.lang.Object obj)
Put the given object at the given position. |
int |
size()
Return the number of objects stored into the grid. |
void |
swapPositions(int x1,
int y1,
int x2,
int y2)
Swap the content of the (x1, y1) and (x2, y2) cells of the grid. |
| Methods inherited from class jas.space.Grid |
|---|
boundX, boundY, equals, getMooreNeighborsPositions, getVonNeumannNeighborsPositions, getXSize, getYSize, gridIterator, iterator, reflectX, reflectY, torusX, torusY, toString |
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
| Methods inherited from class java.lang.Object |
|---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface jas.space.IObjGrid |
|---|
boundX, boundY, getXSize, getYSize, reflectX, reflectY, torusX, torusY |
| Methods inherited from interface java.util.Collection |
|---|
hashCode |
| Constructor Detail |
|---|
public ObjGrid(Grid grid)
grid - The source grid.
public ObjGrid(int xSize,
int ySize)
xSize - The width of the grid.ySize - The height of the grid.| Method Detail |
|---|
public boolean add(java.lang.Object o)
add in interface java.util.Collectionadd in class java.util.AbstractCollectiono - The IGridPosition object to be added.
public boolean addGridPosition(IGridPosition object)
addGridPosition in interface IObjGridobject - The IGridPosition object to be added.
public void clear()
clear in interface java.util.Collectionclear in class Grid
public int countObjectsAt(int x,
int y)
Grid
countObjectsAt in interface IObjGridcountObjectsAt in class Gridx - The x coordinate.y - The y coordinate.
public java.lang.Object get(int x,
int y)
get in class Gridx - The x coordinate.y - The y coordinate.
public java.lang.Object[][] getMatrix()
public java.lang.Object[] getMooreNeighbors(int x,
int y)
x - the x coordinate of the objecty - the y coordinate of the object
public java.lang.Object[] getMooreNeighbors(int x,
int y,
int xExtent,
int yExtent)
x - the x coordinate of the objecty - the y coordinate of the objectxExtent - the extension of the neighborhood in the x directionyExtent - the extension of the neighborhood in the y direction
public java.lang.Object[] getVonNeumannNeighbors(int x,
int y)
x - the x coordinate of the objecty - the y coordinate of the object
public java.lang.Object[] getVonNeumannNeighbors(int x,
int y,
int xExtent,
int yExtent)
x - the x coordinate of the objecty - the y coordinate of the objectxExtent - the extension of the neighborhood in the x directionyExtent - the extension of the neighborhood in the y direction
public boolean moveGridPosition(IGridPosition object,
int destinationX,
int destinationY)
moveGridPosition in interface IObjGriddestinationX - The x destination coordinate.destinationY - The y destination coordinate.object - An object implementing IGridPosition interface.
public boolean removeGridPosition(IGridPosition object)
removeGridPosition in interface IObjGridobject - The IGridPosition object to be removed.
public void set(int x,
int y,
java.lang.Object obj)
set in class Gridx - The x coordinate.y - The y coordinate.obj - The object to be stored at the (x, y) cell.public int size()
size in interface java.util.Collectionsize in class Grid
public void swapPositions(int x1,
int y1,
int x2,
int y2)
swapPositions in class Gridx1 - The x coordinate for the first cell.y1 - The y coordinate for the first cell.x2 - The x coordinate for the second cell.y2 - The y coordinate for the second cell.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||