Skip to content

Commit c3d3aea

Browse files
Make the check of rectangle being completely inside another rectangle tolerable to small precision mistakes
DEVSIX-2474
1 parent 6172dbc commit c3d3aea

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

io/src/main/java/com/itextpdf/io/LogMessageConstant.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public final class LogMessageConstant {
140140
public static final String PROPERTY_IN_PERCENTS_NOT_SUPPORTED = "Property {0} in percents is not supported";
141141
public static final String RECTANGLE_HAS_NEGATIVE_OR_ZERO_SIZES = "The {0} rectangle has negative or zero sizes. It will not be displayed.";
142142
public static final String RECTANGLE_HAS_NEGATIVE_SIZE = "The {0} rectangle has negative size. It will not be displayed.";
143+
public static final String REDACTION_OF_ANNOTATION_TYPE_WATERMARK_IS_NOT_SUPPORTED = "Redaction of annotation subtype /Watermark is not supported";
143144
public static final String REMOVING_PAGE_HAS_ALREADY_BEEN_FLUSHED = "The removing page has already been flushed.";
144145
public static final String RENDERER_WAS_NOT_ABLE_TO_PROCESS_KEEP_WITH_NEXT = "The renderer was not able to process keep with next property properly";
145146
public static final String ROLE_MAPPING_FROM_SOURCE_IS_NOT_COPIED_ALREADY_EXIST = "Role mapping \"{0}\" from source document is not copied. Destination document already has \"{1}\" mapping.";

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,11 @@ public Rectangle getIntersection(Rectangle rect) {
160160
}
161161

162162
/**
163-
* Check if this rectangle contains the passed rectangle
164-
* A rectangle will envelop itself
163+
* Check if this rectangle contains the passed rectangle.
164+
* A rectangle will envelop itself, meaning that for any rectangle {@code rect}
165+
* the expression {@code rect.contains(rect)} always returns true.
165166
*
166-
* @param rect
167+
* @param rect a rectangle which is to be checked if it is fully contained inside this rectangle.
167168
* @return true if this rectangle contains the passed rectangle, false otherwise.
168169
*/
169170
public boolean contains(Rectangle rect) {
@@ -177,8 +178,8 @@ public boolean contains(Rectangle rect) {
177178
float rurx = rllx + rect.getWidth();
178179
float rury = rlly + rect.getHeight();
179180

180-
return llx <= rllx && lly <= rlly
181-
&& rurx <= urx && rury <= ury;
181+
return llx - EPS <= rllx && lly - EPS <= rlly
182+
&& rurx <= urx + EPS && rury <= ury + EPS;
182183
}
183184

184185
/**

0 commit comments

Comments
 (0)