Package net.sf.freecol.server.generator
Class RiverSection
- java.lang.Object
-
- 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
Fields Modifier and Type Field Description private java.util.Map<Direction,java.lang.Integer>
branches
River magnitude (size) for each direction toward the edges of the tileDirection
direction
Direction the river is flowing toward, at the current sectionprivate int
size
River magnitude (size) at the center of the tileprivate static char[]
template
private Tile
tile
Tile 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.String
encodeStyle()
private int
getBranch(Direction direction)
Gets the size of a branchint
getSize()
Returns the sizeTile
getTile()
Get the section tile.void
grow()
Increases the size of this section by one.void
growBranch(Direction direction, int increment)
Increases the size a branchvoid
removeBranch(Direction direction)
Removes a branchvoid
setBranch(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
- TheDirection
of the branch.size
- The size to set.
-
getBranch
private final int getBranch(Direction direction)
Gets the size of a branch- Parameters:
direction
- TheDirection
of the branch.- Returns:
- The branch size.
-
removeBranch
public final void removeBranch(Direction direction)
Removes a branch- Parameters:
direction
- TheDirection
of the branch.
-
growBranch
public final void growBranch(Direction direction, int increment)
Increases the size a branch- Parameters:
direction
- TheDirection
of 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()
-
-