Skip to content

Commit e1f7918

Browse files
committed
docs: Add JavaDoc for createFromMinAndMax
Adds JavaDoc to explain what the methods are doing and to state contracts and guarantees.
1 parent a4a74e3 commit e1f7918

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

nui/src/main/java/org/terasology/nui/util/RectUtility.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,74 @@ public final class RectUtility {
1010
private RectUtility() {
1111
}
1212

13+
/**
14+
* Create a 2D axis-aligned rectangle at bottom-left anchor position with given size.
15+
*
16+
* The result is guaranteed to be valid. If either width or height are negative an empty rectangle is returned.
17+
* If creating a rectangle of requested size would exceed the integer range the maximal rectangle that still fits
18+
* into the range is returned.
19+
*
20+
* @param minX the x-coordinate of the bottom-left corner
21+
* @param minY the y-coordinate of the bottom-left corner
22+
* @param width the width (x-direction)
23+
* @param height the height (y-direction)
24+
*
25+
* @return a 2D axis-aligned rectangle as specified, or an empty rectangle if either width or height are negative
26+
*/
1327
public static Rectanglei createFromMinAndSize(int minX, int minY, int width, int height) {
1428
final int maxX = NUIMathUtil.addClampAtMax(minX, width);
1529
final int maxY = NUIMathUtil.addClampAtMax(minY, height);
1630
final Rectanglei rect = new Rectanglei(minX, minY, maxX, maxY);
1731
return rect.isValid() ? rect : new Rectanglei();
1832
}
1933

34+
/**
35+
* Create a 2D axis-aligned rectangle at bottom-left anchor position with given size.
36+
*
37+
* The result is guaranteed to be valid. If either width or height are negative an empty rectangle is returned.
38+
* If creating a rectangle of requested size would exceed the integer range the maximal rectangle that still fits
39+
* into the range is returned.
40+
*
41+
* @param min the coordinates of the bottom-left corner
42+
* @param size the size of the rectangle
43+
* @return a 2D axis-aligned rectangle as specified, or an empty rectangle if either width or height are negative
44+
*/
2045
public static Rectanglei createFromMinAndSize(Vector2i min, Vector2i size) {
2146
return createFromMinAndSize(min.x, min.y, size.x, size.y);
2247
}
2348

49+
/**
50+
* Create a 2D axis-aligned rectangle at bottom-left anchor position with given size.
51+
*
52+
* The result is guaranteed to be valid. If either width or height are negative an empty rectangle is returned.
53+
* If creating a rectangle of requested size would exceed the integer range the maximal rectangle that still fits
54+
* into the range is returned.
55+
*
56+
* @param minX the x-coordinate of the bottom-left corner
57+
* @param minY the y-coordinate of the bottom-left corner
58+
* @param width the width (x-direction)
59+
* @param height the height (y-direction)
60+
*
61+
* @return a 2D axis-aligned rectangle as specified, or an empty rectangle if either width or height are negative
62+
*/
2463
public static Rectanglef createFromMinAndSize(float minX, float minY, float width, float height) {
2564
final float maxX = NUIMathUtil.addClampAtMax(minX, width);
2665
final float maxY = NUIMathUtil.addClampAtMax(minY, height);
2766
final Rectanglef rect = new Rectanglef(minX, minY, maxX, maxY);
2867
return rect.isValid() ? rect : new Rectanglef();
2968
}
3069

70+
/**
71+
* Create a 2D axis-aligned rectangle at bottom-left anchor position with given size.
72+
*
73+
* The result is guaranteed to be valid. If either width or height are negative an empty rectangle is returned.
74+
* If creating a rectangle of requested size would exceed the integer range the maximal rectangle that still fits
75+
* into the range is returned.
76+
*
77+
* @param min the coordinates of the bottom-left corner
78+
* @param size the size of the rectangle
79+
* @return a 2D axis-aligned rectangle as specified, or an empty rectangle if either width or height are negative
80+
*/
3181
public static Rectanglef createFromMinAndSize(Vector2f min, Vector2f size) {
3282
return createFromMinAndSize(min.x, min.y, size.x, size.y);
3383
}

0 commit comments

Comments
 (0)