Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
4ddf1e47
Commit
4ddf1e47
authored
11 years ago
by
Tadashi G. Takaoka
Browse files
Options
Downloads
Patches
Plain Diff
Remove unused gesture preview trail code
Change-Id: I2aa77675628a4b1655b30852c950f5daae6f0a92
parent
c7588446
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java
+7
-30
7 additions, 30 deletions
...hod/keyboard/internal/GestureStrokeWithPreviewPoints.java
with
7 additions
and
30 deletions
java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java
+
7
−
30
View file @
4ddf1e47
...
...
@@ -21,8 +21,6 @@ import com.android.inputmethod.latin.ResizableIntArray;
public
final
class
GestureStrokeWithPreviewPoints
extends
GestureStroke
{
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
mPreviewXCoordinates
=
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
int
mLastInterpolatedPreviewIndex
;
private
int
mMinPreviewSamplingDistanceSquared
;
private
int
mLastX
;
private
int
mLastY
;
private
double
mMinPreviewSamplingDistance
;
private
double
mDistanceFromLastSample
;
// 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
// 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.
private
static
final
double
INTERPOLATION_ANGULAR_THRESHOLD
=
Math
.
PI
/
12.0d
;
private
static
final
int
MAX_INTERPOLATION_PARTITION
=
4
;
...
...
@@ -70,31 +65,16 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
@Override
public
void
setKeyboardGeometry
(
final
int
keyWidth
,
final
int
keyboardHeight
)
{
super
.
setKeyboardGeometry
(
keyWidth
,
keyboardHeight
);
final
float
samplingRatioToKeyWidth
=
ENABLE_INTERPOLATION
?
MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH_WITH_INTERPOLATION
:
MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH
;
final
float
samplingRatioToKeyWidth
=
MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH
;
mMinPreviewSamplingDistance
=
keyWidth
*
samplingRatioToKeyWidth
;
mMinPreviewSamplingDistanceSquared
=
(
int
)(
mMinPreviewSamplingDistance
*
mMinPreviewSamplingDistance
);
}
private
boolean
needsSampling
(
final
int
x
,
final
int
y
,
final
boolean
isMajorEvent
)
{
if
(
ENABLE_INTERPOLATION
)
{
mDistanceFromLastSample
+=
Math
.
hypot
(
x
-
mLastX
,
y
-
mLastY
);
mLastX
=
x
;
mLastY
=
y
;
if
(
mDistanceFromLastSample
>=
mMinPreviewSamplingDistance
)
{
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
;
mDistanceFromLastSample
+=
Math
.
hypot
(
x
-
mLastX
,
y
-
mLastY
);
mLastX
=
x
;
mLastY
=
y
;
if
(
mDistanceFromLastSample
>=
mMinPreviewSamplingDistance
)
{
mDistanceFromLastSample
=
0.0d
;
return
true
;
}
return
false
;
...
...
@@ -140,9 +120,6 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
public
int
interpolateStrokeAndReturnStartIndexOfLastSegment
(
final
int
lastInterpolatedIndex
,
final
ResizableIntArray
eventTimes
,
final
ResizableIntArray
xCoords
,
final
ResizableIntArray
yCoords
)
{
if
(!
ENABLE_INTERPOLATION
)
{
return
lastInterpolatedIndex
;
}
final
int
size
=
mPreviewEventTimes
.
getLength
();
final
int
[]
pt
=
mPreviewEventTimes
.
getPrimitiveArray
();
final
int
[]
px
=
mPreviewXCoordinates
.
getPrimitiveArray
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment