Class MapObject

java.lang.Object
org.openpatch.scratch.extensions.tiled.MapObject

public class MapObject extends Object
Represents a map object with various properties such as dimensions, position, visibility, and type. It also provides methods to retrieve property values in different formats and to get a Shape representation of the map object.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    An object representing an ellipse shape.
    double
    The height of the map object.
    int
    The unique identifier of the map object.
    The name of the map object.
    An object representing a point.
    A Polygon object representing a polygon shape.
    A Polyline object representing a polyline shape.
    A list of properties associated with the map object.
    double
    The rotation angle of the map object.
    The type of the map object.
    boolean
    The visibility status of the map object.
    double
    The width of the map object.
    double
    The x-coordinate of the map object.
    double
    The y-coordinate of the map object.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieves the value of a property with the specified name from the properties list.
    boolean
    Retrieves the value of the specified property as a boolean.
    float
    Retrieves the value of a specified property as a float.
    int
    Retrieves the value of a property with the specified name and converts it to an integer.
    Returns a Shape object representing the current map object.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • height

      public double height
      The height of the map object.
    • id

      public int id
      The unique identifier of the map object.
    • name

      public String name
      The name of the map object.
    • rotation

      public double rotation
      The rotation angle of the map object.
    • visible

      public boolean visible
      The visibility status of the map object.
    • width

      public double width
      The width of the map object.
    • type

      public String type
      The type of the map object.
    • x

      public double x
      The x-coordinate of the map object.
    • y

      public double y
      The y-coordinate of the map object.
    • properties

      public List<Property> properties
      A list of properties associated with the map object.
    • ellipse

      public Object ellipse
      An object representing an ellipse shape.
    • point

      public Object point
      An object representing a point.
    • polygon

      public Polygon polygon
      A Polygon object representing a polygon shape.
    • polyline

      public Polyline polyline
      A Polyline object representing a polyline shape.
  • Constructor Details

    • MapObject

      public MapObject()
  • Method Details

    • getPropertyInt

      public int getPropertyInt(String name)
      Retrieves the value of a property with the specified name and converts it to an integer.
      Parameters:
      name - the name of the property to retrieve
      Returns:
      the integer value of the property
      Throws:
      NumberFormatException - if the property value cannot be parsed as an integer
    • getProperty

      public String getProperty(String name)
      Retrieves the value of a property with the specified name from the properties list.
      Parameters:
      name - the name of the property to retrieve
      Returns:
      the value of the property with the specified name
    • getPropertyFloat

      public float getPropertyFloat(String name)
      Retrieves the value of a specified property as a float.
      Parameters:
      name - the name of the property to retrieve
      Returns:
      the float value of the specified property
      Throws:
      NumberFormatException - if the property value cannot be parsed as a float
    • getPropertyBoolean

      public boolean getPropertyBoolean(String name)
      Retrieves the value of the specified property as a boolean.
      Parameters:
      name - the name of the property to retrieve
      Returns:
      the boolean value of the property, or false if the property is not found or cannot be parsed as a boolean
    • getShape

      public Shape getShape()
      Returns a Shape object representing the current map object. The type of Shape returned depends on the properties of the map object: - If the object is a point, a 1x1 rectangle is returned. - If the object is an ellipse, an Ellipse2D object with the specified width and height is returned. - If the object is a polygon, a Polygon object with the specified points is returned. - If none of the above conditions are met, a rectangle with the specified width and height is returned.
      Returns:
      a Shape object representing the current map object.