Class MapUtils

java.lang.Object
net.dermetfan.gdx.maps.MapUtils

public class MapUtils
extends java.lang.Object
provides useful methods for dealing with maps
  • Constructor Summary

    Constructors
    Constructor Description
    MapUtils()  
  • Method Summary

    Modifier and Type Method Description
    static <T> T findProperty​(java.lang.String key, T defaultValue, com.badlogic.gdx.maps.MapProperties... properties)
    Finds a property in an array of MapProperties.
    static <T> T getProperty​(com.badlogic.gdx.maps.MapProperties properties, java.lang.String key, T defaultValue)
    Makes sure the return value is of the desired type (null-safe).
    static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.Map map)  
    static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.MapLayer layer, int indent)  
    static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.MapLayers layers, int indent)  
    static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.MapObject object, int indent)  
    static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.MapObjects objects, int indent)  
    static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.Map map, int indent)  
    static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.MapProperties properties, int indent)  
    static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.tiled.TiledMapTile tile, int indent)  
    static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.tiled.TiledMapTileSet set, int indent)  
    static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.tiled.TiledMapTileSets sets, int indent)  
    static com.badlogic.gdx.math.Vector2 size​(com.badlogic.gdx.maps.tiled.TiledMap map)
    sets the given Vector2 to the max width and height of all tile layers of the given map
    static com.badlogic.gdx.math.Vector2 toIsometricGridPoint​(float x, float y, float cellWidth, float cellHeight)  
    static com.badlogic.gdx.math.Vector2 toIsometricGridPoint​(com.badlogic.gdx.math.Vector2 point, float cellWidth, float cellHeight)
    converts point to its coordinates on an isometric grid
    static com.badlogic.gdx.math.Vector3 toIsometricGridPoint​(com.badlogic.gdx.math.Vector3 point, float cellWidth, float cellHeight)  
    static com.badlogic.gdx.maps.tiled.TiledMapTile[] toTiledMapTileArray​(com.badlogic.gdx.maps.tiled.TiledMapTileSet tiles)
    creates an array of TiledMapTiles from a TiledMapTileSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MapUtils

      public MapUtils()
  • Method Details

    • findProperty

      public static <T> T findProperty​(java.lang.String key, T defaultValue, com.badlogic.gdx.maps.MapProperties... properties)
      Finds a property in an array of MapProperties. If multiple MapProperties contain the value, the later given one's value is returned.
      Type Parameters:
      T - the type of the value
      Parameters:
      key - the key
      defaultValue - the default value
      properties - the MapProperties to search
      Returns:
      the last found value or defaultValue
    • getProperty

      public static <T> T getProperty​(com.badlogic.gdx.maps.MapProperties properties, java.lang.String key, T defaultValue)
      Makes sure the return value is of the desired type (null-safe). If the value of the property is not of the desired type, it will be parsed.
      Parameters:
      properties - the MapProperties to get the value from
      key - the key of the property
      defaultValue - the value to return in case the value was null or an empty String or couldn't be returned
      Returns:
      the key's value as the type of defaultValue
    • readableHierarchy

      public static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.Map map)
      See Also:
      readableHierarchy(com.badlogic.gdx.maps.Map, int)
    • readableHierarchy

      public static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.Map map, int indent)
      Parameters:
      map - the map to represent
      indent - the indentation size (indent is '\t')
      Returns:
      a human-readable hierarchy of the given map and its descendants
    • readableHierarchy

      public static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.tiled.TiledMapTileSets sets, int indent)
      See Also:
      readableHierarchy(com.badlogic.gdx.maps.Map, int)
    • readableHierarchy

      public static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.tiled.TiledMapTileSet set, int indent)
      See Also:
      readableHierarchy(com.badlogic.gdx.maps.Map, int)
    • readableHierarchy

      public static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.tiled.TiledMapTile tile, int indent)
      See Also:
      readableHierarchy(com.badlogic.gdx.maps.Map, int)
    • readableHierarchy

      public static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.MapLayers layers, int indent)
      See Also:
      readableHierarchy(com.badlogic.gdx.maps.Map, int)
    • readableHierarchy

      public static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.MapLayer layer, int indent)
      See Also:
      readableHierarchy(com.badlogic.gdx.maps.Map, int)
    • readableHierarchy

      public static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.MapObjects objects, int indent)
      See Also:
      readableHierarchy(com.badlogic.gdx.maps.Map, int)
    • readableHierarchy

      public static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.MapObject object, int indent)
      See Also:
      readableHierarchy(com.badlogic.gdx.maps.Map, int)
    • readableHierarchy

      public static java.lang.String readableHierarchy​(com.badlogic.gdx.maps.MapProperties properties, int indent)
      See Also:
      readableHierarchy(com.badlogic.gdx.maps.Map, int)
    • toTiledMapTileArray

      public static com.badlogic.gdx.maps.tiled.TiledMapTile[] toTiledMapTileArray​(com.badlogic.gdx.maps.tiled.TiledMapTileSet tiles)
      creates an array of TiledMapTiles from a TiledMapTileSet
      Parameters:
      tiles - the TiledMapTileSet to create an array from
      Returns:
      the array of TiledMapTiles
    • toIsometricGridPoint

      public static com.badlogic.gdx.math.Vector2 toIsometricGridPoint​(com.badlogic.gdx.math.Vector2 point, float cellWidth, float cellHeight)
      converts point to its coordinates on an isometric grid
      Parameters:
      point - the point to convert
      cellWidth - the width of the grid cells
      cellHeight - the height of the grid cells
      Returns:
      the given point converted to its coordinates on an isometric grid
    • toIsometricGridPoint

      public static com.badlogic.gdx.math.Vector2 toIsometricGridPoint​(float x, float y, float cellWidth, float cellHeight)
      See Also:
      toIsometricGridPoint(Vector2, float, float)
    • toIsometricGridPoint

      public static com.badlogic.gdx.math.Vector3 toIsometricGridPoint​(com.badlogic.gdx.math.Vector3 point, float cellWidth, float cellHeight)
      See Also:
      toIsometricGridPoint(Vector2, float, float)
    • size

      public static com.badlogic.gdx.math.Vector2 size​(com.badlogic.gdx.maps.tiled.TiledMap map)
      sets the given Vector2 to the max width and height of all tile layers of the given map
      Parameters:
      map - the map to measure
      Returns:
      the given Vector2 representing the map size