Class Rectangle
- java.lang.Object
-
- de.aristaflow.adept2.model.graphical.Rectangle
-
- All Implemented Interfaces:
Serializable
public class Rectangle extends Object implements Serializable
A simple data class for rectangular areas and points. The area can be either absolute (having coordinates for the top-left corner) or relative.- Author:
- Ulrich Kreher
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
height
The height of the rectangular area.protected boolean
isRelative
Wether the rectangular area is relative that is, it does not have valid coordinates.protected int
width
The width of the rectangular area.protected int
x
The x-coordinate of the top-left corner of the rectangular area or -1 for a relative rectangular area.protected int
y
The y-coordinate of the top-left corner of the rectangular area or -1 for a relative rectangular area.
-
Constructor Summary
Constructors Constructor Description Rectangle(int x, int y, boolean point)
Creates a new point having the designated coordinates or a relative rectangle with the designated extent.Rectangle(int x, int y, int width, int height)
Creates a new rectangle area with the designated coordinates of the top-left corner, and the designated extent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getHeight()
Gets the height of the rectangular area or 0 for a point.int
getWidth()
Gets the width of the rectangular area or 0 for a point.int
getX()
Gets the x-coordinate of the top-left corner of the rectangular area.int
getY()
Gets the y-coordinate of the top-left corner of the rectangular area.boolean
isRelative()
Gets whether the rectangular area is relative and therefore the coordinates are invalid.
-
-
-
Field Detail
-
x
protected final int x
The x-coordinate of the top-left corner of the rectangular area or -1 for a relative rectangular area.
-
y
protected final int y
The y-coordinate of the top-left corner of the rectangular area or -1 for a relative rectangular area.
-
width
protected final int width
The width of the rectangular area.
-
height
protected final int height
The height of the rectangular area.
-
isRelative
protected final boolean isRelative
Wether the rectangular area is relative that is, it does not have valid coordinates.
-
-
Constructor Detail
-
Rectangle
public Rectangle(int x, int y, int width, int height)
Creates a new rectangle area with the designated coordinates of the top-left corner, and the designated extent.- Parameters:
x
- The x-coordinate of the top-left corner of the rectangular area.y
- The y-coordinate of the top-left corner of the rectangular areawidth
- The width of the rectangular area.height
- The height of the rectangular area.
-
Rectangle
public Rectangle(int x, int y, boolean point)
Creates a new point having the designated coordinates or a relative rectangle with the designated extent.- Parameters:
x
- The x-coordinate of the point or the width of the relative rectangular area.y
- The y-coordinate of the point or the height of the relative rectangular area.point
- Whether to create a point (having no extent) or a relative rectangular area.
-
-
Method Detail
-
getX
public int getX()
Gets the x-coordinate of the top-left corner of the rectangular area. In case of a relative rectangular area, the returned value is invalid.- Returns:
- The x-coordinate of the top-left corner of the rectangular area. In case of a relative rectangular area, the returned value is invalid.
-
getY
public int getY()
Gets the y-coordinate of the top-left corner of the rectangular area. In case of a relative rectangular area, the returned value is invalid.- Returns:
- The y-coordinate of the top-left corner of the rectangular area. In case of a relative rectangular area, the returned value is invalid.
-
getWidth
public int getWidth()
Gets the width of the rectangular area or 0 for a point.- Returns:
- The width of the rectangular area or 0 for a point.
-
getHeight
public int getHeight()
Gets the height of the rectangular area or 0 for a point.- Returns:
- The height of the rectangular area or 0 for a point.
-
isRelative
public boolean isRelative()
Gets whether the rectangular area is relative and therefore the coordinates are invalid.- Returns:
- Whether the rectangular area is relative and therefore the coordinates are invalid.
-
-