summaryrefslogtreecommitdiff
path: root/platform/java/src
diff options
context:
space:
mode:
authorFred Ross-Perry <fross-perry@conceptuamath.com>2016-08-19 10:01:01 -0700
committerFred Ross-Perry <fross-perry@conceptuamath.com>2016-08-19 10:02:11 -0700
commit9f457e6f5b488bc336d5cd337c3bafe2ce32625a (patch)
treee586e52f9efeb6db09b316caabb5034c3dc5e65c /platform/java/src
parentd1ad269c3bc46ac070d3c682df390d04bd8cd619 (diff)
downloadmupdf-9f457e6f5b488bc336d5cd337c3bafe2ce32625a.tar.xz
Java - change contains() in Rect and RectI to properly handle empty rects.
Diffstat (limited to 'platform/java/src')
-rw-r--r--platform/java/src/com/artifex/mupdf/fitz/Rect.java12
-rw-r--r--platform/java/src/com/artifex/mupdf/fitz/RectI.java16
2 files changed, 22 insertions, 6 deletions
diff --git a/platform/java/src/com/artifex/mupdf/fitz/Rect.java b/platform/java/src/com/artifex/mupdf/fitz/Rect.java
index 3b8983a9..f35c290e 100644
--- a/platform/java/src/com/artifex/mupdf/fitz/Rect.java
+++ b/platform/java/src/com/artifex/mupdf/fitz/Rect.java
@@ -91,18 +91,18 @@ public class Rect
public boolean contains(float x, float y)
{
- if (x >= x0 && x < x1 && y >= y0 && y < y1)
- return true;
+ if (isEmpty())
+ return false;
- return false;
+ return (x >= x0 && x < x1 && y >= y0 && y < y1);
}
public boolean contains(Rect r)
{
- if (r.x0 >= x0 && r.x1 < x1 && r.y0 >= y0 && r.y1 < y1)
- return true;
+ if (isEmpty() || r.isEmpty())
+ return false;
- return false;
+ return (r.x0 >= x0 && r.x1 <= x1 && r.y0 >= y0 && r.y1 <= y1);
}
public boolean isEmpty()
diff --git a/platform/java/src/com/artifex/mupdf/fitz/RectI.java b/platform/java/src/com/artifex/mupdf/fitz/RectI.java
index 2d5e8f70..7cc9d98e 100644
--- a/platform/java/src/com/artifex/mupdf/fitz/RectI.java
+++ b/platform/java/src/com/artifex/mupdf/fitz/RectI.java
@@ -83,6 +83,22 @@ public class RectI
return this;
}
+ public boolean contains(int x, int y)
+ {
+ if (isEmpty())
+ return false;
+
+ return (x >= x0 && x < x1 && y >= y0 && y < y1);
+ }
+
+ public boolean contains(Rect r)
+ {
+ if (isEmpty() || r.isEmpty())
+ return false;
+
+ return (r.x0 >= x0 && r.x1 <= x1 && r.y0 >= y0 && r.y1 <= y1);
+ }
+
public boolean isEmpty()
{
return (x0 == x1 || y0 == y1);