Class MapObject
java.lang.Object
org.openpatch.scratch.extensions.tiled.MapObject
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
Modifier and TypeFieldDescriptionAn 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
-
Method Summary
Modifier and TypeMethodDescriptiongetProperty
(String name) Retrieves the value of a property with the specified name from the properties list.boolean
getPropertyBoolean
(String name) Retrieves the value of the specified property as a boolean.float
getPropertyFloat
(String name) Retrieves the value of a specified property as a float.int
getPropertyInt
(String name) Retrieves the value of a property with the specified name and converts it to an integer.getShape()
Returns a Shape object representing the current map object.
-
Field Details
-
height
public double heightThe height of the map object. -
id
public int idThe unique identifier of the map object. -
name
The name of the map object. -
rotation
public double rotationThe rotation angle of the map object. -
visible
public boolean visibleThe visibility status of the map object. -
width
public double widthThe width of the map object. -
type
The type of the map object. -
x
public double xThe x-coordinate of the map object. -
y
public double yThe y-coordinate of the map object. -
properties
A list of properties associated with the map object. -
ellipse
An object representing an ellipse shape. -
point
An object representing a point. -
polygon
A Polygon object representing a polygon shape. -
polyline
A Polyline object representing a polyline shape.
-
-
Constructor Details
-
MapObject
public MapObject()
-
-
Method Details
-
getPropertyInt
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
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
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
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
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.
-