net.sf.freecol.server.generator
Class RiverSection

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

public class RiverSection
extends java.lang.Object

This class facilitates building, editing the TileImprovement style for rivers Rivers on the Map are composed of many individual TileImprovements displayed on each Tile the river flows through The river TileImprovement on a Tile has a style which represents the inputs/outputs of water to/from neighboring Tiles This class allows manipulation of individual stream(s) to neighboring Tiles (there are many in case of confluence)


Field Summary
private static int[] base
          Base numbers used to encode/decode the river style
private  int[] branch
          River magnitude (size) for each direction toward the edges of the tile
 Map.Direction direction
          Direction the river is flowing toward, at the current section
private  Map.Position position
          Position of the current river section
private  int size
          River magnitude (size) at the center of the tile
 
Constructor Summary
RiverSection(int style)
          Constructor used by the MapEditor to encode/decode the style
RiverSection(Map.Position position, Map.Direction direction)
          Constructor used to automatically generate rivers.
 
Method Summary
 void decodeStyle(int style)
          Decodes the style
 int encodeStyle()
          Encodes the style as a four-digit base-three number.
 int getBranch(Map.Direction direction)
          Gets the size of a branch
 Map.Position getPosition()
          Returns the position
 int getSize()
          Returns the size
 void grow()
          Increases the size of this section by one.
 void growBranch(Map.Direction direction, int increment)
          Increases the size a branch
 void removeBranch(Map.Direction direction)
          Removes a branch
 void setBranch(Map.Direction direction, int size)
          Sets the size of a branch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

base

private static int[] base
Base numbers used to encode/decode the river style


branch

private int[] branch
River magnitude (size) for each direction toward the edges of the tile


size

private int size
River magnitude (size) at the center of the tile


direction

public Map.Direction direction
Direction the river is flowing toward, at the current section


position

private Map.Position position
Position of the current river section

Constructor Detail

RiverSection

public RiverSection(int style)
Constructor used by the MapEditor to encode/decode the style

Parameters:
style - The encoded style

RiverSection

public RiverSection(Map.Position position,
                    Map.Direction direction)
Constructor used to automatically generate rivers.

Parameters:
position - The map position
direction - The direction the river is flowing toward
Method Detail

getPosition

public Map.Position getPosition()
Returns the position

Returns:
position

getSize

public int getSize()
Returns the size

Returns:
size

decodeStyle

public void decodeStyle(int style)
Decodes the style

Parameters:
style -

encodeStyle

public int encodeStyle()
Encodes the style as a four-digit base-three number. The digits correspond to the four directions valid for rivers, namely north east, south east, south west and north west. Each digit is either zero (no river), one (minor river) or two (major river).

Returns:
style

setBranch

public void setBranch(Map.Direction direction,
                      int size)
Sets the size of a branch


getBranch

public int getBranch(Map.Direction direction)
Gets the size of a branch


removeBranch

public void removeBranch(Map.Direction direction)
Removes a branch


growBranch

public void growBranch(Map.Direction direction,
                       int increment)
Increases the size a branch


grow

public void grow()
Increases the size of this section by one.