|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.ascape.model.space.CollectionSpace org.ascape.model.space.Discrete org.ascape.model.space.Array org.ascape.model.space.Array2DBase
public abstract class Array2DBase
The Class Array2DBase.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.ascape.model.space.CollectionSpace |
---|
CollectionSpace.ClosestDataPoint, CollectionSpace.ConditionalIterator, CollectionSpace.CSIterator, CollectionSpace.CSMutableIterator, CollectionSpace.ListMutableRandomIterator, CollectionSpace.ListRandomIterator, CollectionSpace.MutableSubIterator, CollectionSpace.SubIterator |
Field Summary | |
---|---|
protected Node[][] |
cells
The actual 2D array of agents. |
protected int |
currentPositionInRank
The current position within the current rank for this enumeration. |
protected int |
currentRank
The current distance from the origin for this enumeration. |
protected boolean |
nearnessLineOfSight
Should movement or line of sight be used for interpreting 'nearness'? Default is line of sight for the moment, but will change as soon as code is completed. |
protected int[] |
order
The order. |
static int |
rankLimit
The rank limit. |
protected int[][][] |
relativeCoordinates
The relative coordinates. |
protected static double[] |
relativeCoordinatesRankDistance
The relative coordinates rank distance. |
protected static int[] |
relativeCoordinatesRankLengths
The relative coordinates rank lengths. |
protected static int[][][] |
relativeCoordinatesTemplate
The Constant relativeCoordinatesTemplate. |
protected static int[] |
sumOfCoordinatesWithinRank
The sum of coordinates within rank. |
Fields inherited from class org.ascape.model.space.Array |
---|
CACHE_RESULTS |
Fields inherited from class org.ascape.model.space.Discrete |
---|
performanceWarning |
Fields inherited from class org.ascape.model.space.CollectionSpace |
---|
collection, ESTIMATED_MAXIMUM_SIZE, extent, geometry |
Constructor Summary | |
---|---|
Array2DBase()
Constructs a base 2-dimensional array space of provided extent. |
|
Array2DBase(CoordinateDiscrete extent)
Constructs a base 2-dimensional array space of provided extent. |
Method Summary | |
---|---|
boolean |
add(java.lang.Object o)
Adds the supplied object (agent) to this collection. |
boolean |
addAll(java.util.Collection c)
Adds all of the agent in the specified collection to the end of the context. |
void |
clear()
Removes all agents from the context. |
java.lang.Object |
clone()
Overides the clone method to do a deep clone of member state so that such state will not be shared between scapes. |
void |
construct()
Contructs the basic space structure. |
boolean |
contains(java.lang.Object o)
Returns true if the context collection contains the object (agent.) |
boolean |
containsAll(java.util.Collection c)
Returns true if this collection contains all of agents in the specified collection. |
Node |
findCellAway(Node originCell,
Node targetCell)
Returns the cell within immediate neighborhood furthest away from the requestd cell. |
Node[] |
findCells(Conditional condition)
Finds cells within the space that meet some condition. |
Node[] |
findCells(Conditional condition,
int _x,
int _y,
int width,
int height)
Finds cells within the specified space that meet some condition. |
Node |
findCellToward(Node originCell,
Node targetCell)
Returns the next cell within immediate neighborhood toward the requested cell. |
Location |
findRandom()
Returns a cell randomly selected from the lattice. |
Location |
findRandom(int x,
int y,
int width,
int height)
Returns a random unoccupied discrete location in the space given with the lattice. |
Location |
findRandom(Node cell,
int x,
int y,
int width,
int height)
Returns a random unoccupied discrete location in the space given with the lattice. |
Coordinate |
findRandomCoordinate()
Returns a coordinate randomly selected from the lattice's space. |
Location |
findRandomRelative(Node cell,
int x,
int y,
int width,
int height)
Returns a random unoccupied discrete location in the space given with the lattice. |
Node |
findRandomUnoccupied(int x,
int y,
int width,
int height)
Returns a random unoccupied discrete location in the space given with the lattice. |
Location |
findRelative(Location location,
Coordinate coordinate)
Locates a cell based on a relative reference. |
java.util.List |
findWithinEuclidian(Coordinate origin,
boolean includeSelf,
double dist)
Find within euclidian. |
java.util.List |
findWithinMoore(Coordinate origin,
boolean includeSelf,
double distanceDouble)
Find within moore. |
java.util.List |
findWithinVonNeumann(Coordinate origin,
boolean includeSelf,
double dist)
Find within von neumann. |
java.util.List |
findWithinVonNeumannLineOfSight(Coordinate origin,
boolean includeSelf,
double dist)
Find within von neumann line of sight. |
java.util.List |
findWithinVonNeumannMovement(Coordinate origin,
boolean includeSelf,
double distance)
Find within von neumann movement. |
Location |
get(Coordinate coordinate)
Returns the cell existing at the specified coordinate. |
Node |
get(int xPosition,
int yPosition)
Returns the cell existing at the specified integer coordinates. |
Node[] |
getCellsNearVonNeumannLineOfSight(Node origin,
boolean includeSelf,
int distance)
Deprecated. |
Node[] |
getCellsNearVonNeumannMovement(Node origin,
boolean includeSelf,
int distance)
Deprecated. |
int |
getSize()
Returns the size, or number of cells, (the product of all extents) of this two-dimensional array. |
int |
getXSize()
Returns the horizontal span of the array. |
int |
getYSize()
Returns the vertical span of the array. |
void |
initialize()
Initializes the space, copying a set of relative coordinates for use, and ensuring that the ordering used for random draws starts consistently. |
boolean |
isEmpty()
Are there no agents in this context?. |
boolean |
isMutable()
Is the context mutable, that is, can it change its structure at runtime? Returns true for this collection. |
boolean |
isNearnessLineOfSight()
Should 'nearness' be interpreted as where an agent can move, or where the agent has line of sight? This is important for von Neumann geometry, but irrelevant otherwise. |
boolean |
isValid(CoordinateDiscrete coordinate)
Determines whether the supplied coordinate is valid in the space. |
boolean |
isValid(int xPosition,
int yPosition)
Determines whether the supplied position is valid in the space. |
java.util.Iterator |
iterator()
Returns an iterator across all agents in this context. |
void |
populate()
Populates the space with clones of the prototype agent. |
void |
randomizeCallingOrder()
Randomizes the lookup used to determine calling order for random order execution of rules. |
protected void |
randomizeRank(int rank)
Randomizes the coordinates within the specified rank. |
boolean |
remove(java.lang.Object o)
Removes the supplied object (agent) from this collection. |
boolean |
removeAll(java.util.Collection c)
Removes all of the agents contained in the collection. |
boolean |
retainAll(java.util.Collection c)
Retains only the elements in the context that are in the specified collection. |
ResetableIterator |
safeIterator()
Returns a context iterator across all objects in this context. |
ResetableIterator |
safeIterator(int start,
int limit)
Safe iterator. |
RandomIterator |
safeRandomIterator()
Returns a context iterator across all agents in random order. |
void |
set(Coordinate coordinate,
Location cell)
Sets the cell existing at the specified coordinate. |
void |
set(int xPosition,
int yPosition,
Location cell)
Sets the cell existing at the specified coordinate. |
void |
setExtent(Coordinate extent)
Sets the size of the space. |
void |
setExtent(int xSize,
int ySize)
Sets the size of the space. |
void |
setGeometry(Geometry geometry)
Sets the geometry of this space. |
void |
setNearnessLineOfSight(boolean nearnessLineOfSight)
Returns wether line of sight is being used as the interpretation for von Neumann geometry nearness. |
int |
size()
Returns the number of agents in the context. |
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this collection in proper sequence. |
java.lang.Object[] |
toArray(java.lang.Object[] a)
Returns an array containing the current agents in this context; the runtime type is specified by the passed array. |
java.util.List |
toList()
|
Methods inherited from class org.ascape.model.space.Array |
---|
findNearest, findNearestMatchRank, findRandomMatchInRank, findWithin, findWithinImpl, replace, swap |
Methods inherited from class org.ascape.model.space.CollectionSpace |
---|
add, calculateDistance, conditionalIterator, conditionalIterator, countWithin, createOrder, createSpatialConditional, deleteSweep, filter, find, findMaximum, findMaximum, findMaximumWithin, findMinimum, findMinimum, findMinimumWithin, findNearest, findRandom, findRandom, findRandom, findRandomWithin, getContext, getExtent, getGeometry, getRandom, hasWithin, isDeleteSweepNeeded, isPeriodic, iteratorCount, iteratorToList, moveAway, moveToward, newLocation, newLocation, randomInRange, randomInRange, randomIs, randomizeOrder, randomToLimit, safeIterators, setContext, setExtent, setPeriodic, setRandom, setSize, withinIterator |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
equals, hashCode |
Field Detail |
---|
protected Node[][] cells
protected int[] order
protected boolean nearnessLineOfSight
protected static final int[][][] relativeCoordinatesTemplate
protected int[][][] relativeCoordinates
protected static int[] relativeCoordinatesRankLengths
protected static double[] relativeCoordinatesRankDistance
protected static int[] sumOfCoordinatesWithinRank
public static int rankLimit
protected int currentRank
protected int currentPositionInRank
Constructor Detail |
---|
public Array2DBase()
public Array2DBase(CoordinateDiscrete extent)
extent
- a coordinate describing the size of this spaceMethod Detail |
---|
public java.lang.Object clone()
clone
in interface Space
clone
in class CollectionSpace
public void construct()
construct
in interface Space
construct
in class CollectionSpace
public void populate()
populate
in interface Space
populate
in class CollectionSpace
public void initialize()
initialize
in interface Space
initialize
in class CollectionSpace
public void setGeometry(Geometry geometry)
setGeometry
in class CollectionSpace
geometry
- the basic geometry of this spacepublic void setExtent(Coordinate extent)
setExtent
in interface Space
setExtent
in class CollectionSpace
extent
- a coordinate at the maximum extentpublic void setExtent(int xSize, int ySize)
xSize
- the horizontal size (width) of the spaceySize
- the vertical size (height) of the spacepublic void randomizeCallingOrder()
public java.util.Iterator iterator()
CollectionSpace
iterator
in interface java.lang.Iterable
iterator
in interface java.util.Collection
iterator
in class CollectionSpace
public ResetableIterator safeIterator()
CollectionSpace
safeIterator
in interface Space
safeIterator
in class CollectionSpace
public ResetableIterator safeIterator(int start, int limit)
Space
safeIterator
in interface Space
safeIterator
in class CollectionSpace
start
- the startlimit
- the limit
public RandomIterator safeRandomIterator()
CollectionSpace
safeRandomIterator
in interface Space
safeRandomIterator
in class CollectionSpace
public boolean isMutable()
CollectionSpace
isMutable
in interface Space
isMutable
in class CollectionSpace
public int getSize()
getSize
in interface Space
getSize
in class Discrete
public int getXSize()
public int getYSize()
public Node[] findCells(Conditional condition)
condition
- the condition that found cell must meet
public Node[] findCells(Conditional condition, int _x, int _y, int width, int height)
condition
- the condition that found cell must meet_x
- the leftmost cell location_y
- the topmost cell locationwidth
- the number of vertical cellsheight
- the number of horizontal cells
public Location findRandom()
findRandom
in interface Space
findRandom
in class CollectionSpace
public Location findRandom(int x, int y, int width, int height)
x
- the leftmost cell locationy
- the top cell locationwidth
- the number of vertical cellsheight
- the number of horizontal cells
public final Location findRandomRelative(Node cell, int x, int y, int width, int height)
cell
- a cell to exclude from search (typically origin)x
- the leftmost cell locationy
- the top cell locationwidth
- the number of vertical cellsheight
- the number of horizontal cells
public final Location findRandom(Node cell, int x, int y, int width, int height)
cell
- a cell to exclude from search (typically origin)x
- the leftmost cell locationy
- the top cell locationwidth
- the number of vertical cellsheight
- the number of horizontal cells
public Node findRandomUnoccupied(int x, int y, int width, int height)
x
- the leftmost cell locationy
- the top cell locationwidth
- the number of vertical cellsheight
- the number of horizontal cells
public Coordinate findRandomCoordinate()
findRandomCoordinate
in interface Space
findRandomCoordinate
in class CollectionSpace
public boolean isValid(CoordinateDiscrete coordinate)
coordinate
- the position to check
public Location findRelative(Location location, Coordinate coordinate)
findRelative
in interface Relative
location
- the origin locationcoordinate
- the delta from location
public Location get(Coordinate coordinate)
get
in interface Space
get
in class CollectionSpace
coordinate
- a coordinate asserted to be within the space
isValid(org.ascape.model.space.CoordinateDiscrete)
public void set(Coordinate coordinate, Location cell)
set
in interface Space
set
in class CollectionSpace
coordinate
- the coordinatecell
- the cellpublic void set(int xPosition, int yPosition, Location cell)
xPosition
- the x positionyPosition
- the y positioncell
- the cellpublic boolean isValid(int xPosition, int yPosition)
xPosition
- the x position to checkyPosition
- the y position to check
public Node get(int xPosition, int yPosition)
xPosition
- the x positionyPosition
- the y position
public boolean add(java.lang.Object o)
CollectionSpace
add
in interface java.util.Collection
add
in class CollectionSpace
o
- the a
public boolean addAll(java.util.Collection c)
CollectionSpace
addAll
in interface java.util.Collection
addAll
in class CollectionSpace
c
- collection whose agents are to be added to the context
public void clear()
CollectionSpace
clear
in interface java.util.Collection
clear
in class CollectionSpace
public boolean contains(java.lang.Object o)
CollectionSpace
contains
in interface java.util.Collection
contains
in class CollectionSpace
o
- the agent to search for
public boolean containsAll(java.util.Collection c)
CollectionSpace
containsAll
in interface java.util.Collection
containsAll
in class CollectionSpace
c
- collection of agents to be found in the context
public boolean isEmpty()
CollectionSpace
isEmpty
in interface java.util.Collection
isEmpty
in class CollectionSpace
public boolean remove(java.lang.Object o)
CollectionSpace
remove
in interface java.util.Collection
remove
in class CollectionSpace
o
- the agent to be removed
public boolean removeAll(java.util.Collection c)
CollectionSpace
removeAll
in interface java.util.Collection
removeAll
in class CollectionSpace
c
- collection whose agents are to be added to the context
public boolean retainAll(java.util.Collection c)
CollectionSpace
retainAll
in interface java.util.Collection
retainAll
in class CollectionSpace
c
- collection whose agents are to be retained in the context
public int size()
CollectionSpace
size
in interface java.util.Collection
size
in class CollectionSpace
public java.lang.Object[] toArray()
CollectionSpace
toArray
in interface java.util.Collection
toArray
in class CollectionSpace
Arrays.asList(java.lang.Object[])
public java.util.List toList()
toList
in class CollectionSpace
public java.lang.Object[] toArray(java.lang.Object[] a)
CollectionSpace
toArray
in interface java.util.Collection
toArray
in class CollectionSpace
a
- the array to copy the agents to
public boolean isNearnessLineOfSight()
public void setNearnessLineOfSight(boolean nearnessLineOfSight)
nearnessLineOfSight
- should line of sight be used as the interpreation for
'nearness'isNearnessLineOfSight()
protected void randomizeRank(int rank)
rank
- the rank to shufflepublic java.util.List findWithinMoore(Coordinate origin, boolean includeSelf, double distanceDouble)
origin
- the originincludeSelf
- the include selfdistanceDouble
- the distance double
public java.util.List findWithinVonNeumann(Coordinate origin, boolean includeSelf, double dist)
origin
- the originincludeSelf
- the include selfdist
- the dist
public final Node[] getCellsNearVonNeumannMovement(Node origin, boolean includeSelf, int distance)
origin
- the agent to find cells nearincludeSelf
- should supplied agent be included in the return setdistance
- the distance to form centralCells to return cells
public java.util.List findWithinVonNeumannMovement(Coordinate origin, boolean includeSelf, double distance)
origin
- the originincludeSelf
- the include selfdistance
- the distance
public final Node[] getCellsNearVonNeumannLineOfSight(Node origin, boolean includeSelf, int distance)
origin
- the agent to find cells neardistance
- the distance to form centralCells to return cellsincludeSelf
- should supplied agent be included in the return set
public java.util.List findWithinVonNeumannLineOfSight(Coordinate origin, boolean includeSelf, double dist)
origin
- the originincludeSelf
- the include selfdist
- the dist
public java.util.List findWithinEuclidian(Coordinate origin, boolean includeSelf, double dist)
origin
- the originincludeSelf
- the include selfdist
- the dist
public Node findCellToward(Node originCell, Node targetCell)
findCellToward
in class Discrete
originCell
- the current celltargetCell
- the cell that we are moving toward
public Node findCellAway(Node originCell, Node targetCell)
findCellAway
in class Discrete
originCell
- the current celltargetCell
- the cell that we are moving toward
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |