public class ExtendableMap extends java.lang.Object implements Map
Constructor and Description |
---|
ExtendableMap()
Creates an empty map.
|
Modifier and Type | Method and Description |
---|---|
void |
addBidirectionalLink(java.lang.String fromLocation,
java.lang.String toLocation,
java.lang.Double distance)
Adds a connection which can be traveled in both direction.
|
void |
addUnidirectionalLink(java.lang.String fromLocation,
java.lang.String toLocation,
java.lang.Double distance)
Adds a one-way connection to the map.
|
void |
clear()
Removes everything.
|
void |
clearLinks()
Clears all connections but keeps location position informations.
|
java.lang.Double |
getDistance(java.lang.String fromLocation,
java.lang.String toLocation)
Returns the travel distance between the two specified locations if they
are linked by a connection and null otherwise.
|
java.util.List<java.lang.String> |
getLocations()
Returns a list of all locations.
|
Point2D |
getPosition(java.lang.String loc)
Returns the position of the specified location as with respect to an
orthogonal coordinate system.
|
java.util.List<java.lang.String> |
getPossibleNextLocations(java.lang.String location)
Answers to the question: Where can I get, following one of the
connections starting at the specified location?
|
java.util.List<java.lang.String> |
getPossiblePrevLocations(java.lang.String location)
Answers to the question: From where can I reach a specified location,
following one of the map connections? This implementation just calls
getPossibleNextLocations(String) as the underlying graph structure
cannot be traversed efficiently in reverse order. |
boolean |
isLocation(java.lang.String str)
Checks whether the given string is the name of a location.
|
java.lang.String |
randomlyGenerateDestination()
Returns a location which is selected by random.
|
void |
removeBidirectionalLink(java.lang.String fromLocation,
java.lang.String toLocation)
Removes the two corresponding one-way connections.
|
void |
removeUnidirectionalLink(java.lang.String fromLocation,
java.lang.String toLocation)
Removes a one-way connection.
|
void |
setDistAndDirToRefLocation(java.lang.String loc,
double dist,
int dir)
Defines the position of a location within the map.
|
void |
setPosition(java.lang.String loc,
double x,
double y)
Defines the position of a location as with respect to an orthogonal
coordinate system.
|
public void clear()
public void clearLinks()
public java.util.List<java.lang.String> getLocations()
getLocations
in interface Map
public boolean isLocation(java.lang.String str)
public java.util.List<java.lang.String> getPossibleNextLocations(java.lang.String location)
getPossibleNextLocations
in interface Map
public java.util.List<java.lang.String> getPossiblePrevLocations(java.lang.String location)
getPossibleNextLocations(String)
as the underlying graph structure
cannot be traversed efficiently in reverse order.getPossiblePrevLocations
in interface Map
public java.lang.Double getDistance(java.lang.String fromLocation, java.lang.String toLocation)
getDistance
in interface Map
public void addUnidirectionalLink(java.lang.String fromLocation, java.lang.String toLocation, java.lang.Double distance)
public void addBidirectionalLink(java.lang.String fromLocation, java.lang.String toLocation, java.lang.Double distance)
public java.lang.String randomlyGenerateDestination()
randomlyGenerateDestination
in interface Map
public void removeUnidirectionalLink(java.lang.String fromLocation, java.lang.String toLocation)
public void removeBidirectionalLink(java.lang.String fromLocation, java.lang.String toLocation)
public void setPosition(java.lang.String loc, double x, double y)
public void setDistAndDirToRefLocation(java.lang.String loc, double dist, int dir)
dist=0
and dir=0
) and all the other location should be placed
relative to it.loc
- location namedist
- distance to a reference positiondir
- bearing (compass direction) in which the location is seen from
the reference positionpublic Point2D getPosition(java.lang.String loc)
getPosition
in interface Map