Class Tileset

java.lang.Object
de.gurkenlabs.litiengine.environment.tilemap.xml.CustomPropertyProvider
de.gurkenlabs.litiengine.environment.tilemap.xml.Tileset
All Implemented Interfaces:
ICustomPropertyProvider, ITileset, Resource, Comparable<Resource>

public class Tileset extends CustomPropertyProvider implements ITileset
The Tileset class represents a collection of tiles used in a tile-based map. It extends the CustomPropertyProvider class and implements the ITileset interface. This class provides various properties and methods to manage and access tileset information.
  • Field Details

  • Constructor Details

    • Tileset

      public Tileset()
      Default constructor for the Tileset class. Initializes a new instance of the Tileset class and sets up a listener to clear the sprite sheet when images are cleared.
    • Tileset

      public Tileset(Tileset original)
      Copy constructor for the Tileset class. Creates a new instance of the Tileset class by copying the properties from the provided Tileset object.
      Parameters:
      original - The original Tileset object to copy from.
    • Tileset

      public Tileset(Tileset original, int firstGridId)
      Creates a map-local copy of a tileset with the supplied first global tile ID.
      Parameters:
      original - the project tileset to copy
      firstGridId - the first global tile ID assigned to the copy
  • Method Details

    • copyFrom

      public void copyFrom(Tileset original)
    • copyTerrainSetsFrom

      public void copyTerrainSetsFrom(Tileset original)
    • enrichTerrainMetadataFrom

      public void enrichTerrainMetadataFrom(Tileset original)
    • getProperties

      public Map<String, ICustomProperty> getProperties()
      Description copied from interface: ICustomPropertyProvider
      Returns a Map view of the custom properties for this ICustomPropertyProvider.
      Specified by:
      getProperties in interface ICustomPropertyProvider
      Overrides:
      getProperties in class CustomPropertyProvider
      Returns:
      a Map view of the custom properties for this ICustomPropertyProvider
    • getFirstGridId

      public int getFirstGridId()
      Description copied from interface: ITileset
      Gets the first grid id.
      Specified by:
      getFirstGridId in interface ITileset
      Returns:
      the first grid id
    • setFirstGridId

      public void setFirstGridId(int firstGridId)
      Sets the first global tile ID used by this tileset in its containing map.
      Parameters:
      firstGridId - the first global tile ID, starting at 1
    • getImage

      public IMapImage getImage()
      Description copied from interface: ITileset
      Gets the image.
      Specified by:
      getImage in interface ITileset
      Returns:
      the image
    • setImage

      public void setImage(MapImage image)
    • setMargin

      public void setMargin(int margin)
    • setSpacing

      public void setSpacing(int spacing)
    • getMargin

      public int getMargin()
      Gets the margin.
      Specified by:
      getMargin in interface ITileset
      Returns:
      the margin
    • getName

      public String getName()
      Description copied from interface: Resource
      Gets the name of the resource.
      Specified by:
      getName in interface Resource
      Returns:
      The name of the resource.
    • getSource

      public String getSource()
    • getSourceTileset

      public Tileset getSourceTileset()
    • setName

      public void setName(String name)
      Description copied from interface: Resource
      Sets the name of the resource.
      Specified by:
      setName in interface Resource
      Parameters:
      name - The new name of the resource.
    • setSource

      public void setSource(String source)
    • getSpacing

      public int getSpacing()
      Gets the spacing.
      Specified by:
      getSpacing in interface ITileset
      Returns:
      the spacing
    • getSpritesheet

      public Spritesheet getSpritesheet()
      Description copied from interface: ITileset
      Gets the spritesheet that contains the rendered tile images.
      Specified by:
      getSpritesheet in interface ITileset
      Returns:
      the spritesheet
    • getTileDimension

      public Dimension getTileDimension()
      Description copied from interface: ITileset
      Gets the tile dimension.
      Specified by:
      getTileDimension in interface ITileset
      Returns:
      the tile dimension
    • getTileHeight

      public int getTileHeight()
      Gets the tile height.
      Specified by:
      getTileHeight in interface ITileset
      Returns:
      the tile height
    • getTileWidth

      public int getTileWidth()
      Gets the tile width.
      Specified by:
      getTileWidth in interface ITileset
      Returns:
      the tile width
    • setTileWidth

      public void setTileWidth(int tileWidth)
    • getColumns

      public int getColumns()
      Description copied from interface: ITileset
      Gets the number of tile columns in the tileset.
      Specified by:
      getColumns in interface ITileset
      Returns:
      the number of columns
    • setTileHeight

      public void setTileHeight(int tileHeight)
    • setColumns

      public void setColumns(int columns)
    • setTileCount

      public void setTileCount(int tileCount)
    • getTileOffset

      public ITileOffset getTileOffset()
      Description copied from interface: ITileset
      Gets the per-tileset rendering offset.
      Specified by:
      getTileOffset in interface ITileset
      Returns:
      the tile offset
    • setTileOffset

      public void setTileOffset(int x, int y)
    • getTileCount

      public int getTileCount()
      Description copied from interface: ITileset
      Gets the total number of tiles defined by this tileset.
      Specified by:
      getTileCount in interface ITileset
      Returns:
      the tile count
    • getTile

      public ITilesetEntry getTile(int id)
      Description copied from interface: ITileset
      Gets the tileset entry with the given local id.
      Specified by:
      getTile in interface ITileset
      Parameters:
      id - the local tile id
      Returns:
      the tileset entry, or null if no such entry exists
    • getTransformations

      public TileTransformations getTransformations()
      Gets the tile transformations.
      Returns:
      the tile transformations
    • getTilesetClass

      public String getTilesetClass()
      Gets the tileset class.
      Returns:
      the tileset class
    • getObjectalignment

      public String getObjectalignment()
      Gets the object alignment.
      Returns:
      the object alignment
    • setObjectalignment

      public void setObjectalignment(String objectalignment)
    • getTilerendersize

      public String getTilerendersize()
      Gets the tile render size.
      Returns:
      the tile render size
    • setTilerendersize

      public void setTilerendersize(String tilerendersize)
    • getFillmode

      public String getFillmode()
      Gets the fill mode.
      Returns:
      the fill mode
    • setFillmode

      public void setFillmode(String fillmode)
    • containsTile

      public boolean containsTile(ITile tile)
      Description copied from interface: ITileset
      Returns whether this tileset contains the supplied tile.
      Specified by:
      containsTile in interface ITileset
      Parameters:
      tile - the tile to test
      Returns:
      true if this tileset contains the tile
    • containsTile

      public boolean containsTile(int tileId)
      Description copied from interface: ITileset
      Returns whether this tileset contains a tile with the supplied global id.
      Specified by:
      containsTile in interface ITileset
      Parameters:
      tileId - the global tile id
      Returns:
      true if the global id belongs to this tileset
    • getTerrainSets

      public List<ITerrainSet> getTerrainSets()
      Description copied from interface: ITileset
      Gets the terrain sets defined by this tile set.
      Specified by:
      getTerrainSets in interface ITileset
      Returns:
      The terrain sets of this instance.
    • getOrCreateTerrainSets

      public List<ITerrainSet> getOrCreateTerrainSets()
    • containsTile

      public boolean containsTile(ITilesetEntry entry)
      Description copied from interface: ITileset
      Returns whether this tileset contains the supplied tileset entry.
      Specified by:
      containsTile in interface ITileset
      Parameters:
      entry - the entry to test
      Returns:
      true if this tileset contains the entry
    • finish

      public void finish(URL location) throws TmxException
      Throws:
      TmxException
    • saveSource

      public void saveSource(Path path)
      Saves the source tileset to the specified base path.
      Parameters:
      path - The base path where the source tileset should be saved.
    • isExternal

      public boolean isExternal()
      Checks if the tileset is external.
      Returns:
      true if the tileset is external, false otherwise.
    • load

      public void load(List<Tileset> rawTilesets)
      Loads the source tileset from the provided list of raw tilesets.
      Parameters:
      rawTilesets - The list of raw tilesets to load the source tileset from.