Class Grid2D
- java.lang.Object
- 
- jadex.commons.SimplePropertyObject
- 
- jadex.commons.meta.TypedPropertyObject
- 
- jadex.extension.envsupport.environment.SynchronizedPropertyObject
- 
- jadex.extension.envsupport.environment.AbstractEnvironmentSpace
- 
- jadex.extension.envsupport.environment.space2d.Space2D
- 
- jadex.extension.envsupport.environment.space2d.Grid2D
 
 
 
 
 
 
- 
- All Implemented Interfaces:
- IExtensionInstance,- IPropertyObject,- ITypedPropertyObject,- IEnvironmentSpace
 
 public class Grid2D extends Space2D 2D grid environment.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class jadex.extension.envsupport.environment.space2d.Space2DSpace2D.KdTreeProcess
 - 
Nested classes/interfaces inherited from class jadex.extension.envsupport.environment.AbstractEnvironmentSpaceAbstractEnvironmentSpace.AtomicCounter
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static java.lang.StringDEFAULT_NAMEThe default ID for this space.static java.lang.StringNEIGHBORHOOD_MOOREThe moore neighborhood.static java.lang.StringNEIGHBORHOOD_VON_NEUMANNThe von neumann neighborhood.protected MultiCollection<IVector2,ISpaceObject>objectsygridposAll simobject id's accessible per position.static java.lang.StringPROPERTY_NEIGHBORHOODThe neighborhood property.- 
Fields inherited from class jadex.extension.envsupport.environment.space2d.Space2Dareasize, BORDER_RELAXED, BORDER_STRICT, BORDER_TORUS, kdTrees, PROPERTY_BORDER, PROPERTY_POSITION
 - 
Fields inherited from class jadex.extension.envsupport.environment.AbstractEnvironmentSpaceactionlist, actions, avatarmappings, classloader, config, dataconsumers, dataproviders, dataviewmappings, exta, fetcher, ia, initialavatars, listeners, objectidcounter, objecttypes, objecttypesMeta, observercenters, perceptgenerators, perceptlist, perceptprocessors, percepttypes, pfetcher, processes, processtypes, spaceobjects, spaceobjectsbyowner, spaceobjectsbytype, taskidcounter, tasktypes, views, zombieobjects
 - 
Fields inherited from class jadex.extension.envsupport.environment.SynchronizedPropertyObjectmonitor
 - 
Fields inherited from class jadex.commons.SimplePropertyObjectpcs, properties
 
- 
 - 
Constructor SummaryConstructors Constructor Description Grid2D()Creates a newContinuousSpace2Dwith the default name.Grid2D(IVector2 areasize)Creates a newContinuousSpace2Dwith the default name.Grid2D(java.lang.Object name, IVector2 areasize)Creates a newContinuousSpace2Dwith a special ID.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description IVector1calculateDistance(IVector1 dx, IVector1 dy)Calculate the distance in the space.booleandestroyAndVerifySpaceObject(java.lang.Object id)Destroys an object in this space.voiddestroySpaceObject(java.lang.Object id)Destroys an object in this space.IVector2getEmptyGridPosition()Get an empty position in the grid.java.util.Set<ISpaceObject>getNearGridObjects(IVector2 position, int range, java.lang.String[] types)java.util.Set<ISpaceObject>getNearObjects(IVector2 position, IVector1 distance, java.lang.String type)Retrieve all objects in the distance for a position.java.lang.StringgetNeighborhood()Get the neighborhood.IVector2getRandomGridPosition(IVector2 distance)Retrieves a random position within the simulation area with a minimum distance from the edge.IVector1getShortestDirection(IVector1 pos1, IVector1 pos2, boolean isx)Get the shortest (direct) direction between two coordinates.java.util.Collection<ISpaceObject>getSpaceObjectsByGridPosition(IVector2 position, java.lang.Object type)Get all SimObjects from a specific type at a specific grid positionvoidinitSpaceObject(ISpaceObject ret)Init an object in this space.voidsetAreaSize(IVector2 areasize)Set the area size.voidsetPosition(java.lang.Object id, IVector2 pos)Set the position of an object.- 
Methods inherited from class jadex.extension.envsupport.environment.space2d.Space2DaddSpaceObjectType, adjustPosition, disableKdTree, enableKdTree, getAreaSize, getBorderMode, getDistance, getDistance, getNearestObject, getNearObjects, getNearObjects, getNearObjects, getRandomPosition, getSpaceObjects
 - 
Methods inherited from class jadex.extension.envsupport.environment.AbstractEnvironmentSpaceaddAvatarMappings, addDataConsumer, addDataProvider, addDataView, addDataViewMapping, addEnvironmentListener, addInitialAvatar, addObjectTaskType, addPerceptGenerator, addPerceptProcessor, addPerceptType, addSpaceAction, addSpaceProcessType, addTaskListener, cancelSpaceAction, componentAdded, componentRemoved, createAvatar, createObjectTask, createPercept, createSpaceObject, createSpaceObjectZombie, createSpaceProcess, fireEnvironmentEvent, fireObjectEvent, getAvatar, getAvatar, getAvatarMapping, getAvatars, getClassLoader, getComponentActionList, getComponents, getComponentType, getDataConsumer, getDataConsumers, getDataProvider, getDataView, getDataViews, getExternalAccess, getFetcher, getOwner, getPerceptList, getPerceptType, getProcesses, getProperty, getSpaceAction, getSpaceObject, getSpaceObject0, getSpaceObjectsByType, getSpaceObjectsCollection, getSpaceObjectType, getSpaceProcess, getSpaceProcessNames, getViews, init, initSpace, mergeProperties, mergeProperties, performSpaceAction, performSpaceAction, removeAvatarMappings, removeDataView, removeEnvironmentListener, removeObjectTask, removeObjectTaskType, removePerceptGenerator, removePerceptProcessor, removePerceptType, removeSpaceAction, removeSpaceObjectType, removeSpaceProcess, removeSpaceProcessType, removeTaskListener, setFetcher, setInitData, setOwner, terminate, waitForTask
 - 
Methods inherited from class jadex.extension.envsupport.environment.SynchronizedPropertyObjectaddPropertyChangeListener, getMonitor, getPropertyNames, hasProperty, removePropertyChangeListener, setProperty
 - 
Methods inherited from class jadex.commons.meta.TypedPropertyObjectgetMetaData, getMetaDatas
 - 
Methods inherited from class jadex.commons.SimplePropertyObjectgetProperties, setProperties, toString
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface jadex.commons.IPropertyObjectgetPropertyNames, hasProperty, setProperty
 
- 
 
- 
- 
- 
Field Detail- 
DEFAULT_NAMEpublic static final java.lang.String DEFAULT_NAME The default ID for this space.
 - 
NEIGHBORHOOD_MOOREpublic static final java.lang.String NEIGHBORHOOD_MOORE The moore neighborhood.- See Also:
- Constant Field Values
 
 - 
NEIGHBORHOOD_VON_NEUMANNpublic static final java.lang.String NEIGHBORHOOD_VON_NEUMANN The von neumann neighborhood.- See Also:
- Constant Field Values
 
 - 
PROPERTY_NEIGHBORHOODpublic static final java.lang.String PROPERTY_NEIGHBORHOOD The neighborhood property.- See Also:
- Constant Field Values
 
 - 
objectsygridposprotected MultiCollection<IVector2,ISpaceObject> objectsygridpos All simobject id's accessible per position.
 
- 
 - 
Constructor Detail- 
Grid2Dpublic Grid2D() Creates a newContinuousSpace2Dwith the default name.- Parameters:
- clockService- the clock service
- timeCoefficient- the time coefficient for time differences.
- areaSize- the size of the 2D area
 
 - 
Grid2Dpublic Grid2D(IVector2 areasize) Creates a newContinuousSpace2Dwith the default name.- Parameters:
- actionexecutor- executor for component actions
- areasize- the size of the 2D area
 
 - 
Grid2Dpublic Grid2D(java.lang.Object name, IVector2 areasize)Creates a newContinuousSpace2Dwith a special ID.- Parameters:
- name- the name of this space
- areasize- the size of the 2D area
- actionexecutor- executor for component actions
 
 
- 
 - 
Method Detail- 
setAreaSizepublic void setAreaSize(IVector2 areasize) Set the area size.- Overrides:
- setAreaSizein class- Space2D
- Parameters:
- areasize- The area size.
 
 - 
getNeighborhoodpublic java.lang.String getNeighborhood() Get the neighborhood.- Returns:
- Set the neighborhood.
 
 - 
getSpaceObjectsByGridPositionpublic java.util.Collection<ISpaceObject> getSpaceObjectsByGridPosition(IVector2 position, java.lang.Object type) Get all SimObjects from a specific type at a specific grid position
 - 
getEmptyGridPositionpublic IVector2 getEmptyGridPosition() Get an empty position in the grid.- Returns:
- Empty IVector2position.
 
 - 
getRandomGridPositionpublic IVector2 getRandomGridPosition(IVector2 distance) Retrieves a random position within the simulation area with a minimum distance from the edge.- Parameters:
- distance- minimum distance from the edge, null or zero for no distance
 
 - 
setPositionpublic void setPosition(java.lang.Object id, IVector2 pos)Set the position of an object.- Overrides:
- setPositionin class- Space2D
- Parameters:
- id- The object id.
- pos- The object position.
 
 - 
initSpaceObjectpublic void initSpaceObject(ISpaceObject ret) Init an object in this space.- Overrides:
- initSpaceObjectin class- Space2D
 
 - 
destroyAndVerifySpaceObjectpublic boolean destroyAndVerifySpaceObject(java.lang.Object id) Destroys an object in this space.- Parameters:
- objectId- the object's ID
 
 - 
destroySpaceObjectpublic void destroySpaceObject(java.lang.Object id) Destroys an object in this space.- Specified by:
- destroySpaceObjectin interface- IEnvironmentSpace
- Overrides:
- destroySpaceObjectin class- AbstractEnvironmentSpace
- Parameters:
- objectId- the object's ID
 
 - 
getNearGridObjectspublic java.util.Set<ISpaceObject> getNearGridObjects(IVector2 position, int range, java.lang.String[] types) 
 - 
getNearObjectspublic java.util.Set<ISpaceObject> getNearObjects(IVector2 position, IVector1 distance, java.lang.String type) Retrieve all objects in the distance for a position. Uses position->object mapping, for fast operation.- Overrides:
- getNearObjectsin class- Space2D
- Parameters:
- position- The position.
- distance- The distance.
- type- The type (or null for all objects).
- Returns:
- The near objects.
 
 - 
calculateDistancepublic IVector1 calculateDistance(IVector1 dx, IVector1 dy) Calculate the distance in the space.- Overrides:
- calculateDistancein class- Space2D
- Parameters:
- dx- The distance in x.
- dy- The distance in y.
- Returns:
- The distance according to the distance metrics of the space.
 
 - 
getShortestDirectionpublic IVector1 getShortestDirection(IVector1 pos1, IVector1 pos2, boolean isx) Get the shortest (direct) direction between two coordinates.- Parameters:
- pos1- The first position.
- pos2- The second position.
- isx- The flag indicating if x or y).
- Returns:
- -1: left/down, +1: right/up, 0: no move
 
 
- 
 
-