net.sf.freecol.server.generator
Class River

java.lang.Object
  extended by net.sf.freecol.server.generator.River

public class River
extends java.lang.Object

A river for the map generator.


Constructor Summary
River(Map map, java.util.Map<Map.Position,River> riverMap, ServerRegion region, java.util.Random random)
          Constructor.
 
Method Summary
 void add(Map.Position position, Map.Direction direction)
          Adds a new section to this river.
 boolean contains(Map.Position p)
          Returns true if this river already contains the given position.
 boolean flowFromSource(Map.Position position)
          Creates a river flowing from the given position if possible.
 RiverSection getLastSection()
           
 int getLength()
          Returns the length of this river.
 ServerRegion getRegion()
          Get the ServerRegion value.
 java.util.List<RiverSection> getSections()
           
 void grow(RiverSection lastSection, Map.Position position)
          Increases the size of this river.
 boolean isNextToSelf(Map.Position p)
          Returns true if the given position is next to this river.
 boolean isNextToWater(Map.Position p)
          Returns true if the given position is next to a river, lake or sea.
 void setRegion(ServerRegion newServerRegion)
          Set the ServerRegion value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

River

public River(Map map,
             java.util.Map<Map.Position,River> riverMap,
             ServerRegion region,
             java.util.Random random)
Constructor.

Parameters:
map - The map on which the river flows.
riverMap - A hashtable of position-river pairs.
region - The region for this river.
random - The Random number source to use.
Method Detail

getSections

public java.util.List<RiverSection> getSections()

getLength

public int getLength()
Returns the length of this river.

Returns:
the length of this river.

getLastSection

public RiverSection getLastSection()

getRegion

public final ServerRegion getRegion()
Get the ServerRegion value.

Returns:
a ServerRegion value

setRegion

public final void setRegion(ServerRegion newServerRegion)
Set the ServerRegion value.

Parameters:
newServerRegion - The new ServerRegion value.

add

public void add(Map.Position position,
                Map.Direction direction)
Adds a new section to this river.

Parameters:
position - Where this section is located.
direction - The direction the river is flowing in.

grow

public void grow(RiverSection lastSection,
                 Map.Position position)
Increases the size of this river.

Parameters:
lastSection - The last section of the river flowing into this one.
position - The position of the confluence.

isNextToSelf

public boolean isNextToSelf(Map.Position p)
Returns true if the given position is next to this river.

Parameters:
p - A map position.
Returns:
true if the given position is next to this river.

isNextToWater

public boolean isNextToWater(Map.Position p)
Returns true if the given position is next to a river, lake or sea.

Parameters:
p - A map position.
Returns:
true if the given position is next to a river, lake or sea.

contains

public boolean contains(Map.Position p)
Returns true if this river already contains the given position.

Parameters:
p - A map position.
Returns:
true if this river already contains the given position.

flowFromSource

public boolean flowFromSource(Map.Position position)
Creates a river flowing from the given position if possible.

Parameters:
position - A map position.
Returns:
true if a river was created, false otherwise.