Class Rectangle
java.lang.Object
de.aristaflow.adept2.model.graphical.Rectangle
- All Implemented Interfaces:
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intThe height of the rectangular area.protected final booleanWether the rectangular area is relative that is, it does not have valid coordinates.protected final intThe width of the rectangular area.protected final intThe x-coordinate of the top-left corner of the rectangular area or -1 for a relative rectangular area.protected final intThe y-coordinate of the top-left corner of the rectangular area or -1 for a relative rectangular area. -
Constructor Summary
ConstructorsConstructorDescriptionRectangle(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
Modifier and TypeMethodDescriptionintGets the height of the rectangular area or 0 for a point.intgetWidth()Gets the width of the rectangular area or 0 for a point.intgetX()Gets the x-coordinate of the top-left corner of the rectangular area.intgetY()Gets the y-coordinate of the top-left corner of the rectangular area.booleanGets whether the rectangular area is relative and therefore the coordinates are invalid.
-
Field Details
-
x
protected final int xThe x-coordinate of the top-left corner of the rectangular area or -1 for a relative rectangular area. -
y
protected final int yThe y-coordinate of the top-left corner of the rectangular area or -1 for a relative rectangular area. -
width
protected final int widthThe width of the rectangular area. -
height
protected final int heightThe height of the rectangular area. -
isRelative
protected final boolean isRelativeWether the rectangular area is relative that is, it does not have valid coordinates.
-
-
Constructor Details
-
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 Details
-
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.
-