Class WangColor

java.lang.Object
de.gurkenlabs.litiengine.environment.tilemap.xml.CustomPropertyProvider
de.gurkenlabs.litiengine.environment.tilemap.xml.WangColor
All Implemented Interfaces:
ICustomPropertyProvider, ITerrain

public class WangColor extends CustomPropertyProvider implements ITerrain

One terrain material (a Tiled wangcolor) within a WangSet.

The representative tile and probability guide terrain painting; tile references use local tileset IDs and -1 means that no representative tile is configured.

See Also:
  • Constructor Details

    • WangColor

      public WangColor()
      Creates a white terrain named Terrain without a representative tile.
    • WangColor

      public WangColor(String name, Color color)
      Creates a terrain with default probability 1.
      Parameters:
      name - The terrain name.
      color - The editor display color.
    • WangColor

      public WangColor(WangColor original)
      Creates a copy, including custom properties.
      Parameters:
      original - The terrain to copy.
  • Method Details

    • getName

      public String getName()
      Description copied from interface: ITerrain
      Gets the name of the terrain.
      Specified by:
      getName in interface ITerrain
      Returns:
      A String representing the name of the terrain.
    • setName

      public void setName(String name)
      Sets the terrain name; blank values are normalized to null.
      Parameters:
      name - The new name.
    • getColor

      public Color getColor()
      Description copied from interface: ITerrain
      Gets the color associated with the terrain.
      Specified by:
      getColor in interface ITerrain
      Returns:
      A Color object representing the color of the terrain.
    • setColor

      public void setColor(Color color)
      Sets the editor display color.
      Parameters:
      color - The non-null color.
      Throws:
      NullPointerException - if color is null.
    • getTileId

      public int getTileId()
      Returns the local ID of the representative tile.
      Returns:
      The tile ID, or -1 when none is configured.
    • setTileId

      public void setTileId(int tileId)
      Sets the representative local tile ID.
      Parameters:
      tileId - The tile ID, or -1 for none.
      Throws:
      IllegalArgumentException - if tileId is less than -1.
    • getProbability

      public double getProbability()
      Description copied from interface: ITerrain

      Gets the probability value associated with the terrain.

      The probability value is used in automatic mapping processes to indicate the likelihood or preference of using this terrain in specific contexts. Higher probability values may suggest a higher preference for automatic mapping.

      Specified by:
      getProbability in interface ITerrain
      Returns:
      A double representing the probability value of the terrain.
    • setProbability

      public void setProbability(double probability)
      Sets the relative probability used by terrain painting tools.
      Parameters:
      probability - A finite, non-negative weight.
      Throws:
      IllegalArgumentException - if the value is negative or not finite.
    • toString

      public String toString()
      Overrides:
      toString in class Object