Skip to content

Commit e84b47a

Browse files
committed
Update Rectangle javadocs.
DEVSIX-742
1 parent 8668eec commit e84b47a

File tree

1 file changed

+87
-4
lines changed

1 file changed

+87
-4
lines changed

kernel/src/main/java/com/itextpdf/kernel/geom/Rectangle.java

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public Rectangle(Rectangle rect) {
7373

7474
/**
7575
* Calculates the common rectangle which includes all the input rectangles.
76+
*
7677
* @param rectangles list of input rectangles.
7778
* @return common rectangle.
7879
*/
@@ -98,6 +99,19 @@ public static Rectangle getCommonRectangle(Rectangle... rectangles) {
9899
return new Rectangle(llx, lly, urx-llx, ury-lly);
99100
}
100101

102+
/**
103+
* Sets the rectangle by the coordinates, specifying its lower left and upper right points. May be used in chain.
104+
* <br/>
105+
* <br/>
106+
* Note: this method will normalize coordinates, so the rectangle will have non negative width and height,
107+
* and its x and y coordinates specified lower left point.
108+
*
109+
* @param llx the X coordinate of lower left point
110+
* @param lly the Y coordinate of lower left point
111+
* @param urx the X coordinate of upper right point
112+
* @param ury the Y coordinate of upper right point
113+
* @return this {@link Rectangle} instance.
114+
*/
101115
public Rectangle setBbox(float llx, float lly, float urx, float ury) {
102116
// If llx is greater than urx, swap them (normalize)
103117
if (llx > urx) {
@@ -118,75 +132,139 @@ public Rectangle setBbox(float llx, float lly, float urx, float ury) {
118132
return this;
119133
}
120134

135+
/**
136+
* Gets the X coordinate of lower left point.
137+
*
138+
* @return the X coordinate of lower left point.
139+
*/
121140
public float getX() {
122141
return x;
123142
}
124143

144+
/**
145+
* Sets the X coordinate of lower left point. May be used in chain.
146+
*
147+
* @param x the X coordinate of lower left point to be set.
148+
* @return this {@link Rectangle} instance.
149+
*/
125150
public Rectangle setX(float x) {
126151
this.x = x;
127152
return this;
128153
}
129154

155+
/**
156+
* Gets the Y coordinate of lower left point.
157+
*
158+
* @return the Y coordinate of lower left point.
159+
*/
130160
public float getY() {
131161
return y;
132162
}
133163

164+
/**
165+
* Sets the Y coordinate of lower left point. May be used in chain.
166+
*
167+
* @param y the Y coordinate of lower left point to be set.
168+
* @return this {@link Rectangle} instance.
169+
*/
134170
public Rectangle setY(float y) {
135171
this.y = y;
136172
return this;
137173
}
138174

175+
/**
176+
* Gets the width of rectangle.
177+
*
178+
* @return the width of rectangle.
179+
*/
139180
public float getWidth() {
140181
return width;
141182
}
142183

184+
/**
185+
* Sets the width of rectangle. May be used in chain.
186+
*
187+
* @param width the the width of rectangle to be set.
188+
* @return this {@link Rectangle} instance.
189+
*/
143190
public Rectangle setWidth(float width) {
144191
this.width = width;
145192
return this;
146193
}
147194

195+
/**
196+
* Gets the height of rectangle.
197+
*
198+
* @return the height of rectangle.
199+
*/
148200
public float getHeight() {
149201
return height;
150202
}
151203

204+
/**
205+
* Sets the height of rectangle. May be used in chain.
206+
*
207+
* @param height the the width of rectangle to be set.
208+
* @return this {@link Rectangle} instance.
209+
*/
152210
public Rectangle setHeight(float height) {
153211
this.height = height;
154212
return this;
155213
}
156214

215+
/**
216+
* Increases the height of rectangle by the given value. May be used in chain.
217+
*
218+
* @param extra the value of the extra height to be added.
219+
* @return this {@link Rectangle} instance.
220+
*/
157221
public Rectangle increaseHeight(float extra) {
158222
this.height += extra;
159223
return this;
160224
}
161225

226+
/**
227+
* Decreases the height of rectangle by the given value. May be used in chain.
228+
*
229+
* @param extra the value of the extra height to be subtracted.
230+
* @return this {@link Rectangle} instance.
231+
*/
162232
public Rectangle decreaseHeight(float extra) {
163233
this.height -= extra;
164234
return this;
165235
}
166236

167237
/**
168-
* Gets llx, the same: {@code getX()}.
238+
* Gets the X coordinate of the left edge of the rectangle. Same as: {@code getX()}.
239+
*
240+
* @return the X coordinate of the left edge of the rectangle.
169241
*/
170242
public float getLeft() {
171243
return x;
172244
}
173245

174246
/**
175-
* Gets urx, the same to {@code getX() + getWidth()}.
247+
* Gets the X coordinate of the right edge of the rectangle. Same as: {@code getX() + getWidth()}.
248+
*
249+
* @return the X coordinate of the right edge of the rectangle.
176250
*/
177251
public float getRight() {
178252
return x + width;
179253
}
180254

181255
/**
182-
* Gets ury, the same to {@code getY() + getHeight()}.
256+
* Gets the Y coordinate of the upper edge of the rectangle. Same as: {@code getY() + getHeight()}.
257+
*
258+
* @return the Y coordinate of the upper edge of the rectangle.
183259
*/
184260
public float getTop() {
185261
return y + height;
186262
}
187263

188264
/**
189-
* Gets lly, the same to {@code getY()}.
265+
* Gets the Y coordinate of the lower edge of the rectangle. Same as: {@code getY()}.
266+
*
267+
* @return the Y coordinate of the lower edge of the rectangle.
190268
*/
191269
public float getBottom() {
192270
return y;
@@ -239,6 +317,11 @@ public String toString() {
239317
getHeight();
240318
}
241319

320+
/**
321+
* Gets the copy of this rectangle.
322+
*
323+
* @return the copied rectangle.
324+
*/
242325
public Rectangle clone() {
243326
return new Rectangle(x, y, width, height);
244327
}

0 commit comments

Comments
 (0)