[libbluray-devel] HScreenRectangle: add equals

hpi1 git at videolan.org
Sun Apr 17 14:57:15 CEST 2016


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sat Apr 16 23:09:07 2016 +0300| [84e2f5aa2249be6b39e767cb57af637c06166f4b] | committer: hpi1

HScreenRectangle: add equals

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=84e2f5aa2249be6b39e767cb57af637c06166f4b
---

 .../bdj/java/org/havi/ui/HScreenRectangle.java     |   29 +++++++++++++++-----
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/libbluray/bdj/java/org/havi/ui/HScreenRectangle.java b/src/libbluray/bdj/java/org/havi/ui/HScreenRectangle.java
index cae3b14..f2deb82 100644
--- a/src/libbluray/bdj/java/org/havi/ui/HScreenRectangle.java
+++ b/src/libbluray/bdj/java/org/havi/ui/HScreenRectangle.java
@@ -21,10 +21,8 @@ package org.havi.ui;
 
 public class HScreenRectangle {
     public HScreenRectangle(float x, float y, float width, float height) {
-        this.x = x;
-        this.y = y;
-        this.width = width;
-        this.height = height;
+        setLocation(x, y);
+        setSize(width, height);
     }
 
     public void setLocation(float x, float y) {
@@ -33,12 +31,29 @@ public class HScreenRectangle {
     }
 
     public void setSize(float width, float height) {
-        this.width = width;
-        this.height = height;
+        this.width = Math.max(0.0f, width);
+        this.height = Math.max(0.0f, height);
+    }
+
+    public boolean equals(Object obj)
+    {
+        if (!(obj instanceof HScreenRectangle))
+            return false;
+
+        HScreenRectangle other = (HScreenRectangle)obj;
+        Float x1 = new Float(this.x);
+        Float y1 = new Float(this.y);
+        Float w1 = new Float(this.width);
+        Float h1 = new Float(this.height);
+        Float x2 = new Float(other.x);
+        Float y2 = new Float(other.y);
+        Float w2 = new Float(other.width);
+        Float h2 = new Float(other.height);
+        return x1.equals(x2) && y1.equals(y2) && w1.equals(w2) && h1.equals(h2);
     }
 
     public String toString() {
-        return "HScreenRectangle[" + x + "," + y + " " + width + "x" + height + "]";
+        return getClass().getName() + "[" + x + "," + y + " " + width + "x" + height + "]";
     }
 
     public float x;



More information about the libbluray-devel mailing list