summaryrefslogtreecommitdiffstats
path: root/graphics/java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2011-04-20 18:18:51 -0700
committerDianne Hackborn <hackbod@google.com>2011-04-21 15:17:52 -0700
commit44bc17c6b517aef35a390c81b5aa79c4f284f744 (patch)
treeb4dabc94a8974f81cf7ea855a93e307205c5b8d7 /graphics/java
parent52c03d2cb9a782366e804d1910a7c8f072b05353 (diff)
downloadframeworks_base-44bc17c6b517aef35a390c81b5aa79c4f284f744.zip
frameworks_base-44bc17c6b517aef35a390c81b5aa79c4f284f744.tar.gz
frameworks_base-44bc17c6b517aef35a390c81b5aa79c4f284f744.tar.bz2
Rework display size access.
Applications now get the display size from the window manager. No behavior should be changed yet, this is just prep for some real changes. Change-Id: I2958a6660895c1cba2b670509600014e55ee9273
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/graphics/Point.aidl18
-rw-r--r--graphics/java/android/graphics/Point.java53
-rw-r--r--graphics/java/android/graphics/PointF.aidl18
-rw-r--r--graphics/java/android/graphics/PointF.java53
4 files changed, 139 insertions, 3 deletions
diff --git a/graphics/java/android/graphics/Point.aidl b/graphics/java/android/graphics/Point.aidl
new file mode 100644
index 0000000..0e6b2b9
--- /dev/null
+++ b/graphics/java/android/graphics/Point.aidl
@@ -0,0 +1,18 @@
+/* Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+package android.graphics;
+
+parcelable Point;
diff --git a/graphics/java/android/graphics/Point.java b/graphics/java/android/graphics/Point.java
index c351444..338e880 100644
--- a/graphics/java/android/graphics/Point.java
+++ b/graphics/java/android/graphics/Point.java
@@ -16,11 +16,14 @@
package android.graphics;
+import android.os.Parcel;
+import android.os.Parcelable;
+
/**
* Point holds two integer coordinates
*/
-public class Point {
+public class Point implements Parcelable {
public int x;
public int y;
@@ -82,4 +85,52 @@ public class Point {
@Override public String toString() {
return "Point(" + x + ", " + y+ ")";
}
+
+ /**
+ * Parcelable interface methods
+ */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * Write this point to the specified parcel. To restore a point from
+ * a parcel, use readFromParcel()
+ * @param out The parcel to write the point's coordinates into
+ */
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(x);
+ out.writeInt(y);
+ }
+
+ public static final Parcelable.Creator<Point> CREATOR = new Parcelable.Creator<Point>() {
+ /**
+ * Return a new point from the data in the specified parcel.
+ */
+ public Point createFromParcel(Parcel in) {
+ Point r = new Point();
+ r.readFromParcel(in);
+ return r;
+ }
+
+ /**
+ * Return an array of rectangles of the specified size.
+ */
+ public Point[] newArray(int size) {
+ return new Point[size];
+ }
+ };
+
+ /**
+ * Set the point's coordinates from the data stored in the specified
+ * parcel. To write a point to a parcel, call writeToParcel().
+ *
+ * @param in The parcel to read the point's coordinates from
+ */
+ public void readFromParcel(Parcel in) {
+ x = in.readInt();
+ y = in.readInt();
+ }
}
diff --git a/graphics/java/android/graphics/PointF.aidl b/graphics/java/android/graphics/PointF.aidl
new file mode 100644
index 0000000..ad72acd
--- /dev/null
+++ b/graphics/java/android/graphics/PointF.aidl
@@ -0,0 +1,18 @@
+/* Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+package android.graphics;
+
+parcelable PointF;
diff --git a/graphics/java/android/graphics/PointF.java b/graphics/java/android/graphics/PointF.java
index 0f045a1..e00271f 100644
--- a/graphics/java/android/graphics/PointF.java
+++ b/graphics/java/android/graphics/PointF.java
@@ -16,13 +16,15 @@
package android.graphics;
+import android.os.Parcel;
+import android.os.Parcelable;
import android.util.FloatMath;
/**
* PointF holds two float coordinates
*/
-public class PointF {
+public class PointF implements Parcelable {
public float x;
public float y;
@@ -84,5 +86,52 @@ public class PointF {
public static float length(float x, float y) {
return FloatMath.sqrt(x * x + y * y);
}
-}
+ /**
+ * Parcelable interface methods
+ */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * Write this point to the specified parcel. To restore a point from
+ * a parcel, use readFromParcel()
+ * @param out The parcel to write the point's coordinates into
+ */
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeFloat(x);
+ out.writeFloat(y);
+ }
+
+ public static final Parcelable.Creator<PointF> CREATOR = new Parcelable.Creator<PointF>() {
+ /**
+ * Return a new point from the data in the specified parcel.
+ */
+ public PointF createFromParcel(Parcel in) {
+ PointF r = new PointF();
+ r.readFromParcel(in);
+ return r;
+ }
+
+ /**
+ * Return an array of rectangles of the specified size.
+ */
+ public PointF[] newArray(int size) {
+ return new PointF[size];
+ }
+ };
+
+ /**
+ * Set the point's coordinates from the data stored in the specified
+ * parcel. To write a point to a parcel, call writeToParcel().
+ *
+ * @param in The parcel to read the point's coordinates from
+ */
+ public void readFromParcel(Parcel in) {
+ x = in.readFloat();
+ y = in.readFloat();
+ }
+}