|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface GridMap
Represents an environment object that can be used to keep track of the location of other objects in a 2-dimensional grid.
Initially, a rectangular location and size are set. Then, environment objects can be set to particular locations (the GridMap should take care of updating the location of GridObjects, so the environment only has to manipulate locations once.)
GridObjects can be queried directly for their location, or the GridMap can be queried to find out what objects are in a particular location.
Method Summary | |
---|---|
DiscreteRectangle |
getRectangle()
Returns the location and size of the map. |
boolean |
locationIsWithinBounds(DiscretePoint2D theLocation)
Returns true if the given location is within the bounds of the map. |
java.util.Set<GridObject> |
objectsAtLocation(DiscretePoint2D theLocation)
Returns a set (possibly empty) of the environment objects known to be present at the given location. |
void |
setRectangle(DiscreteRectangle theRectangle)
Sets the location and size of the map. |
void |
updateObjectLocation(GridObject theObject,
DiscretePoint2D theLocation)
Updates the location of a GridObject. |
Methods inherited from interface edu.columbia.cs.coms4701.agent.EnvironmentObject |
---|
addPropertyChangeListener, isAlive, removePropertyChangeListener, setAlive |
Method Detail |
---|
void setRectangle(DiscreteRectangle theRectangle)
theRectangle
- DiscreteRectangle getRectangle()
void updateObjectLocation(GridObject theObject, DiscretePoint2D theLocation)
The method should update both the object's location property, and whatever internal mechanism is used to permit efficient querying of locations for present objects.
Note that the method should also make sure to remove the old record of the object's location, if it has a current location!
theObject
- theLocation
- java.util.Set<GridObject> objectsAtLocation(DiscretePoint2D theLocation)
theLocation
-
boolean locationIsWithinBounds(DiscretePoint2D theLocation)
More complex subclasses may find this useful.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |