Class Space2D
- 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
 
 
 
 
 
- 
- All Implemented Interfaces:
- jadex.application.IExtensionInstance,- IPropertyObject,- ITypedPropertyObject,- IEnvironmentSpace
 - Direct Known Subclasses:
- ContinuousSpace2D,- Grid2D
 
 public abstract class Space2D extends AbstractEnvironmentSpace General 2D space.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected classSpace2D.KdTreeProcess- 
Nested classes/interfaces inherited from class jadex.extension.envsupport.environment.AbstractEnvironmentSpaceAbstractEnvironmentSpace.AtomicCounter
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected IVector2areasizeArea size.static java.lang.StringBORDER_RELAXEDBorder relaxed mode.static java.lang.StringBORDER_STRICTBorder strict mode.static java.lang.StringBORDER_TORUSBorder torus behavior.protected java.util.Map<java.lang.String,KdTree>kdTreesKD-Trees.static java.lang.StringPROPERTY_BORDERThe constant for the border property.static java.lang.StringPROPERTY_POSITIONThe constant for the position property.- 
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
 
- 
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSpaceObjectType(java.lang.String typename, IPropertyMetaDataSet mobjecttype)Add a space type.IVector2adjustPosition(IVector2 pos)Calculate a position according to the space borders.IVector1calculateDistance(IVector1 dx, IVector1 dy)Calculate the distance in the space.voiddisableKdTree(java.lang.String type)Disables kd-tree NN-Search optimization for a specific object type.voidenableKdTree(java.lang.String type)Enables kd-tree NN-Search optimization for a specific object type.IVector2getAreaSize()Returns the size of the simulated area.java.lang.StringgetBorderMode()Get the border mode.IVector1getDistance(IVector1 pos1, IVector1 pos2, boolean isx)Get the distance between two coordinates (x or y).IVector1getDistance(IVector2 pos1, IVector2 pos2)Get the distance between two positions.ISpaceObjectgetNearestObject(IVector2 position, IVector1 maxdist, java.lang.String type)Returns the nearest object to the given position within a maximum distance from the position.java.util.Set<ISpaceObject>getNearObjects(IVector2 position, IVector1 maxdist)Retrieve all objects in the distance for a positionjava.util.Set<ISpaceObject>getNearObjects(IVector2 position, IVector1 maxdist, IFilter filter)Retrieve all objects in the distance for a positionjava.util.Set<ISpaceObject>getNearObjects(IVector2 position, IVector1 maxdist, java.lang.String type)Retrieve all objects in the distance for a positionjava.util.Set<ISpaceObject>getNearObjects(IVector2 position, IVector1 maxdist, java.lang.String type, IFilter filter)Retrieve all objects in the distance for a positionIVector2getRandomPosition(IVector2 distance)Retrieves a random position within the simulation area with a minimum distance from the edge.java.lang.Object[]getSpaceObjects()Get all space objects.voidinitSpaceObject(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.AbstractEnvironmentSpaceaddAvatarMappings, addDataConsumer, addDataProvider, addDataView, addDataViewMapping, addEnvironmentListener, addInitialAvatar, addObjectTaskType, addPerceptGenerator, addPerceptProcessor, addPerceptType, addSpaceAction, addSpaceProcessType, addTaskListener, cancelSpaceAction, componentAdded, componentRemoved, createAvatar, createObjectTask, createPercept, createSpaceObject, createSpaceObjectZombie, createSpaceProcess, destroySpaceObject, 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- 
PROPERTY_POSITIONpublic static final java.lang.String PROPERTY_POSITION The constant for the position property.- See Also:
- Constant Field Values
 
 - 
PROPERTY_BORDERpublic static final java.lang.String PROPERTY_BORDER The constant for the border property.- See Also:
- Constant Field Values
 
 - 
BORDER_STRICTpublic static final java.lang.String BORDER_STRICT Border strict mode.- See Also:
- Constant Field Values
 
 - 
BORDER_RELAXEDpublic static final java.lang.String BORDER_RELAXED Border relaxed mode.- See Also:
- Constant Field Values
 
 - 
BORDER_TORUSpublic static final java.lang.String BORDER_TORUS Border torus behavior.- See Also:
- Constant Field Values
 
 - 
areasizeprotected IVector2 areasize Area size.
 - 
kdTreesprotected java.util.Map<java.lang.String,KdTree> kdTrees KD-Trees.
 
- 
 - 
Constructor Detail- 
Space2Dprotected 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- 
getAreaSizepublic IVector2 getAreaSize() Returns the size of the simulated area.- Returns:
- size of the simulated area
 
 - 
setAreaSizepublic void setAreaSize(IVector2 areasize) Set the area size.- Parameters:
- areasize- The area size.
 
 - 
getBorderModepublic java.lang.String getBorderMode() Get the border mode.- Returns:
- the border_mode
 
 - 
initSpaceObjectpublic void initSpaceObject(ISpaceObject ret) Init an object in this space.- Overrides:
- initSpaceObjectin class- AbstractEnvironmentSpace
 
 - 
addSpaceObjectTypepublic void addSpaceObjectType(java.lang.String typename, IPropertyMetaDataSet mobjecttype)Description copied from class:AbstractEnvironmentSpaceAdd a space type.- Specified by:
- addSpaceObjectTypein interface- IEnvironmentSpace
- Overrides:
- addSpaceObjectTypein class- AbstractEnvironmentSpace
- Parameters:
- typename- The type name.
- mobjecttype- The properties (map of maps with name->name/value/dynamic/event).
 
 - 
setPositionpublic void setPosition(java.lang.Object id, IVector2 pos)Set the position of an object.- Parameters:
- id- The object id.
- pos- The object position.
 
 - 
getDistancepublic IVector1 getDistance(IVector2 pos1, IVector2 pos2) Get the distance between two positions.- Parameters:
- pos1- The first position.
- pos2- The second position.
 
 - 
getDistancepublic 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.
 
 - 
calculateDistancepublic 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.
 
 - 
adjustPositionpublic IVector2 adjustPosition(IVector2 pos) Calculate a position according to the space borders.
 - 
getRandomPositionpublic 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
 
 - 
enableKdTreepublic void enableKdTree(java.lang.String type) Enables kd-tree NN-Search optimization for a specific object type. This will increase space overhead but massively decreases restricted nearest-neighborsearches in cases of large amounts of (evenly distributed) objects.- Parameters:
- String- type The type of object being optimized.
 
 - 
disableKdTreepublic void disableKdTree(java.lang.String type) Disables kd-tree NN-Search optimization for a specific object type.- Parameters:
- String- type The type of object for which the kd-tree is disabled.
 
 - 
getNearestObjectpublic ISpaceObject getNearestObject(IVector2 position, IVector1 maxdist, java.lang.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
 
 - 
getNearObjectspublic java.util.Set<ISpaceObject> getNearObjects(IVector2 position, IVector1 maxdist) Retrieve all objects in the distance for a position- Parameters:
- position-
- distance-
- Returns:
- The near objects.
 
 - 
getNearObjectspublic java.util.Set<ISpaceObject> getNearObjects(IVector2 position, IVector1 maxdist, java.lang.String type) Retrieve all objects in the distance for a position- Parameters:
- position-
- distance-
- Returns:
- The near objects.
 
 - 
getNearObjectspublic java.util.Set<ISpaceObject> getNearObjects(IVector2 position, IVector1 maxdist, IFilter filter) Retrieve all objects in the distance for a position- Parameters:
- position-
- distance-
- Returns:
- The near objects.
 
 - 
getNearObjectspublic java.util.Set<ISpaceObject> getNearObjects(IVector2 position, IVector1 maxdist, java.lang.String type, IFilter filter) Retrieve all objects in the distance for a position- Parameters:
- position-
- distance-
- Returns:
- The near objects.
 
 - 
getSpaceObjectspublic java.lang.Object[] getSpaceObjects() Get all space objects.- Returns:
- All space objects.
 
 
- 
 
-