public abstract class Space2D extends AbstractEnvironmentSpace
Modifier and Type | Class and Description |
---|---|
protected class |
Space2D.KdTreeProcess |
AbstractEnvironmentSpace.AtomicCounter
Modifier and Type | Field and Description |
---|---|
protected IVector2 |
areasize
Area size.
|
static java.lang.String |
BORDER_RELAXED
Border relaxed mode.
|
static java.lang.String |
BORDER_STRICT
Border strict mode.
|
static java.lang.String |
BORDER_TORUS
Border torus behavior.
|
protected java.util.Map<java.lang.String,KdTree> |
kdTrees
KD-Trees.
|
static java.lang.String |
PROPERTY_BORDER
The constant for the border property.
|
static java.lang.String |
PROPERTY_POSITION
The constant for the position property.
|
actionlist, 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
monitor
pcs, properties
Modifier | Constructor and Description |
---|---|
protected |
Space2D(IVector2 areasize)
Initializes the 2D-Space.
|
Modifier and Type | Method and Description |
---|---|
void |
addSpaceObjectType(java.lang.String typename,
IPropertyMetaDataSet mobjecttype)
Add a space type.
|
IVector2 |
adjustPosition(IVector2 pos)
Calculate a position according to the space borders.
|
IVector1 |
calculateDistance(IVector1 dx,
IVector1 dy)
Calculate the distance in the space.
|
void |
disableKdTree(java.lang.String type)
Disables kd-tree NN-Search optimization for a specific object type.
|
void |
enableKdTree(java.lang.String type)
Enables kd-tree NN-Search optimization for a specific object type.
|
IVector2 |
getAreaSize()
Returns the size of the simulated area.
|
java.lang.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,
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 position
|
java.util.Set<ISpaceObject> |
getNearObjects(IVector2 position,
IVector1 maxdist,
IFilter filter)
Retrieve all objects in the distance for a position
|
java.util.Set<ISpaceObject> |
getNearObjects(IVector2 position,
IVector1 maxdist,
java.lang.String type)
Retrieve all objects in the distance for a position
|
java.util.Set<ISpaceObject> |
getNearObjects(IVector2 position,
IVector1 maxdist,
java.lang.String type,
IFilter filter)
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.
|
java.lang.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(java.lang.Object id,
IVector2 pos)
Set the position of an object.
|
addAvatarMappings, 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
addPropertyChangeListener, getMonitor, getPropertyNames, hasProperty, removePropertyChangeListener, setProperty
getMetaData, getMetaDatas
getProperties, setProperties, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getPropertyNames, hasProperty, setProperty
public static final java.lang.String PROPERTY_POSITION
public static final java.lang.String PROPERTY_BORDER
public static final java.lang.String BORDER_STRICT
public static final java.lang.String BORDER_RELAXED
public static final java.lang.String BORDER_TORUS
protected IVector2 areasize
protected java.util.Map<java.lang.String,KdTree> kdTrees
protected Space2D(IVector2 areasize)
spaceexecutor
- executor for the spaceactionexecutor
- executor for component actionsareasize
- the size of the 2D areapublic IVector2 getAreaSize()
public void setAreaSize(IVector2 areasize)
areasize
- The area size.public java.lang.String getBorderMode()
public void initSpaceObject(ISpaceObject ret)
initSpaceObject
in class AbstractEnvironmentSpace
public void addSpaceObjectType(java.lang.String typename, IPropertyMetaDataSet mobjecttype)
AbstractEnvironmentSpace
addSpaceObjectType
in interface IEnvironmentSpace
addSpaceObjectType
in class AbstractEnvironmentSpace
typename
- The type name.mobjecttype
- The properties (map of maps with name->name/value/dynamic/event).public void setPosition(java.lang.Object id, IVector2 pos)
id
- The object id.pos
- The object position.public IVector1 getDistance(IVector2 pos1, IVector2 pos2)
pos1
- The first position.pos2
- The second position.public IVector1 getDistance(IVector1 pos1, IVector1 pos2, boolean isx)
pos1
- The first position.pos2
- The second position.public IVector1 calculateDistance(IVector1 dx, IVector1 dy)
dx
- The distance in x.dy
- The distance in y.public IVector2 adjustPosition(IVector2 pos)
public IVector2 getRandomPosition(IVector2 distance)
distance
- minimum distance from the edge, null or zero for no distancepublic void enableKdTree(java.lang.String type)
String
- type The type of object being optimized.public void disableKdTree(java.lang.String type)
String
- type The type of object for which the kd-tree is disabled.public ISpaceObject getNearestObject(IVector2 position, IVector1 maxdist, java.lang.String type)
position
- position the object should be nearest tomaxdist
- maximum distance from the position, use null for unlimited distancepublic java.util.Set<ISpaceObject> getNearObjects(IVector2 position, IVector1 maxdist)
position
- distance
- public java.util.Set<ISpaceObject> getNearObjects(IVector2 position, IVector1 maxdist, java.lang.String type)
position
- distance
- public java.util.Set<ISpaceObject> getNearObjects(IVector2 position, IVector1 maxdist, IFilter filter)
position
- distance
- public java.util.Set<ISpaceObject> getNearObjects(IVector2 position, IVector1 maxdist, java.lang.String type, IFilter filter)
position
- distance
- public java.lang.Object[] getSpaceObjects()