uchicago.src.sim.topology.space.d2
Class AbstractObject2DTopology

java.lang.Object
  extended byuchicago.src.sim.topology.space.d2.AbstractObject2DTopology
All Implemented Interfaces:
ModifyableTopology, RelationTopology
Direct Known Subclasses:
AbstractObject2DSpace

public abstract class AbstractObject2DTopology
extends java.lang.Object
implements ModifyableTopology

Author:
administrator The Abstract2DTopology class provides an underlying implementation for Object2DSpaces to act as Topologies. It implements all the methods required to get, add, remove and "Relations" between objects and the locations in the Grid.

Field Summary
protected  java.util.HashMap locations
           
 
Constructor Summary
AbstractObject2DTopology(java.lang.String type)
           
 
Method Summary
 void addRelation(java.lang.Object element1, java.lang.Object element2, double distance)
          inserts an object into a location in the Object2DSpace extending this support class
 double distance(java.lang.Object element1, java.lang.Object element2)
          Gets the distance between two objects in this topology.
 java.util.List getRelations(java.lang.Object element)
          Get all of the relationships that the given element has with other elements.
 java.util.List getRelations(java.lang.Object element, double range)
          Get all of the relationships that the given element has with other elements in this location.
 java.lang.String getRelationType()
          Get the type of relationship/topology that is represented by this Class.
 void removeRelation(java.lang.Object element1, java.lang.Object element2)
          removes an object from a location in the the Object2DSpace.
 void setRelationType(java.lang.String type)
          Set the type of relationship/topology that is represented by this Class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

locations

protected java.util.HashMap locations
Constructor Detail

AbstractObject2DTopology

public AbstractObject2DTopology(java.lang.String type)
Method Detail

addRelation

public void addRelation(java.lang.Object element1,
                        java.lang.Object element2,
                        double distance)
inserts an object into a location in the Object2DSpace extending this support class

Specified by:
addRelation in interface ModifyableTopology
Parameters:
element1 -
element2 -
distance -
See Also:
ModifyableTopology.addRelation(java.lang.Object, java.lang.Object, double)

removeRelation

public void removeRelation(java.lang.Object element1,
                           java.lang.Object element2)
removes an object from a location in the the Object2DSpace.

Specified by:
removeRelation in interface ModifyableTopology
Parameters:
element1 -
element2 -
See Also:
ModifyableTopology.removeRelation(java.lang.Object, java.lang.Object)

getRelations

public java.util.List getRelations(java.lang.Object element)
Get all of the relationships that the given element has with other elements.

Parameters:
element -
Returns:

getRelations

public java.util.List getRelations(java.lang.Object element,
                                   double range)
Get all of the relationships that the given element has with other elements in this location. (In this case, get the List of occupants from the location). In this case, the only range available is 1, this returns the same contents as public List getRelations(Object element).

Specified by:
getRelations in interface RelationTopology
Parameters:
element -
range -
Returns:
List of objects

getRelationType

public java.lang.String getRelationType()
Get the type of relationship/topology that is represented by this Class. This can be controlled so that two objects of the same class can exist in the context with different type id's. For example, if this represents a Object2DGrid, this could return "Agent Space" or "Playing Field".

Specified by:
getRelationType in interface RelationTopology
Returns:
the type

setRelationType

public void setRelationType(java.lang.String type)
Set the type of relationship/topology that is represented by this Class. This can be controlled so that two objects of the same class can exist in the context with different type id's. For example, if this represents a Object2DGrid, this could return "Agent Space" or "Playing Field".

Specified by:
setRelationType in interface RelationTopology
Parameters:
type -
See Also:
RelationTopology.setRelationType(java.lang.String)

distance

public double distance(java.lang.Object element1,
                       java.lang.Object element2)
Gets the distance between two objects in this topology. This could be either spatial distance, network distance or any other kind of well defined metric distance.

Specified by:
distance in interface RelationTopology
Parameters:
element1 -
element2 -
Returns:
double representing the distance between to objects in this Topology