1 | /* | |
2 | * $Id: Rectangle.java 3742 2009-03-03 16:42:09Z blowagie $ | |
3 | * | |
4 | * Copyright 1999, 2000, 2001, 2002 by Bruno Lowagie. | |
5 | * | |
6 | * The contents of this file are subject to the Mozilla Public License Version 1.1 | |
7 | * (the "License"); you may not use this file except in compliance with the License. | |
8 | * You may obtain a copy of the License at http://www.mozilla.org/MPL/ | |
9 | * | |
10 | * Software distributed under the License is distributed on an "AS IS" basis, | |
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
12 | * for the specific language governing rights and limitations under the License. | |
13 | * | |
14 | * The Original Code is 'iText, a free JAVA-PDF library'. | |
15 | * | |
16 | * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by | |
17 | * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie. | |
18 | * All Rights Reserved. | |
19 | * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer | |
20 | * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved. | |
21 | * | |
22 | * Contributor(s): all the names of the contributors are added in the source code | |
23 | * where applicable. | |
24 | * | |
25 | * Alternatively, the contents of this file may be used under the terms of the | |
26 | * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the | |
27 | * provisions of LGPL are applicable instead of those above. If you wish to | |
28 | * allow use of your version of this file only under the terms of the LGPL | |
29 | * License and not to allow others to use your version of this file under | |
30 | * the MPL, indicate your decision by deleting the provisions above and | |
31 | * replace them with the notice and other provisions required by the LGPL. | |
32 | * If you do not delete the provisions above, a recipient may use your version | |
33 | * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. | |
34 | * | |
35 | * This library is free software; you can redistribute it and/or modify it | |
36 | * under the terms of the MPL as stated above or under the terms of the GNU | |
37 | * Library General Public License as published by the Free Software Foundation; | |
38 | * either version 2 of the License, or any later version. | |
39 | * | |
40 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
41 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
42 | * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more | |
43 | * details. | |
44 | * | |
45 | * If you didn't download this code from the following link, you should check if | |
46 | * you aren't using an obsolete version: | |
47 | * http://www.lowagie.com/iText/ | |
48 | */ | |
49 | package com.lowagie.text; | |
50 | ||
51 | import java.awt.Color; | |
52 | import java.util.ArrayList; | |
53 | ||
54 | import com.lowagie.text.pdf.GrayColor; | |
55 | ||
56 | /** | |
57 | * A <CODE>Rectangle</CODE> is the representation of a geometric figure. | |
58 | * | |
59 | * Rectangles support constant width borders using | |
60 | * {@link #setBorderWidth(float)}and {@link #setBorder(int)}. They also support | |
61 | * borders that vary in width/color on each side using methods like | |
62 | * {@link #setBorderWidthLeft(float)}or | |
63 | * {@link #setBorderColorLeft(java.awt.Color)}. | |
64 | * | |
65 | * @see Element | |
66 | * @see Table | |
67 | * @see Cell | |
68 | * @see HeaderFooter | |
69 | */ | |
70 | public class Rectangle implements Element { | |
71 | ||
72 | // CONSTANTS: | |
73 | ||
74 | /** This is the value that will be used as <VAR>undefined </VAR>. */ | |
75 | public static final int UNDEFINED = -1; | |
76 | ||
77 | /** This represents one side of the border of the <CODE>Rectangle</CODE>. */ | |
78 | public static final int TOP = 1; | |
79 | ||
80 | /** This represents one side of the border of the <CODE>Rectangle</CODE>. */ | |
81 | public static final int BOTTOM = 2; | |
82 | ||
83 | /** This represents one side of the border of the <CODE>Rectangle</CODE>. */ | |
84 | public static final int LEFT = 4; | |
85 | ||
86 | /** This represents one side of the border of the <CODE>Rectangle</CODE>. */ | |
87 | public static final int RIGHT = 8; | |
88 | ||
89 | /** This represents a rectangle without borders. */ | |
90 | public static final int NO_BORDER = 0; | |
91 | ||
92 | /** This represents a type of border. */ | |
93 | public static final int BOX = TOP + BOTTOM + LEFT + RIGHT; | |
94 | ||
95 | // MEMBER VARIABLES: | |
96 | ||
97 | /** the lower left x-coordinate. */ | |
98 | protected float llx; | |
99 | ||
100 | /** the lower left y-coordinate. */ | |
101 | protected float lly; | |
102 | ||
103 | /** the upper right x-coordinate. */ | |
104 | protected float urx; | |
105 | ||
106 | /** the upper right y-coordinate. */ | |
107 | protected float ury; | |
108 | ||
109 | /** The rotation of the Rectangle */ | |
110 | protected int rotation = 0; | |
111 | ||
112 | /** This is the color of the background of this rectangle. */ | |
113 | protected Color backgroundColor = null; | |
114 | ||
115 | /** This represents the status of the 4 sides of the rectangle. */ | |
116 | protected int border = UNDEFINED; | |
117 | ||
118 | /** Whether variable width/color borders are used. */ | |
119 | protected boolean useVariableBorders = false; | |
120 | ||
121 | /** This is the width of the border around this rectangle. */ | |
122 | protected float borderWidth = UNDEFINED; | |
123 | ||
124 | /** The width of the left border of this rectangle. */ | |
125 | protected float borderWidthLeft = UNDEFINED; | |
126 | ||
127 | /** The width of the right border of this rectangle. */ | |
128 | protected float borderWidthRight = UNDEFINED; | |
129 | ||
130 | /** The width of the top border of this rectangle. */ | |
131 | protected float borderWidthTop = UNDEFINED; | |
132 | ||
133 | /** The width of the bottom border of this rectangle. */ | |
134 | protected float borderWidthBottom = UNDEFINED; | |
135 | ||
136 | /** The color of the border of this rectangle. */ | |
137 | protected Color borderColor = null; | |
138 | ||
139 | /** The color of the left border of this rectangle. */ | |
140 | protected Color borderColorLeft = null; | |
141 | ||
142 | /** The color of the right border of this rectangle. */ | |
143 | protected Color borderColorRight = null; | |
144 | ||
145 | /** The color of the top border of this rectangle. */ | |
146 | protected Color borderColorTop = null; | |
147 | ||
148 | /** The color of the bottom border of this rectangle. */ | |
149 | protected Color borderColorBottom = null; | |
150 | ||
151 | // CONSTRUCTORS: | |
152 | ||
153 | /** | |
154 | * Constructs a <CODE>Rectangle</CODE> -object. | |
155 | * | |
156 | * @param llx | |
157 | * lower left x | |
158 | * @param lly | |
159 | * lower left y | |
160 | * @param urx | |
161 | * upper right x | |
162 | * @param ury | |
163 | * upper right y | |
164 | */ | |
165 | public Rectangle(float llx, float lly, float urx, float ury) { | |
166 | this.llx = llx; | |
167 | this.lly = lly; | |
168 | this.urx = urx; | |
169 | this.ury = ury; | |
170 | } | |
171 | ||
172 | /** | |
173 | * Constructs a <CODE>Rectangle</CODE> -object starting from the origin (0, | |
174 | * 0). | |
175 | * | |
176 | * @param urx | |
177 | * upper right x | |
178 | * @param ury | |
179 | * upper right y | |
180 | */ | |
181 | public Rectangle(float urx, float ury) { | |
182 | this(0, 0, urx, ury); | |
183 | } | |
184 | ||
185 | // OJO... Modificacion de | |
186 | // flopez------------------------------------------------- | |
187 | /** | |
188 | * Constructs a <CODE>Rectangle</CODE> -object. | |
189 | * | |
190 | * @param llx | |
191 | * lower left x | |
192 | * @param lly | |
193 | * lower left y | |
194 | * @param urx | |
195 | * upper right x | |
196 | * @param ury | |
197 | * upper right y | |
198 | * @param rotation | |
199 | * 0, 90, 180, or 270 grades | |
200 | */ | |
201 | public Rectangle(float llx, float lly, float urx, float ury, int rotation) { | |
202 | this(llx, lly, urx, ury); | |
203 |
1
1. |
setRotation(rotation); |
204 | } | |
205 | ||
206 | /** | |
207 | * Constructs a <CODE>Rectangle</CODE> -object starting from the origin (0, | |
208 | * 0). | |
209 | * | |
210 | * @param urx | |
211 | * upper right x | |
212 | * @param ury | |
213 | * upper right y | |
214 | * @param rotation | |
215 | * 0, 90, 180, or 270 grades | |
216 | */ | |
217 | public Rectangle(float urx, float ury, int rotation) { | |
218 | this(0, 0, urx, ury); | |
219 |
1
1. |
setRotation(rotation); |
220 | } | |
221 | ||
222 | /** | |
223 | * Sets the rotation of the rectangle. Valid values are 0, 90, 180, and 270. | |
224 | * | |
225 | * @param rotation | |
226 | * the new rotation value | |
227 | * @since iText 5.0.6 | |
228 | */ | |
229 | public void setRotation(final int rotation) { | |
230 |
1
1. setRotation : Replaced integer modulus with multiplication → NO_COVERAGE |
int mod = rotation % 360; |
231 |
3
1. setRotation : negated conditional → NO_COVERAGE 2. setRotation : negated conditional → NO_COVERAGE 3. setRotation : negated conditional → NO_COVERAGE |
if ((mod == 90) || (mod == 180) || (mod == 270)) { |
232 | this.rotation = mod; | |
233 | } else { | |
234 | this.rotation = 0; | |
235 | } | |
236 | } | |
237 | ||
238 | // ****************************************************************************** | |
239 | ||
240 | /** | |
241 | * Constructs a <CODE>Rectangle</CODE> -object. | |
242 | * | |
243 | * @param rect | |
244 | * another <CODE>Rectangle</CODE> | |
245 | */ | |
246 | public Rectangle(Rectangle rect) { | |
247 | this(rect.llx, rect.lly, rect.urx, rect.ury); | |
248 |
1
1. |
cloneNonPositionParameters(rect); |
249 | } | |
250 | ||
251 | // IMPLEMENTATION OF THE ELEMENT INTERFACE:e | |
252 | ||
253 | /** | |
254 | * Processes the element by adding it (or the different parts) to an | |
255 | * <CODE>ElementListener</CODE>. | |
256 | * | |
257 | * @param listener | |
258 | * an <CODE>ElementListener</CODE> | |
259 | * @return <CODE>true</CODE> if the element was processed successfully | |
260 | */ | |
261 | @Override | |
262 | public boolean process(ElementListener listener) { | |
263 | try { | |
264 |
1
1. process : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return listener.add(this); |
265 | } catch (DocumentException de) { | |
266 |
1
1. process : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
267 | } | |
268 | } | |
269 | ||
270 | /** | |
271 | * Gets the type of the text element. | |
272 | * | |
273 | * @return a type | |
274 | */ | |
275 | @Override | |
276 | public int type() { | |
277 | return Element.RECTANGLE; | |
278 | } | |
279 | ||
280 | /** | |
281 | * Gets all the chunks in this element. | |
282 | * | |
283 | * @return an <CODE>ArrayList</CODE> | |
284 | */ | |
285 | @Override | |
286 | public ArrayList getChunks() { | |
287 |
1
1. getChunks : mutated return of Object value for com/lowagie/text/Rectangle::getChunks to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new ArrayList(); |
288 | } | |
289 | ||
290 | /** | |
291 | * @see com.lowagie.text.Element#isContent() | |
292 | * @since iText 2.0.8 | |
293 | */ | |
294 | @Override | |
295 | public boolean isContent() { | |
296 | return true; | |
297 | } | |
298 | ||
299 | /** | |
300 | * @see com.lowagie.text.Element#isNestable() | |
301 | * @since iText 2.0.8 | |
302 | */ | |
303 | @Override | |
304 | public boolean isNestable() { | |
305 | return false; | |
306 | } | |
307 | ||
308 | // METHODS TO GET/SET THE DIMENSIONS: | |
309 | ||
310 | /** | |
311 | * Sets the lower left x-coordinate. | |
312 | * | |
313 | * @param llx | |
314 | * the new value | |
315 | */ | |
316 | public void setLeft(float llx) { | |
317 | this.llx = llx; | |
318 | } | |
319 | ||
320 | /** | |
321 | * Returns the lower left x-coordinate. | |
322 | * | |
323 | * @return the lower left x-coordinate | |
324 | */ | |
325 | public float getLeft() { | |
326 | return llx; | |
327 | } | |
328 | ||
329 | /** | |
330 | * Returns the lower left x-coordinate, considering a given margin. | |
331 | * | |
332 | * @param margin | |
333 | * a margin | |
334 | * @return the lower left x-coordinate | |
335 | */ | |
336 | public float getLeft(float margin) { | |
337 |
2
1. getLeft : Replaced float addition with subtraction → NO_COVERAGE 2. getLeft : replaced return of float value with -(x + 1) for com/lowagie/text/Rectangle::getLeft → NO_COVERAGE |
return llx + margin; |
338 | } | |
339 | ||
340 | /** | |
341 | * Sets the upper right x-coordinate. | |
342 | * | |
343 | * @param urx | |
344 | * the new value | |
345 | */ | |
346 | public void setRight(float urx) { | |
347 | this.urx = urx; | |
348 | } | |
349 | ||
350 | /** | |
351 | * Returns the upper right x-coordinate. | |
352 | * | |
353 | * @return the upper right x-coordinate | |
354 | */ | |
355 | public float getRight() { | |
356 | return urx; | |
357 | } | |
358 | ||
359 | /** | |
360 | * Returns the upper right x-coordinate, considering a given margin. | |
361 | * | |
362 | * @param margin | |
363 | * a margin | |
364 | * @return the upper right x-coordinate | |
365 | */ | |
366 | public float getRight(float margin) { | |
367 |
2
1. getRight : Replaced float subtraction with addition → NO_COVERAGE 2. getRight : replaced return of float value with -(x + 1) for com/lowagie/text/Rectangle::getRight → NO_COVERAGE |
return urx - margin; |
368 | } | |
369 | ||
370 | /** | |
371 | * Returns the width of the rectangle. | |
372 | * | |
373 | * @return the width | |
374 | */ | |
375 | public float getWidth() { | |
376 |
2
1. getWidth : Replaced float subtraction with addition → NO_COVERAGE 2. getWidth : replaced return of float value with -(x + 1) for com/lowagie/text/Rectangle::getWidth → NO_COVERAGE |
return urx - llx; |
377 | } | |
378 | ||
379 | /** | |
380 | * Sets the upper right y-coordinate. | |
381 | * | |
382 | * @param ury | |
383 | * the new value | |
384 | */ | |
385 | public void setTop(float ury) { | |
386 | this.ury = ury; | |
387 | } | |
388 | ||
389 | /** | |
390 | * Returns the upper right y-coordinate. | |
391 | * | |
392 | * @return the upper right y-coordinate | |
393 | */ | |
394 | public float getTop() { | |
395 | return ury; | |
396 | } | |
397 | ||
398 | /** | |
399 | * Returns the upper right y-coordinate, considering a given margin. | |
400 | * | |
401 | * @param margin | |
402 | * a margin | |
403 | * @return the upper right y-coordinate | |
404 | */ | |
405 | public float getTop(float margin) { | |
406 |
2
1. getTop : Replaced float subtraction with addition → NO_COVERAGE 2. getTop : replaced return of float value with -(x + 1) for com/lowagie/text/Rectangle::getTop → NO_COVERAGE |
return ury - margin; |
407 | } | |
408 | ||
409 | /** | |
410 | * Sets the lower left y-coordinate. | |
411 | * | |
412 | * @param lly | |
413 | * the new value | |
414 | */ | |
415 | public void setBottom(float lly) { | |
416 | this.lly = lly; | |
417 | } | |
418 | ||
419 | /** | |
420 | * Returns the lower left y-coordinate. | |
421 | * | |
422 | * @return the lower left y-coordinate | |
423 | */ | |
424 | public float getBottom() { | |
425 | return lly; | |
426 | } | |
427 | ||
428 | /** | |
429 | * Returns the lower left y-coordinate, considering a given margin. | |
430 | * | |
431 | * @param margin | |
432 | * a margin | |
433 | * @return the lower left y-coordinate | |
434 | */ | |
435 | public float getBottom(float margin) { | |
436 |
2
1. getBottom : Replaced float addition with subtraction → NO_COVERAGE 2. getBottom : replaced return of float value with -(x + 1) for com/lowagie/text/Rectangle::getBottom → NO_COVERAGE |
return lly + margin; |
437 | } | |
438 | ||
439 | /** | |
440 | * Returns the height of the rectangle. | |
441 | * | |
442 | * @return the height | |
443 | */ | |
444 | public float getHeight() { | |
445 |
2
1. getHeight : Replaced float subtraction with addition → NO_COVERAGE 2. getHeight : replaced return of float value with -(x + 1) for com/lowagie/text/Rectangle::getHeight → NO_COVERAGE |
return ury - lly; |
446 | } | |
447 | ||
448 | /** | |
449 | * Normalizes the rectangle. Switches lower left with upper right if | |
450 | * necessary. | |
451 | */ | |
452 | public void normalize() { | |
453 |
2
1. normalize : changed conditional boundary → NO_COVERAGE 2. normalize : negated conditional → NO_COVERAGE |
if (llx > urx) { |
454 | float a = llx; | |
455 | llx = urx; | |
456 | urx = a; | |
457 | } | |
458 |
2
1. normalize : changed conditional boundary → NO_COVERAGE 2. normalize : negated conditional → NO_COVERAGE |
if (lly > ury) { |
459 | float a = lly; | |
460 | lly = ury; | |
461 | ury = a; | |
462 | } | |
463 | } | |
464 | ||
465 | // METHODS TO GET/SET THE ROTATION: | |
466 | ||
467 | /** | |
468 | * Gets the rotation of the rectangle | |
469 | * | |
470 | * @return a rotation value | |
471 | */ | |
472 | public int getRotation() { | |
473 | return rotation; | |
474 | } | |
475 | ||
476 | /** | |
477 | * Rotates the rectangle. Swaps the values of llx and lly and of urx and ury. | |
478 | * | |
479 | * @return the rotated <CODE>Rectangle</CODE> | |
480 | */ | |
481 | public Rectangle rotate() { | |
482 | Rectangle rect = new Rectangle(lly, llx, ury, urx); | |
483 |
1
1. rotate : Replaced integer addition with subtraction → NO_COVERAGE |
rect.rotation = rotation + 90; |
484 |
1
1. rotate : Replaced integer modulus with multiplication → NO_COVERAGE |
rect.rotation %= 360; |
485 |
1
1. rotate : mutated return of Object value for com/lowagie/text/Rectangle::rotate to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return rect; |
486 | } | |
487 | ||
488 | // METHODS TO GET/SET THE BACKGROUND COLOR: | |
489 | ||
490 | /** | |
491 | * Gets the backgroundcolor. | |
492 | * | |
493 | * @return a <CODE>Color</CODE> | |
494 | */ | |
495 | public Color getBackgroundColor() { | |
496 | return backgroundColor; | |
497 | } | |
498 | ||
499 | /** | |
500 | * Sets the backgroundcolor of the rectangle. | |
501 | * | |
502 | * @param backgroundColor | |
503 | * a <CODE>Color</CODE> | |
504 | */ | |
505 | ||
506 | public void setBackgroundColor(Color backgroundColor) { | |
507 | this.backgroundColor = backgroundColor; | |
508 | } | |
509 | ||
510 | /** | |
511 | * Gets the grayscale. | |
512 | * | |
513 | * @return the grayscale color of the background or 0 if the background has no | |
514 | * grayscale color. | |
515 | */ | |
516 | public float getGrayFill() { | |
517 |
1
1. getGrayFill : negated conditional → NO_COVERAGE |
if (backgroundColor instanceof GrayColor) |
518 |
1
1. getGrayFill : replaced return of float value with -(x + 1) for com/lowagie/text/Rectangle::getGrayFill → NO_COVERAGE |
return ((GrayColor) backgroundColor).getGray(); |
519 |
1
1. getGrayFill : replaced return of float value with -(x + 1) for com/lowagie/text/Rectangle::getGrayFill → NO_COVERAGE |
return 0; |
520 | } | |
521 | ||
522 | /** | |
523 | * Sets the the background color to a grayscale value. | |
524 | * | |
525 | * @param value | |
526 | * the new grayscale value | |
527 | */ | |
528 | public void setGrayFill(float value) { | |
529 | backgroundColor = new GrayColor(value); | |
530 | } | |
531 | ||
532 | // METHODS TO GET/SET THE BORDER: | |
533 | ||
534 | /** | |
535 | * Returns the exact type of the border. | |
536 | * | |
537 | * @return a value | |
538 | */ | |
539 | public int getBorder() { | |
540 | return border; | |
541 | } | |
542 | ||
543 | /** | |
544 | * Indicates whether some type of border is set. | |
545 | * | |
546 | * @return a boolean | |
547 | */ | |
548 | public boolean hasBorders() { | |
549 | switch (border) { | |
550 | case UNDEFINED: | |
551 | case NO_BORDER: | |
552 |
1
1. hasBorders : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
553 | default: | |
554 |
11
1. hasBorders : changed conditional boundary → NO_COVERAGE 2. hasBorders : changed conditional boundary → NO_COVERAGE 3. hasBorders : changed conditional boundary → NO_COVERAGE 4. hasBorders : changed conditional boundary → NO_COVERAGE 5. hasBorders : changed conditional boundary → NO_COVERAGE 6. hasBorders : negated conditional → NO_COVERAGE 7. hasBorders : negated conditional → NO_COVERAGE 8. hasBorders : negated conditional → NO_COVERAGE 9. hasBorders : negated conditional → NO_COVERAGE 10. hasBorders : negated conditional → NO_COVERAGE 11. hasBorders : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return borderWidth > 0 || borderWidthLeft > 0 || borderWidthRight > 0 |
555 | || borderWidthTop > 0 || borderWidthBottom > 0; | |
556 | } | |
557 | } | |
558 | ||
559 | /** | |
560 | * Indicates whether the specified type of border is set. | |
561 | * | |
562 | * @param type | |
563 | * the type of border | |
564 | * @return a boolean | |
565 | */ | |
566 | public boolean hasBorder(int type) { | |
567 |
1
1. hasBorder : negated conditional → NO_COVERAGE |
if (border == UNDEFINED) |
568 |
1
1. hasBorder : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
569 |
3
1. hasBorder : Replaced bitwise AND with OR → NO_COVERAGE 2. hasBorder : negated conditional → NO_COVERAGE 3. hasBorder : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return (border & type) == type; |
570 | } | |
571 | ||
572 | /** | |
573 | * Enables/Disables the border on the specified sides. The border is specified | |
574 | * as an integer bitwise combination of the constants: | |
575 | * <CODE>LEFT, RIGHT, TOP, BOTTOM</CODE>. | |
576 | * | |
577 | * @see #enableBorderSide(int) | |
578 | * @see #disableBorderSide(int) | |
579 | * @param border | |
580 | * the new value | |
581 | */ | |
582 | public void setBorder(int border) { | |
583 | this.border = border; | |
584 | } | |
585 | ||
586 | /** | |
587 | * Indicates whether variable width borders are being used. Returns true if | |
588 | * <CODE>setBorderWidthLeft, setBorderWidthRight, | |
589 | * setBorderWidthTop, or setBorderWidthBottom</CODE> has been called. | |
590 | * | |
591 | * @return true if variable width borders are in use | |
592 | */ | |
593 | public boolean isUseVariableBorders() { | |
594 | return useVariableBorders; | |
595 | } | |
596 | ||
597 | /** | |
598 | * Sets a parameter indicating if the rectangle has variable borders | |
599 | * | |
600 | * @param useVariableBorders | |
601 | * indication if the rectangle has variable borders | |
602 | */ | |
603 | public void setUseVariableBorders(boolean useVariableBorders) { | |
604 | this.useVariableBorders = useVariableBorders; | |
605 | } | |
606 | ||
607 | /** | |
608 | * Enables the border on the specified side. | |
609 | * | |
610 | * @param side | |
611 | * the side to enable. One of <CODE>LEFT, RIGHT, TOP, BOTTOM</CODE> | |
612 | */ | |
613 | public void enableBorderSide(int side) { | |
614 |
1
1. enableBorderSide : negated conditional → NO_COVERAGE |
if (border == UNDEFINED) |
615 | border = 0; | |
616 |
1
1. enableBorderSide : Replaced bitwise OR with AND → NO_COVERAGE |
border |= side; |
617 | } | |
618 | ||
619 | /** | |
620 | * Disables the border on the specified side. | |
621 | * | |
622 | * @param side | |
623 | * the side to disable. One of <CODE>LEFT, RIGHT, TOP, BOTTOM</CODE> | |
624 | */ | |
625 | public void disableBorderSide(int side) { | |
626 |
1
1. disableBorderSide : negated conditional → NO_COVERAGE |
if (border == UNDEFINED) |
627 | border = 0; | |
628 |
2
1. disableBorderSide : Replaced XOR with AND → NO_COVERAGE 2. disableBorderSide : Replaced bitwise AND with OR → NO_COVERAGE |
border &= ~side; |
629 | } | |
630 | ||
631 | // METHODS TO GET/SET THE BORDER WIDTH: | |
632 | ||
633 | /** | |
634 | * Gets the borderwidth. | |
635 | * | |
636 | * @return a value | |
637 | */ | |
638 | public float getBorderWidth() { | |
639 | return borderWidth; | |
640 | } | |
641 | ||
642 | /** | |
643 | * Sets the borderwidth of the table. | |
644 | * | |
645 | * @param borderWidth | |
646 | * the new value | |
647 | */ | |
648 | public void setBorderWidth(float borderWidth) { | |
649 | this.borderWidth = borderWidth; | |
650 | } | |
651 | ||
652 | /** | |
653 | * Helper function returning the border width of a specific side. | |
654 | * | |
655 | * @param variableWidthValue | |
656 | * a variable width (could be undefined) | |
657 | * @param side | |
658 | * the border you want to check | |
659 | * @return the variableWidthValue if not undefined, otherwise the borderWidth | |
660 | */ | |
661 | private float getVariableBorderWidth(float variableWidthValue, int side) { | |
662 |
2
1. getVariableBorderWidth : Replaced bitwise AND with OR → NO_COVERAGE 2. getVariableBorderWidth : negated conditional → NO_COVERAGE |
if ((border & side) != 0) |
663 |
2
1. getVariableBorderWidth : negated conditional → NO_COVERAGE 2. getVariableBorderWidth : replaced return of float value with -(x + 1) for com/lowagie/text/Rectangle::getVariableBorderWidth → NO_COVERAGE |
return variableWidthValue != UNDEFINED ? variableWidthValue : borderWidth; |
664 |
1
1. getVariableBorderWidth : replaced return of float value with -(x + 1) for com/lowagie/text/Rectangle::getVariableBorderWidth → NO_COVERAGE |
return 0; |
665 | } | |
666 | ||
667 | /** | |
668 | * Helper function updating the border flag for a side based on the specified | |
669 | * width. A width of 0 will disable the border on that side. Any other width | |
670 | * enables it. | |
671 | * | |
672 | * @param width | |
673 | * width of border | |
674 | * @param side | |
675 | * border side constant | |
676 | */ | |
677 | private void updateBorderBasedOnWidth(float width, int side) { | |
678 | useVariableBorders = true; | |
679 |
2
1. updateBorderBasedOnWidth : changed conditional boundary → NO_COVERAGE 2. updateBorderBasedOnWidth : negated conditional → NO_COVERAGE |
if (width > 0) |
680 |
1
1. updateBorderBasedOnWidth : removed call to com/lowagie/text/Rectangle::enableBorderSide → NO_COVERAGE |
enableBorderSide(side); |
681 | else | |
682 |
1
1. updateBorderBasedOnWidth : removed call to com/lowagie/text/Rectangle::disableBorderSide → NO_COVERAGE |
disableBorderSide(side); |
683 | } | |
684 | ||
685 | /** | |
686 | * Gets the width of the left border. | |
687 | * | |
688 | * @return a width | |
689 | */ | |
690 | public float getBorderWidthLeft() { | |
691 |
1
1. getBorderWidthLeft : replaced return of float value with -(x + 1) for com/lowagie/text/Rectangle::getBorderWidthLeft → NO_COVERAGE |
return getVariableBorderWidth(borderWidthLeft, LEFT); |
692 | } | |
693 | ||
694 | /** | |
695 | * Sets the width of the left border. | |
696 | * | |
697 | * @param borderWidthLeft | |
698 | * a width | |
699 | */ | |
700 | public void setBorderWidthLeft(float borderWidthLeft) { | |
701 | this.borderWidthLeft = borderWidthLeft; | |
702 |
1
1. setBorderWidthLeft : removed call to com/lowagie/text/Rectangle::updateBorderBasedOnWidth → NO_COVERAGE |
updateBorderBasedOnWidth(borderWidthLeft, LEFT); |
703 | } | |
704 | ||
705 | /** | |
706 | * Gets the width of the right border. | |
707 | * | |
708 | * @return a width | |
709 | */ | |
710 | public float getBorderWidthRight() { | |
711 |
1
1. getBorderWidthRight : replaced return of float value with -(x + 1) for com/lowagie/text/Rectangle::getBorderWidthRight → NO_COVERAGE |
return getVariableBorderWidth(borderWidthRight, RIGHT); |
712 | } | |
713 | ||
714 | /** | |
715 | * Sets the width of the right border. | |
716 | * | |
717 | * @param borderWidthRight | |
718 | * a width | |
719 | */ | |
720 | public void setBorderWidthRight(float borderWidthRight) { | |
721 | this.borderWidthRight = borderWidthRight; | |
722 |
1
1. setBorderWidthRight : removed call to com/lowagie/text/Rectangle::updateBorderBasedOnWidth → NO_COVERAGE |
updateBorderBasedOnWidth(borderWidthRight, RIGHT); |
723 | } | |
724 | ||
725 | /** | |
726 | * Gets the width of the top border. | |
727 | * | |
728 | * @return a width | |
729 | */ | |
730 | public float getBorderWidthTop() { | |
731 |
1
1. getBorderWidthTop : replaced return of float value with -(x + 1) for com/lowagie/text/Rectangle::getBorderWidthTop → NO_COVERAGE |
return getVariableBorderWidth(borderWidthTop, TOP); |
732 | } | |
733 | ||
734 | /** | |
735 | * Sets the width of the top border. | |
736 | * | |
737 | * @param borderWidthTop | |
738 | * a width | |
739 | */ | |
740 | public void setBorderWidthTop(float borderWidthTop) { | |
741 | this.borderWidthTop = borderWidthTop; | |
742 |
1
1. setBorderWidthTop : removed call to com/lowagie/text/Rectangle::updateBorderBasedOnWidth → NO_COVERAGE |
updateBorderBasedOnWidth(borderWidthTop, TOP); |
743 | } | |
744 | ||
745 | /** | |
746 | * Gets the width of the bottom border. | |
747 | * | |
748 | * @return a width | |
749 | */ | |
750 | public float getBorderWidthBottom() { | |
751 |
1
1. getBorderWidthBottom : replaced return of float value with -(x + 1) for com/lowagie/text/Rectangle::getBorderWidthBottom → NO_COVERAGE |
return getVariableBorderWidth(borderWidthBottom, BOTTOM); |
752 | } | |
753 | ||
754 | /** | |
755 | * Sets the width of the bottom border. | |
756 | * | |
757 | * @param borderWidthBottom | |
758 | * a width | |
759 | */ | |
760 | public void setBorderWidthBottom(float borderWidthBottom) { | |
761 | this.borderWidthBottom = borderWidthBottom; | |
762 |
1
1. setBorderWidthBottom : removed call to com/lowagie/text/Rectangle::updateBorderBasedOnWidth → NO_COVERAGE |
updateBorderBasedOnWidth(borderWidthBottom, BOTTOM); |
763 | } | |
764 | ||
765 | // METHODS TO GET/SET THE BORDER COLOR: | |
766 | ||
767 | /** | |
768 | * Gets the color of the border. | |
769 | * | |
770 | * @return a <CODE>Color</CODE> | |
771 | */ | |
772 | public Color getBorderColor() { | |
773 | return borderColor; | |
774 | } | |
775 | ||
776 | /** | |
777 | * Sets the color of the border. | |
778 | * | |
779 | * @param borderColor | |
780 | * a <CODE>Color</CODE> | |
781 | */ | |
782 | public void setBorderColor(Color borderColor) { | |
783 | this.borderColor = borderColor; | |
784 | } | |
785 | ||
786 | /** | |
787 | * Gets the color of the left border. | |
788 | * | |
789 | * @return a <CODE>Color</CODE> | |
790 | */ | |
791 | public Color getBorderColorLeft() { | |
792 |
1
1. getBorderColorLeft : negated conditional → NO_COVERAGE |
if (borderColorLeft == null) |
793 |
1
1. getBorderColorLeft : mutated return of Object value for com/lowagie/text/Rectangle::getBorderColorLeft to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return borderColor; |
794 |
1
1. getBorderColorLeft : mutated return of Object value for com/lowagie/text/Rectangle::getBorderColorLeft to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return borderColorLeft; |
795 | } | |
796 | ||
797 | /** | |
798 | * Sets the color of the left border. | |
799 | * | |
800 | * @param borderColorLeft | |
801 | * a <CODE>Color</CODE> | |
802 | */ | |
803 | public void setBorderColorLeft(Color borderColorLeft) { | |
804 | this.borderColorLeft = borderColorLeft; | |
805 | } | |
806 | ||
807 | /** | |
808 | * Gets the color of the right border. | |
809 | * | |
810 | * @return a <CODE>Color</CODE> | |
811 | */ | |
812 | public Color getBorderColorRight() { | |
813 |
1
1. getBorderColorRight : negated conditional → NO_COVERAGE |
if (borderColorRight == null) |
814 |
1
1. getBorderColorRight : mutated return of Object value for com/lowagie/text/Rectangle::getBorderColorRight to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return borderColor; |
815 |
1
1. getBorderColorRight : mutated return of Object value for com/lowagie/text/Rectangle::getBorderColorRight to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return borderColorRight; |
816 | } | |
817 | ||
818 | /** | |
819 | * Sets the color of the right border. | |
820 | * | |
821 | * @param borderColorRight | |
822 | * a <CODE>Color</CODE> | |
823 | */ | |
824 | public void setBorderColorRight(Color borderColorRight) { | |
825 | this.borderColorRight = borderColorRight; | |
826 | } | |
827 | ||
828 | /** | |
829 | * Gets the color of the top border. | |
830 | * | |
831 | * @return a <CODE>Color</CODE> | |
832 | */ | |
833 | public Color getBorderColorTop() { | |
834 |
1
1. getBorderColorTop : negated conditional → NO_COVERAGE |
if (borderColorTop == null) |
835 |
1
1. getBorderColorTop : mutated return of Object value for com/lowagie/text/Rectangle::getBorderColorTop to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return borderColor; |
836 |
1
1. getBorderColorTop : mutated return of Object value for com/lowagie/text/Rectangle::getBorderColorTop to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return borderColorTop; |
837 | } | |
838 | ||
839 | /** | |
840 | * Sets the color of the top border. | |
841 | * | |
842 | * @param borderColorTop | |
843 | * a <CODE>Color</CODE> | |
844 | */ | |
845 | public void setBorderColorTop(Color borderColorTop) { | |
846 | this.borderColorTop = borderColorTop; | |
847 | } | |
848 | ||
849 | /** | |
850 | * Gets the color of the bottom border. | |
851 | * | |
852 | * @return a <CODE>Color</CODE> | |
853 | */ | |
854 | public Color getBorderColorBottom() { | |
855 |
1
1. getBorderColorBottom : negated conditional → NO_COVERAGE |
if (borderColorBottom == null) |
856 |
1
1. getBorderColorBottom : mutated return of Object value for com/lowagie/text/Rectangle::getBorderColorBottom to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return borderColor; |
857 |
1
1. getBorderColorBottom : mutated return of Object value for com/lowagie/text/Rectangle::getBorderColorBottom to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return borderColorBottom; |
858 | } | |
859 | ||
860 | /** | |
861 | * Sets the color of the bottom border. | |
862 | * | |
863 | * @param borderColorBottom | |
864 | * a <CODE>Color</CODE> | |
865 | */ | |
866 | public void setBorderColorBottom(Color borderColorBottom) { | |
867 | this.borderColorBottom = borderColorBottom; | |
868 | } | |
869 | ||
870 | // SPECIAL METHODS: | |
871 | ||
872 | /** | |
873 | * Gets a Rectangle that is altered to fit on the page. | |
874 | * | |
875 | * @param top | |
876 | * the top position | |
877 | * @param bottom | |
878 | * the bottom position | |
879 | * @return a <CODE>Rectangle</CODE> | |
880 | */ | |
881 | public Rectangle rectangle(float top, float bottom) { | |
882 | Rectangle tmp = new Rectangle(this); | |
883 |
2
1. rectangle : changed conditional boundary → NO_COVERAGE 2. rectangle : negated conditional → NO_COVERAGE |
if (getTop() > top) { |
884 |
1
1. rectangle : removed call to com/lowagie/text/Rectangle::setTop → NO_COVERAGE |
tmp.setTop(top); |
885 |
1
1. rectangle : removed call to com/lowagie/text/Rectangle::disableBorderSide → NO_COVERAGE |
tmp.disableBorderSide(TOP); |
886 | } | |
887 |
2
1. rectangle : changed conditional boundary → NO_COVERAGE 2. rectangle : negated conditional → NO_COVERAGE |
if (getBottom() < bottom) { |
888 |
1
1. rectangle : removed call to com/lowagie/text/Rectangle::setBottom → NO_COVERAGE |
tmp.setBottom(bottom); |
889 |
1
1. rectangle : removed call to com/lowagie/text/Rectangle::disableBorderSide → NO_COVERAGE |
tmp.disableBorderSide(BOTTOM); |
890 | } | |
891 |
1
1. rectangle : mutated return of Object value for com/lowagie/text/Rectangle::rectangle to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return tmp; |
892 | } | |
893 | ||
894 | /** | |
895 | * Copies each of the parameters, except the position, from a | |
896 | * <CODE>Rectangle</CODE> object | |
897 | * | |
898 | * @param rect | |
899 | * <CODE>Rectangle</CODE> to copy from | |
900 | */ | |
901 | public void cloneNonPositionParameters(Rectangle rect) { | |
902 | this.rotation = rect.rotation; | |
903 | this.backgroundColor = rect.backgroundColor; | |
904 | this.border = rect.border; | |
905 | this.useVariableBorders = rect.useVariableBorders; | |
906 | this.borderWidth = rect.borderWidth; | |
907 | this.borderWidthLeft = rect.borderWidthLeft; | |
908 | this.borderWidthRight = rect.borderWidthRight; | |
909 | this.borderWidthTop = rect.borderWidthTop; | |
910 | this.borderWidthBottom = rect.borderWidthBottom; | |
911 | this.borderColor = rect.borderColor; | |
912 | this.borderColorLeft = rect.borderColorLeft; | |
913 | this.borderColorRight = rect.borderColorRight; | |
914 | this.borderColorTop = rect.borderColorTop; | |
915 | this.borderColorBottom = rect.borderColorBottom; | |
916 | } | |
917 | ||
918 | /** | |
919 | * Copies each of the parameters, except the position, from a | |
920 | * <CODE>Rectangle</CODE> object if the value is set there | |
921 | * | |
922 | * @param rect | |
923 | * <CODE>Rectangle</CODE> to copy from | |
924 | */ | |
925 | public void softCloneNonPositionParameters(Rectangle rect) { | |
926 |
1
1. softCloneNonPositionParameters : negated conditional → NO_COVERAGE |
if (rect.rotation != 0) |
927 | this.rotation = rect.rotation; | |
928 |
1
1. softCloneNonPositionParameters : negated conditional → NO_COVERAGE |
if (rect.backgroundColor != null) |
929 | this.backgroundColor = rect.backgroundColor; | |
930 |
1
1. softCloneNonPositionParameters : negated conditional → NO_COVERAGE |
if (rect.border != UNDEFINED) |
931 | this.border = rect.border; | |
932 |
1
1. softCloneNonPositionParameters : negated conditional → NO_COVERAGE |
if (useVariableBorders) |
933 | this.useVariableBorders = rect.useVariableBorders; | |
934 |
1
1. softCloneNonPositionParameters : negated conditional → NO_COVERAGE |
if (rect.borderWidth != UNDEFINED) |
935 | this.borderWidth = rect.borderWidth; | |
936 |
1
1. softCloneNonPositionParameters : negated conditional → NO_COVERAGE |
if (rect.borderWidthLeft != UNDEFINED) |
937 | this.borderWidthLeft = rect.borderWidthLeft; | |
938 |
1
1. softCloneNonPositionParameters : negated conditional → NO_COVERAGE |
if (rect.borderWidthRight != UNDEFINED) |
939 | this.borderWidthRight = rect.borderWidthRight; | |
940 |
1
1. softCloneNonPositionParameters : negated conditional → NO_COVERAGE |
if (rect.borderWidthTop != UNDEFINED) |
941 | this.borderWidthTop = rect.borderWidthTop; | |
942 |
1
1. softCloneNonPositionParameters : negated conditional → NO_COVERAGE |
if (rect.borderWidthBottom != UNDEFINED) |
943 | this.borderWidthBottom = rect.borderWidthBottom; | |
944 |
1
1. softCloneNonPositionParameters : negated conditional → NO_COVERAGE |
if (rect.borderColor != null) |
945 | this.borderColor = rect.borderColor; | |
946 |
1
1. softCloneNonPositionParameters : negated conditional → NO_COVERAGE |
if (rect.borderColorLeft != null) |
947 | this.borderColorLeft = rect.borderColorLeft; | |
948 |
1
1. softCloneNonPositionParameters : negated conditional → NO_COVERAGE |
if (rect.borderColorRight != null) |
949 | this.borderColorRight = rect.borderColorRight; | |
950 |
1
1. softCloneNonPositionParameters : negated conditional → NO_COVERAGE |
if (rect.borderColorTop != null) |
951 | this.borderColorTop = rect.borderColorTop; | |
952 |
1
1. softCloneNonPositionParameters : negated conditional → NO_COVERAGE |
if (rect.borderColorBottom != null) |
953 | this.borderColorBottom = rect.borderColorBottom; | |
954 | } | |
955 | ||
956 | /** | |
957 | * @return a String representation of the rectangle | |
958 | * @see java.lang.Object#toString() | |
959 | */ | |
960 | @Override | |
961 | public String toString() { | |
962 | StringBuilder buf = new StringBuilder("Rectangle: "); | |
963 | buf.append(getWidth()); | |
964 | buf.append('x'); | |
965 | buf.append(getHeight()); | |
966 | buf.append(" (rot: "); | |
967 | buf.append(rotation); | |
968 | buf.append(" degrees)"); | |
969 | return buf.toString(); | |
970 | } | |
971 | ||
972 | } | |
Mutations | ||
203 |
1.1 |
|
219 |
1.1 |
|
230 |
1.1 |
|
231 |
1.1 2.2 3.3 |
|
248 |
1.1 |
|
264 |
1.1 |
|
266 |
1.1 |
|
287 |
1.1 |
|
337 |
1.1 2.2 |
|
367 |
1.1 2.2 |
|
376 |
1.1 2.2 |
|
406 |
1.1 2.2 |
|
436 |
1.1 2.2 |
|
445 |
1.1 2.2 |
|
453 |
1.1 2.2 |
|
458 |
1.1 2.2 |
|
483 |
1.1 |
|
484 |
1.1 |
|
485 |
1.1 |
|
517 |
1.1 |
|
518 |
1.1 |
|
519 |
1.1 |
|
552 |
1.1 |
|
554 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 |
|
567 |
1.1 |
|
568 |
1.1 |
|
569 |
1.1 2.2 3.3 |
|
614 |
1.1 |
|
616 |
1.1 |
|
626 |
1.1 |
|
628 |
1.1 2.2 |
|
662 |
1.1 2.2 |
|
663 |
1.1 2.2 |
|
664 |
1.1 |
|
679 |
1.1 2.2 |
|
680 |
1.1 |
|
682 |
1.1 |
|
691 |
1.1 |
|
702 |
1.1 |
|
711 |
1.1 |
|
722 |
1.1 |
|
731 |
1.1 |
|
742 |
1.1 |
|
751 |
1.1 |
|
762 |
1.1 |
|
792 |
1.1 |
|
793 |
1.1 |
|
794 |
1.1 |
|
813 |
1.1 |
|
814 |
1.1 |
|
815 |
1.1 |
|
834 |
1.1 |
|
835 |
1.1 |
|
836 |
1.1 |
|
855 |
1.1 |
|
856 |
1.1 |
|
857 |
1.1 |
|
883 |
1.1 2.2 |
|
884 |
1.1 |
|
885 |
1.1 |
|
887 |
1.1 2.2 |
|
888 |
1.1 |
|
889 |
1.1 |
|
891 |
1.1 |
|
926 |
1.1 |
|
928 |
1.1 |
|
930 |
1.1 |
|
932 |
1.1 |
|
934 |
1.1 |
|
936 |
1.1 |
|
938 |
1.1 |
|
940 |
1.1 |
|
942 |
1.1 |
|
944 |
1.1 |
|
946 |
1.1 |
|
948 |
1.1 |
|
950 |
1.1 |
|
952 |
1.1 |