summaryrefslogtreecommitdiffstats
path: root/tests/sketch/src/com/android/gesture/Instance.java
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2009-05-21 15:05:50 -0700
committerRomain Guy <romainguy@android.com>2009-05-21 15:26:46 -0700
commitb6d99b7d17fd1bb1326a70744bd01be5d1586487 (patch)
treed7450b579b920bf26dd559f4dc349af411727263 /tests/sketch/src/com/android/gesture/Instance.java
parentaeed1816b7bbf8948c1daed48db6fe7567f338af (diff)
downloadframeworks_base-b6d99b7d17fd1bb1326a70744bd01be5d1586487.zip
frameworks_base-b6d99b7d17fd1bb1326a70744bd01be5d1586487.tar.gz
frameworks_base-b6d99b7d17fd1bb1326a70744bd01be5d1586487.tar.bz2
Modify how GestureLibrary stores its data. The XML format is now replaced by a more efficient binary format which should speed up saving/loading. The format is very similar to the one used by the letters recognizer. The format is documented in GestureLibrary.java.
Diffstat (limited to 'tests/sketch/src/com/android/gesture/Instance.java')
-rwxr-xr-xtests/sketch/src/com/android/gesture/Instance.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/sketch/src/com/android/gesture/Instance.java b/tests/sketch/src/com/android/gesture/Instance.java
index b2e030e..502a0fa 100755
--- a/tests/sketch/src/com/android/gesture/Instance.java
+++ b/tests/sketch/src/com/android/gesture/Instance.java
@@ -16,6 +16,8 @@
package com.android.gesture;
+import android.graphics.Matrix;
+
/**
* An instance represents a sample if the label is available or a query if the
* label is null.
@@ -47,10 +49,12 @@ class Instance {
private void normalize() {
float[] sample = vector;
float sum = 0;
+
int size = sample.length;
for (int i = 0; i < size; i++) {
sum += sample[i] * sample[i];
}
+
float magnitude = (float) Math.sqrt(sum);
for (int i = 0; i < size; i++) {
sample[i] /= magnitude;
@@ -100,12 +104,11 @@ class Instance {
}
}
- android.graphics.Matrix m = new android.graphics.Matrix();
+ Matrix m = new Matrix();
m.setTranslate(-center[0], -center[1]);
- android.graphics.Matrix rotation = new android.graphics.Matrix();
- rotation.setRotate(adjustment);
- m.postConcat(rotation);
+ m.postRotate(adjustment);
m.mapPoints(pts);
+
return pts;
}