am 4ddf1e47: Remove unused gesture preview trail code

* commit '4ddf1e47a756fdd06cadf6c83fe653b14135384c':
  Remove unused gesture preview trail code
main
Tadashi G. Takaoka 2013-05-06 22:51:49 -07:00 committed by Android Git Automerger
commit 7a926b3ca7
1 changed files with 7 additions and 30 deletions

View File

@ -21,8 +21,6 @@ import com.android.inputmethod.latin.ResizableIntArray;
public final class GestureStrokeWithPreviewPoints extends GestureStroke { public final class GestureStrokeWithPreviewPoints extends GestureStroke {
public static final int PREVIEW_CAPACITY = 256; public static final int PREVIEW_CAPACITY = 256;
private static final boolean ENABLE_INTERPOLATION = true;
private final ResizableIntArray mPreviewEventTimes = new ResizableIntArray(PREVIEW_CAPACITY); private final ResizableIntArray mPreviewEventTimes = new ResizableIntArray(PREVIEW_CAPACITY);
private final ResizableIntArray mPreviewXCoordinates = new ResizableIntArray(PREVIEW_CAPACITY); private final ResizableIntArray mPreviewXCoordinates = new ResizableIntArray(PREVIEW_CAPACITY);
private final ResizableIntArray mPreviewYCoordinates = new ResizableIntArray(PREVIEW_CAPACITY); private final ResizableIntArray mPreviewYCoordinates = new ResizableIntArray(PREVIEW_CAPACITY);
@ -32,18 +30,15 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
private final HermiteInterpolator mInterpolator = new HermiteInterpolator(); private final HermiteInterpolator mInterpolator = new HermiteInterpolator();
private int mLastInterpolatedPreviewIndex; private int mLastInterpolatedPreviewIndex;
private int mMinPreviewSamplingDistanceSquared;
private int mLastX; private int mLastX;
private int mLastY; private int mLastY;
private double mMinPreviewSamplingDistance; private double mMinPreviewSamplingDistance;
private double mDistanceFromLastSample; private double mDistanceFromLastSample;
// TODO: Move these constants to resource. // TODO: Move these constants to resource.
// The minimum linear distance between sample points for preview in keyWidth unit.
private static final float MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH = 0.1f;
// The minimum trail distance between sample points for preview in keyWidth unit when using // The minimum trail distance between sample points for preview in keyWidth unit when using
// interpolation. // interpolation.
private static final float MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH_WITH_INTERPOLATION = 0.2f; private static final float MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH = 0.2f;
// The angular threshold to use interpolation in radian. PI/12 is 15 degree. // The angular threshold to use interpolation in radian. PI/12 is 15 degree.
private static final double INTERPOLATION_ANGULAR_THRESHOLD = Math.PI / 12.0d; private static final double INTERPOLATION_ANGULAR_THRESHOLD = Math.PI / 12.0d;
private static final int MAX_INTERPOLATION_PARTITION = 4; private static final int MAX_INTERPOLATION_PARTITION = 4;
@ -70,31 +65,16 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
@Override @Override
public void setKeyboardGeometry(final int keyWidth, final int keyboardHeight) { public void setKeyboardGeometry(final int keyWidth, final int keyboardHeight) {
super.setKeyboardGeometry(keyWidth, keyboardHeight); super.setKeyboardGeometry(keyWidth, keyboardHeight);
final float samplingRatioToKeyWidth = ENABLE_INTERPOLATION final float samplingRatioToKeyWidth = MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH;
? MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH_WITH_INTERPOLATION
: MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH;
mMinPreviewSamplingDistance = keyWidth * samplingRatioToKeyWidth; mMinPreviewSamplingDistance = keyWidth * samplingRatioToKeyWidth;
mMinPreviewSamplingDistanceSquared = (int)(
mMinPreviewSamplingDistance * mMinPreviewSamplingDistance);
} }
private boolean needsSampling(final int x, final int y, final boolean isMajorEvent) { private boolean needsSampling(final int x, final int y, final boolean isMajorEvent) {
if (ENABLE_INTERPOLATION) { mDistanceFromLastSample += Math.hypot(x - mLastX, y - mLastY);
mDistanceFromLastSample += Math.hypot(x - mLastX, y - mLastY); mLastX = x;
mLastX = x; mLastY = y;
mLastY = y; if (mDistanceFromLastSample >= mMinPreviewSamplingDistance) {
if (mDistanceFromLastSample >= mMinPreviewSamplingDistance) { mDistanceFromLastSample = 0.0d;
mDistanceFromLastSample = 0.0d;
return true;
}
return false;
}
final int dx = x - mLastX;
final int dy = y - mLastY;
if (isMajorEvent || dx * dx + dy * dy >= mMinPreviewSamplingDistanceSquared) {
mLastX = x;
mLastY = y;
return true; return true;
} }
return false; return false;
@ -140,9 +120,6 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
public int interpolateStrokeAndReturnStartIndexOfLastSegment(final int lastInterpolatedIndex, public int interpolateStrokeAndReturnStartIndexOfLastSegment(final int lastInterpolatedIndex,
final ResizableIntArray eventTimes, final ResizableIntArray xCoords, final ResizableIntArray eventTimes, final ResizableIntArray xCoords,
final ResizableIntArray yCoords) { final ResizableIntArray yCoords) {
if (!ENABLE_INTERPOLATION) {
return lastInterpolatedIndex;
}
final int size = mPreviewEventTimes.getLength(); final int size = mPreviewEventTimes.getLength();
final int[] pt = mPreviewEventTimes.getPrimitiveArray(); final int[] pt = mPreviewEventTimes.getPrimitiveArray();
final int[] px = mPreviewXCoordinates.getPrimitiveArray(); final int[] px = mPreviewXCoordinates.getPrimitiveArray();