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

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
All Implemented Interfaces:
ISpace, IEnvironmentSpace, IPropertyObject, ITypedPropertyObject
Direct Known Subclasses:
ContinuousSpace2D, Grid2D

public abstract class Space2D
extends AbstractEnvironmentSpace

General 2D space.


Field Summary
protected  IVector2 areasize
          Area size.
static String BORDER_STRICT
          Border strict mode.
static String BORDER_TORUS
          Border torus behavior.
static String PROPERTY_BORDER
          The constant for the border property.
static String PROPERTY_POSITION
          The constant for the position property.
 
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
protected Space2D(IVector2 areasize)
          Initializes the 2D-Space.
 
Method Summary
 IVector2 adjustPosition(IVector2 pos)
          Calculate a position according to the space borders.
 IVector1 calculateDistance(IVector1 dx, IVector1 dy)
          Calculate the distance in the space.
 IVector2 getAreaSize()
          Returns the size of the simulated area.
 String getBorderMode()
          Get the border mode.
 IVector1 getDistance(IVector1 pos1, IVector1 pos2, boolean isx)
          Get the distance between two coordinates (x or y).
 IVector1 getDistance(IVector2 pos1, IVector2 pos2)
          Get the distance between two positions.
 ISpaceObject getNearestObject(IVector2 position, IVector1 maxdist, String type)
          Returns the nearest object to the given position within a maximum distance from the position.
 Set getNearObjects(IVector2 position, IVector1 maxdist)
          Retrieve all objects in the distance for a position
 Set getNearObjects(IVector2 position, IVector1 maxdist, IFilter filter)
          Retrieve all objects in the distance for a position
 Set getNearObjects(IVector2 position, IVector1 maxdist, String type)
          Retrieve all objects in the distance for a position
 IVector2 getRandomPosition(IVector2 distance)
          Retrieves a random position within the simulation area with a minimum distance from the edge.
 Object[] getSpaceObjects()
          Get all space objects.
 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.AbstractEnvironmentSpace
addAvatarMappings, addDataConsumer, addDataProvider, addDataView, addDataViewMapping, addEnvironmentListener, addInitialAvatar, addObjectTaskType, addPerceptGenerator, addPerceptProcessor, addPerceptType, addSpaceAction, addSpaceObjectType, addSpaceProcessType, addTaskListener, componentAdded, componentRemoved, createAvatar, createObjectTask, createPercept, createSpaceObject, createSpaceObjectZombie, createSpaceProcess, destroySpaceObject, 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

PROPERTY_POSITION

public static final String PROPERTY_POSITION
The constant for the position property.

See Also:
Constant Field Values

PROPERTY_BORDER

public static final String PROPERTY_BORDER
The constant for the border property.

See Also:
Constant Field Values

BORDER_STRICT

public static final String BORDER_STRICT
Border strict mode.

See Also:
Constant Field Values

BORDER_TORUS

public static final String BORDER_TORUS
Border torus behavior.

See Also:
Constant Field Values

areasize

protected IVector2 areasize
Area size.

Constructor Detail

Space2D

protected Space2D(IVector2 areasize)
Initializes the 2D-Space.

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

getAreaSize

public IVector2 getAreaSize()
Returns the size of the simulated area.

Returns:
size of the simulated area

setAreaSize

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

Parameters:
areasize - The area size.

getBorderMode

public String getBorderMode()
Get the border mode.

Returns:
the border_mode

initSpaceObject

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

Overrides:
initSpaceObject in class AbstractEnvironmentSpace

setPosition

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

Parameters:
id - The object id.
pos - The object position.

getDistance

public IVector1 getDistance(IVector2 pos1,
                            IVector2 pos2)
Get the distance between two positions.

Parameters:
pos1 - The first position.
pos2 - The second position.

getDistance

public IVector1 getDistance(IVector1 pos1,
                            IVector1 pos2,
                            boolean isx)
Get the distance between two coordinates (x or y).

Parameters:
pos1 - The first position.
pos2 - The second position.

calculateDistance

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

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

adjustPosition

public IVector2 adjustPosition(IVector2 pos)
Calculate a position according to the space borders.


getRandomPosition

public IVector2 getRandomPosition(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

getNearestObject

public ISpaceObject getNearestObject(IVector2 position,
                                     IVector1 maxdist,
                                     String type)
Returns the nearest object to the given position within a maximum distance from the position.

Parameters:
position - position the object should be nearest to
maxdist - maximum distance from the position, use null for unlimited distance
Returns:
nearest object's ID or null if none is found

getNearObjects

public Set getNearObjects(IVector2 position,
                          IVector1 maxdist)
Retrieve all objects in the distance for a position

Parameters:
position -
distance -
Returns:
The near objects.

getNearObjects

public Set getNearObjects(IVector2 position,
                          IVector1 maxdist,
                          String type)
Retrieve all objects in the distance for a position

Parameters:
position -
distance -
Returns:
The near objects.

getNearObjects

public Set getNearObjects(IVector2 position,
                          IVector1 maxdist,
                          IFilter filter)
Retrieve all objects in the distance for a position

Parameters:
position -
distance -
Returns:
The near objects.

getSpaceObjects

public Object[] getSpaceObjects()
Get all space objects.

Returns:
All space objects.


Copyright © 2010. All Rights Reserved.