diff options
author | Romain Guy <romainguy@android.com> | 2009-05-21 15:05:50 -0700 |
---|---|---|
committer | Romain Guy <romainguy@android.com> | 2009-05-21 15:26:46 -0700 |
commit | b6d99b7d17fd1bb1326a70744bd01be5d1586487 (patch) | |
tree | d7450b579b920bf26dd559f4dc349af411727263 /tests/sketch/src/com/android/gesture/GestureUtilities.java | |
parent | aeed1816b7bbf8948c1daed48db6fe7567f338af (diff) | |
download | frameworks_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/GestureUtilities.java')
-rwxr-xr-x | tests/sketch/src/com/android/gesture/GestureUtilities.java | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/tests/sketch/src/com/android/gesture/GestureUtilities.java b/tests/sketch/src/com/android/gesture/GestureUtilities.java index 92de987..6d73c2d 100755 --- a/tests/sketch/src/com/android/gesture/GestureUtilities.java +++ b/tests/sketch/src/com/android/gesture/GestureUtilities.java @@ -18,6 +18,7 @@ package com.android.gesture; import android.graphics.RectF; import android.graphics.Matrix; +import android.util.Log; import java.util.ArrayList; import java.util.Arrays; @@ -42,7 +43,7 @@ final class GestureUtilities { try { stream.close(); } catch (IOException e) { - android.util.Log.e(LOG_TAG, "Could not close stream", e); + Log.e(LOG_TAG, "Could not close stream", e); } } } @@ -56,24 +57,25 @@ final class GestureUtilities { float sx = targetPatchSize / rect.width(); float sy = targetPatchSize / rect.height(); float scale = sx < sy ? sx : sy; - android.graphics.Matrix trans = new android.graphics.Matrix(); + + Matrix trans = new Matrix(); trans.setScale(scale, scale); - android.graphics.Matrix translate1 = new android.graphics.Matrix(); - translate1.setTranslate(-rect.centerX(), -rect.centerY()); - trans.preConcat(translate1); - android.graphics.Matrix translate2 = new android.graphics.Matrix(); - translate2.setTranslate(targetPatchSize / 2, targetPatchSize / 2); - trans.postConcat(translate2); - - ArrayList<GestureStroke> strokes = gesture.getStrokes(); - int count = strokes.size(); + trans.preTranslate(-rect.centerX(), -rect.centerY()); + trans.postTranslate(targetPatchSize / 2, targetPatchSize / 2); + + final ArrayList<GestureStroke> strokes = gesture.getStrokes(); + final int count = strokes.size(); + int size; float xpos; float ypos; + for (int index = 0; index < count; index++) { - GestureStroke stroke = strokes.get(index); + final GestureStroke stroke = strokes.get(index); size = stroke.points.length; - float[] pts = new float[size]; + + final float[] pts = new float[size]; + trans.mapPoints(pts, 0, stroke.points, 0, size / 2); float segmentEndX = -1; float segmentEndY = -1; |