jadex.application.space.envsupport.environment.space2d
Class Grid2D

java.lang.Object
  extended by jadex.commons.SimplePropertyObject
      extended by jadex.commons.meta.TypedPropertyObject
          extended by jadex.application.space.envsupport.environment.SynchronizedPropertyObject
              extended by jadex.application.space.envsupport.environment.AbstractEnvironmentSpace
                  extended by jadex.application.space.envsupport.environment.space2d.Space2D
                      extended by jadex.application.space.envsupport.environment.space2d.Grid2D
All Implemented Interfaces:
ISpace, IEnvironmentSpace, IPropertyObject, ITypedPropertyObject

public class Grid2D
extends Space2D

2D grid environment.


Field Summary
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.
protected  MultiCollection objectsygridpos
          All simobject id's accessible per position.
static String PROPERTY_NEIGHBORHOOD
          The neighborhood property.
 
Fields inherited from class jadex.application.space.envsupport.environment.space2d.Space2D
areasize, BORDER_STRICT, BORDER_TORUS, PROPERTY_BORDER, PROPERTY_POSITION
 
Fields inherited from class jadex.application.space.envsupport.environment.AbstractEnvironmentSpace
actionlist, actions, application, avatarmappings, dataconsumers, dataproviders, dataviewmappings, fetcher, initialavatars, listeners, name, objectidcounter, objecttypes, objecttypesMeta, perceptgenerators, perceptlist, perceptprocessors, percepttypes, processes, processtypes, spaceobjects, spaceobjectsbyowner, spaceobjectsbytype, taskidcounter, tasktypes, views, zombieobjects
 
Fields inherited from class jadex.application.space.envsupport.environment.SynchronizedPropertyObject
monitor
 
Fields inherited from class jadex.commons.SimplePropertyObject
pcs, properties
 
Constructor Summary
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.
 
Method Summary
 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.
 
Methods inherited from class jadex.application.space.envsupport.environment.space2d.Space2D
adjustPosition, getAreaSize, getBorderMode, getDistance, getDistance, getNearestObject, getNearObjects, getNearObjects, getRandomPosition, getSpaceObjects
 
Methods inherited from class jadex.application.space.envsupport.environment.AbstractEnvironmentSpace
addAvatarMappings, addDataConsumer, addDataProvider, addDataView, addDataViewMapping, addEnvironmentListener, addInitialAvatar, addObjectTaskType, addPerceptGenerator, addPerceptProcessor, addPerceptType, addSpaceAction, addSpaceObjectType, addSpaceProcessType, addTaskListener, componentAdded, componentRemoved, createAvatar, createObjectTask, createPercept, createSpaceObject, createSpaceObjectZombie, createSpaceProcess, fireEnvironmentEvent, fireObjectEvent, getAvatar, getAvatar, getAvatarMapping, getAvatars, getComponentActionList, getComponents, getContext, getDataConsumer, getDataConsumers, getDataProvider, getDataView, getDataViews, getFetcher, getOwner, getPerceptList, getPerceptType, getProcesses, getProperty, getSpaceAction, getSpaceObject, getSpaceObject0, getSpaceObjectsByType, getSpaceObjectsCollection, getSpaceProcess, getSpaceProcessNames, getViews, initSpace, mergeProperties, mergeProperties, performSpaceAction, performSpaceAction, removeAvatarMappings, removeDataView, removeEnvironmentListener, removeObjectTask, removeObjectTaskType, removePerceptGenerator, removePerceptProcessor, removePerceptType, removeSpaceAction, removeSpaceObjectType, removeSpaceProcess, removeSpaceProcessType, removeTaskListener, setFetcher, setOwner, terminate
 
Methods inherited from class jadex.application.space.envsupport.environment.SynchronizedPropertyObject
addPropertyChangeListener, getMonitor, getPropertyNames, hasProperty, removePropertyChangeListener, setProperty
 
Methods inherited from class jadex.commons.meta.TypedPropertyObject
getMetaData, getMetaDatas
 
Methods inherited from class jadex.commons.SimplePropertyObject
getProperties, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jadex.commons.IPropertyObject
getPropertyNames, hasProperty, setProperty
 

Field Detail

DEFAULT_NAME

public static final String DEFAULT_NAME
The default ID for this space.


NEIGHBORHOOD_MOORE

public static final String NEIGHBORHOOD_MOORE
The moore neighborhood.

See Also:
Constant Field Values

NEIGHBORHOOD_VON_NEUMANN

public static final String NEIGHBORHOOD_VON_NEUMANN
The von neumann neighborhood.

See Also:
Constant Field Values

PROPERTY_NEIGHBORHOOD

public static final String PROPERTY_NEIGHBORHOOD
The neighborhood property.

See Also:
Constant Field Values

objectsygridpos

protected MultiCollection objectsygridpos
All simobject id's accessible per position.

Constructor Detail

Grid2D

public Grid2D()
Creates a new ContinuousSpace2D with the default name.

Parameters:
clockService - the clock service
timeCoefficient - the time coefficient for time differences.
areaSize - the size of the 2D area

Grid2D

public Grid2D(IVector2 areasize)
Creates a new ContinuousSpace2D with the default name.

Parameters:
actionexecutor - executor for component actions
areasize - the size of the 2D area

Grid2D

public Grid2D(Object name,
              IVector2 areasize)
Creates a new ContinuousSpace2D with a special ID.

Parameters:
name - the name of this space
areasize - the size of the 2D area
actionexecutor - executor for component actions
Method Detail

setAreaSize

public void setAreaSize(IVector2 areasize)
Set the area size.

Overrides:
setAreaSize in class Space2D
Parameters:
areasize - The area size.

getNeighborhood

public String getNeighborhood()
Get the neighborhood.

Returns:
Set the neighborhood.

getSpaceObjectsByGridPosition

public Collection getSpaceObjectsByGridPosition(IVector2 position,
                                                Object type)
Get all SimObjects from a specific type at a specific grid position


getEmptyGridPosition

public IVector2 getEmptyGridPosition()
Get an empty position in the grid.

Returns:
Empty IVector2 position.

setPosition

public void setPosition(Object id,
                        IVector2 pos)
Set the position of an object.

Overrides:
setPosition in class Space2D
Parameters:
id - The object id.
pos - The object position.

initSpaceObject

public void initSpaceObject(ISpaceObject ret)
Init an object in this space.

Overrides:
initSpaceObject in class Space2D

destroySpaceObject

public void destroySpaceObject(Object id)
Destroys an object in this space.

Specified by:
destroySpaceObject in interface IEnvironmentSpace
Overrides:
destroySpaceObject in class AbstractEnvironmentSpace
Parameters:
objectId - the object's ID

getNearObjects

public Set getNearObjects(IVector2 position,
                          IVector1 distance,
                          String type)
Retrieve all objects in the distance for a position. Uses position->object mapping, for fast operation.

Overrides:
getNearObjects in class Space2D
Parameters:
position - The position.
distance - The distance.
type - The type (or null for all objects).
Returns:
The near objects.

calculateDistance

public IVector1 calculateDistance(IVector1 dx,
                                  IVector1 dy)
Calculate the distance in the space.

Overrides:
calculateDistance in class Space2D
Parameters:
dx - The distance in x.
dy - The distance in y.
Returns:
The distance according to the distance metrics of the space.

getShortestDirection

public 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


Copyright © 2010. All Rights Reserved.