Package net.sf.freecol.server.generator
Class RiverSection
- java.lang.Object
-
- net.sf.freecol.server.generator.RiverSection
-
public class RiverSection extends java.lang.ObjectThis 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
Fields Modifier and Type Field Description private java.util.Map<Direction,java.lang.Integer>branchesRiver magnitude (size) for each direction toward the edges of the tileDirectiondirectionDirection the river is flowing toward, at the current sectionprivate intsizeRiver magnitude (size) at the center of the tileprivate static char[]templateprivate TiletileTile of the current river section
-
Constructor Summary
Constructors Constructor Description RiverSection(java.util.Map<Direction,java.lang.Integer> branches)Creates a new RiverSection with the given branches.RiverSection(Tile tile, Direction direction)Constructor used to automatically generate rivers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringencodeStyle()private intgetBranch(Direction direction)Gets the size of a branchintgetSize()Returns the sizeTilegetTile()Get the section tile.voidgrow()Increases the size of this section by one.voidgrowBranch(Direction direction, int increment)Increases the size a branchvoidremoveBranch(Direction direction)Removes a branchvoidsetBranch(Direction direction, int size)Sets the size of a branch
-
-
-
Field Detail
-
template
private static final char[] template
-
branches
private java.util.Map<Direction,java.lang.Integer> branches
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 Direction direction
Direction the river is flowing toward, at the current section
-
tile
private Tile tile
Tile of the current river section
-
-
Constructor Detail
-
RiverSection
public RiverSection(java.util.Map<Direction,java.lang.Integer> branches)
Creates a new RiverSection with the given branches. This constructor is used by the map editor.- Parameters:
branches- The encoded style
-
-
Method Detail
-
getTile
public final Tile getTile()
Get the section tile.- Returns:
- The
Tile.
-
getSize
public final int getSize()
Returns the size- Returns:
- size
-
setBranch
public final void setBranch(Direction direction, int size)
Sets the size of a branch- Parameters:
direction- TheDirectionof the branch.size- The size to set.
-
getBranch
private final int getBranch(Direction direction)
Gets the size of a branch- Parameters:
direction- TheDirectionof the branch.- Returns:
- The branch size.
-
removeBranch
public final void removeBranch(Direction direction)
Removes a branch- Parameters:
direction- TheDirectionof the branch.
-
growBranch
public final void growBranch(Direction direction, int increment)
Increases the size a branch- Parameters:
direction- TheDirectionof the branch.increment- The amount to add to the branch size.
-
grow
public void grow()
Increases the size of this section by one.
-
encodeStyle
public java.lang.String encodeStyle()
-
-