public class Grid2D extends Space2D
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_NAME
The default ID for this space.
|
static String |
NEIGHBORHOOD_MOORE
The moore neighborhood.
|
static String |
NEIGHBORHOOD_VON_NEUMANN
The von neumann neighborhood.
|
static String |
PROPERTY_NEIGHBORHOOD
The neighborhood property.
|
BORDER_STRICT, BORDER_TORUS, PROPERTY_BORDER, PROPERTY_POSITION
Constructor and Description |
---|
Grid2D()
Creates a new
ContinuousSpace2D with the default name. |
Grid2D(IVector2 areasize)
Creates a new
ContinuousSpace2D with the default name. |
Grid2D(Object name,
IVector2 areasize)
Creates a new
ContinuousSpace2D with a special ID. |
Modifier and Type | Method and Description |
---|---|
IVector1 |
calculateDistance(IVector1 dx,
IVector1 dy)
Calculate the distance in the space.
|
void |
destroySpaceObject(Object id)
Destroys an object in this space.
|
IVector2 |
getEmptyGridPosition()
Get an empty position in the grid.
|
Set |
getNearObjects(IVector2 position,
IVector1 distance,
String type)
Retrieve all objects in the distance for a position.
|
String |
getNeighborhood()
Get the neighborhood.
|
IVector1 |
getShortestDirection(IVector1 pos1,
IVector1 pos2,
boolean isx)
Get the shortest (direct) direction between two coordinates.
|
Collection |
getSpaceObjectsByGridPosition(IVector2 position,
Object type)
Get all SimObjects from a specific type at a specific grid position
|
void |
initSpaceObject(ISpaceObject ret)
Init an object in this space.
|
void |
setAreaSize(IVector2 areasize)
Set the area size.
|
void |
setPosition(Object id,
IVector2 pos)
Set the position of an object.
|
addSpaceObjectType, adjustPosition, disableKdTree, enableKdTree, getAreaSize, getBorderMode, getDistance, getDistance, getNearestObject, getNearObjects, getNearObjects, getNearObjects, getRandomPosition, getSpaceObjects
addAvatarMappings, addDataConsumer, addDataProvider, addDataView, addDataViewMapping, addEnvironmentListener, addInitialAvatar, addObjectTaskType, addPerceptGenerator, addPerceptProcessor, addPerceptType, addSpaceAction, addSpaceProcessType, addTaskListener, componentAdded, componentRemoved, createObjectTask, createPercept, createSpaceObject, createSpaceObjectZombie, createSpaceProcess, getAvatar, getAvatar, getAvatars, getClassLoader, getComponentActionList, getComponents, getDataConsumer, getDataConsumers, getDataProvider, getDataView, getDataViews, getExternalAccess, getFetcher, getOwner, getPerceptList, getPerceptType, getProcesses, getProperty, getSpaceAction, getSpaceObject, getSpaceObject0, getSpaceObjectsByType, getSpaceObjectsCollection, getSpaceProcess, getSpaceProcessNames, getViews, init, initSpace, performSpaceAction, performSpaceAction, removeAvatarMappings, removeDataView, removeEnvironmentListener, removeObjectTask, removeObjectTaskType, removePerceptGenerator, removePerceptProcessor, removePerceptType, removeSpaceAction, removeSpaceObjectType, removeSpaceProcess, removeSpaceProcessType, removeTaskListener, setFetcher, setInitData, setOwner, terminate
addPropertyChangeListener, getMonitor, getPropertyNames, hasProperty, removePropertyChangeListener, setProperty
getMetaData, getMetaDatas
getProperties, setProperties, toString
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getPropertyNames, hasProperty, setProperty
public static final String DEFAULT_NAME
public static final String NEIGHBORHOOD_MOORE
public static final String NEIGHBORHOOD_VON_NEUMANN
public static final String PROPERTY_NEIGHBORHOOD
public Grid2D()
ContinuousSpace2D
with the default name.clockService
- the clock servicetimeCoefficient
- the time coefficient for time differences.areaSize
- the size of the 2D areapublic Grid2D(IVector2 areasize)
ContinuousSpace2D
with the default name.actionexecutor
- executor for component actionsareasize
- the size of the 2D areapublic Grid2D(Object name, IVector2 areasize)
ContinuousSpace2D
with a special ID.name
- the name of this spaceareasize
- the size of the 2D areaactionexecutor
- executor for component actionspublic void setAreaSize(IVector2 areasize)
setAreaSize
in class Space2D
areasize
- The area size.public String getNeighborhood()
public Collection getSpaceObjectsByGridPosition(IVector2 position, Object type)
public IVector2 getEmptyGridPosition()
IVector2
position.public void setPosition(Object id, IVector2 pos)
setPosition
in class Space2D
id
- The object id.pos
- The object position.public void initSpaceObject(ISpaceObject ret)
initSpaceObject
in class Space2D
public void destroySpaceObject(Object id)
destroySpaceObject
in interface IEnvironmentSpace
destroySpaceObject
in class AbstractEnvironmentSpace
objectId
- the object's IDpublic Set getNearObjects(IVector2 position, IVector1 distance, String type)
getNearObjects
in class Space2D
position
- The position.distance
- The distance.type
- The type (or null for all objects).public IVector1 calculateDistance(IVector1 dx, IVector1 dy)
calculateDistance
in class Space2D
dx
- The distance in x.dy
- The distance in y.public IVector1 getShortestDirection(IVector1 pos1, IVector1 pos2, boolean isx)
pos1
- The first position.pos2
- The second position.isx
- The flag indicating if x or y).Copyright © 2012. All Rights Reserved.