diff options
author | Romain Guy <romainguy@google.com> | 2012-11-20 18:35:20 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2012-11-20 18:35:20 -0800 |
commit | 9f8af6546deb26d8bddb0c1b23d554fe5380b9d3 (patch) | |
tree | d1179d3b4a1058b9f30be6b1ec9e6de8e231d8ab /graphics/java/android/graphics/PointF.java | |
parent | dc3d76f246f21093ad1ad75dc451126f41b525d3 (diff) | |
download | frameworks_base-9f8af6546deb26d8bddb0c1b23d554fe5380b9d3.zip frameworks_base-9f8af6546deb26d8bddb0c1b23d554fe5380b9d3.tar.gz frameworks_base-9f8af6546deb26d8bddb0c1b23d554fe5380b9d3.tar.bz2 |
Cleanup: add PointF.toString()/equals()/hashcode()
PointF was missing these methods found in Point.
This change also properly implements equals() and hashcode() for
Point to match the PointF implementations.
Change-Id: Ic97280fb9f8c7011d8a13103c67d6e898adf00c0
Diffstat (limited to 'graphics/java/android/graphics/PointF.java')
-rw-r--r-- | graphics/java/android/graphics/PointF.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/graphics/java/android/graphics/PointF.java b/graphics/java/android/graphics/PointF.java index e00271f..ee38dbb 100644 --- a/graphics/java/android/graphics/PointF.java +++ b/graphics/java/android/graphics/PointF.java @@ -73,6 +73,31 @@ public class PointF implements Parcelable { return this.x == x && this.y == y; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PointF pointF = (PointF) o; + + if (Float.compare(pointF.x, x) != 0) return false; + if (Float.compare(pointF.y, y) != 0) return false; + + return true; + } + + @Override + public int hashCode() { + int result = (x != +0.0f ? Float.floatToIntBits(x) : 0); + result = 31 * result + (y != +0.0f ? Float.floatToIntBits(y) : 0); + return result; + } + + @Override + public String toString() { + return "PointF(" + x + ", " + y + ")"; + } + /** * Return the euclidian distance from (0,0) to the point */ |