Class TileImprovementStyle


  • public class TileImprovementStyle
    extends java.lang.Object
    Represents the style of a tile improvement, such as a river or road. Since TileImprovementStyles are immutable and some styles are far more common than others (e.g. rivers with two branches are far more common than rivers with a single branch, or three or four branches), the class caches all styles actually used. As of 0.10.6 we use: - Four character encoded strings for rivers: a "0" for no connection, otherwise the string value of the integer magnitude of the river for each of Direction.longSides. - Eight character binary encoded strings for roads: a "0" or "1" for each of Direction.values() These are distinct so that the overlays can vary.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Map<java.lang.String,​TileImprovementStyle> cache
      Cache all TileImprovementStyles.
      private java.lang.String mask
      A key for the forest overlay, derived from the above.
      private java.lang.String style
      A key for the tile improvement style.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private TileImprovementStyle​(java.lang.String style)
      Private constructor, only called in getInstance() below.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static TileImprovementStyle getInstance​(java.lang.String key)
      Gets the style corresponding to the given string.
      java.lang.String getMask()
      Gets the key suitable for looking up an appropriate overlay (forest) image.
      java.lang.String getString()
      Gets the key suitable for looking up an appropriate tile improvement image.
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • cache

        private static final java.util.Map<java.lang.String,​TileImprovementStyle> cache
        Cache all TileImprovementStyles.
      • style

        private final java.lang.String style
        A key for the tile improvement style.
      • mask

        private final java.lang.String mask
        A key for the forest overlay, derived from the above.
    • Constructor Detail

      • TileImprovementStyle

        private TileImprovementStyle​(java.lang.String style)
        Private constructor, only called in getInstance() below.
        Parameters:
        style - The (decoded) style.
    • Method Detail

      • getString

        public java.lang.String getString()
        Gets the key suitable for looking up an appropriate tile improvement image.
        Returns:
        The tile improvement lookup key.
      • getMask

        public java.lang.String getMask()
        Gets the key suitable for looking up an appropriate overlay (forest) image.
        Returns:
        The overlay lookup key.
      • getInstance

        public static TileImprovementStyle getInstance​(java.lang.String key)
        Gets the style corresponding to the given string.
        Parameters:
        key - The key to look up.
        Returns:
        The corresponding TileImprovementStyle.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object