Class TileData
public class TileData
Represents the tile data for a tile map. This class handles the encoding, compression, and storage of tile data.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUtility class for tile data compression types.static classUtility class for tile data encoding types. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringEncodes the providedTileDatainstance into a string based on its encoding type.protected intRetrieves the height of the tile data.protected intRetrieves the x-axis offset of the tile data.protected intRetrieves the y-axis offset of the tile data.getTiles()Retrieves the list of tiles for the tile data.getValue()protected intgetWidth()Retrieves the width of the tile data.protected booleanChecks if the tile data represents an infinite map.parseBase64Data(String value, String compression) Parses the tile data from a Base64 encoded string.parseCsvData(String value) Parses the tile data from a CSV formatted string.voidsetCompression(String compression) Sets the compression type for the tile data.voidsetEncoding(String encoding) Sets the encoding type for the tile data.protected voidsetMinChunkOffsets(int x, int y) Sets the minimum chunk offsets for the tile data.voidSets the value for the tile data and updates the raw value list.
-
Constructor Details
-
TileData
public TileData()Default constructor for theTileDataclass. This constructor is required for serialization purposes. -
TileData
public TileData(List<Tile> tiles, int width, int height, String encoding, String compression) throws TmxException Constructs a newTileDatainstance with the specified parameters.- Parameters:
tiles- The list of tiles.width- The width of the tile data.height- The height of the tile data.encoding- The encoding type of the tile data.compression- The compression type of the tile data.- Throws:
TmxException- If the encoding or compression type is invalid.
-
TileData
-
-
Method Details
-
getEncoding
-
getCompression
-
getValue
-
setEncoding
Sets the encoding type for the tile data.- Parameters:
encoding- The encoding type to set.
-
setCompression
Sets the compression type for the tile data.- Parameters:
compression- The compression type to set.
-
setValue
Sets the value for the tile data and updates the raw value list.- Parameters:
value- The value to set.
-
getTiles
-
encode
Encodes the providedTileDatainstance into a string based on its encoding type.- Parameters:
data- TheTileDatainstance to encode.- Returns:
- The encoded string representation of the tile data.
- Throws:
IOException- If an I/O error occurs during encoding.
-
setMinChunkOffsets
protected void setMinChunkOffsets(int x, int y) Sets the minimum chunk offsets for the tile data.- Parameters:
x- The minimum chunk offset on the x-axis.y- The minimum chunk offset on the y-axis.
-
isInfinite
protected boolean isInfinite()Checks if the tile data represents an infinite map.- Returns:
trueif the map is infinite,falseotherwise.
-
getWidth
protected int getWidth()Retrieves the width of the tile data. For infinite maps, the width is adjusted based on the chunk offsets.- Returns:
- The width of the tile data.
-
getHeight
protected int getHeight()Retrieves the height of the tile data. For infinite maps, the height is adjusted based on the chunk offsets.- Returns:
- The height of the tile data.
-
getOffsetX
protected int getOffsetX()Retrieves the x-axis offset of the tile data.- Returns:
- The x-axis offset.
-
getOffsetY
protected int getOffsetY()Retrieves the y-axis offset of the tile data.- Returns:
- The y-axis offset.
-
parseBase64Data
protected static List<Tile> parseBase64Data(String value, String compression) throws InvalidTileLayerException Parses the tile data from a Base64 encoded string.- Parameters:
value- The Base64 encoded string containing the tile data.compression- The compression type used on the tile data (e.g., GZIP, ZLIB, or null for no compression).- Returns:
- A list of
Tileobjects parsed from the Base64 encoded string. - Throws:
InvalidTileLayerException- If the Base64 string is invalid or an I/O error occurs during parsing.
-
parseCsvData
Parses the tile data from a CSV formatted string.- Parameters:
value- The CSV formatted string containing the tile data.- Returns:
- A list of
Tileobjects parsed from the CSV string. - Throws:
InvalidTileLayerException- If the CSV string is invalid or an error occurs during parsing.
-