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
104bb70c
Commit
104bb70c
authored
11 years ago
by
Tadashi G. Takaoka
Committed by
Android (Google) Code Review
11 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Avoid drawing too long gesture preview trails"
parents
2afe88b8
80e396d8
No related branches found
No related tags found
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
+17
-6
17 additions, 6 deletions
...hod/keyboard/internal/GestureStrokeWithPreviewPoints.java
with
17 additions
and
6 deletions
java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java
+
17
−
6
View file @
104bb70c
...
...
@@ -34,14 +34,18 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
private
int
mLastY
;
private
double
mMinPreviewSamplingDistance
;
private
double
mDistanceFromLastSample
;
private
double
mInterpolationDistanceThreshold
;
// TODO: Move these constants to resource.
// TODO: Use "dp" instead of ratio to the keyWidth because table has rather large keys.
// 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
=
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
;
// The distance threshold to use interpolation in keyWidth unit.
private
static
final
float
INTERPOLATION_DISTANCE_THRESHOLD_TO_KEY_WIDTH
=
0.5f
;
private
static
final
int
MAX_INTERPOLATION_PARTITIONS
=
6
;
public
GestureStrokeWithPreviewPoints
(
final
int
pointerId
,
final
GestureStrokeParams
params
)
{
super
(
pointerId
,
params
);
...
...
@@ -66,6 +70,7 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
public
void
setKeyboardGeometry
(
final
int
keyWidth
,
final
int
keyboardHeight
)
{
super
.
setKeyboardGeometry
(
keyWidth
,
keyboardHeight
);
mMinPreviewSamplingDistance
=
keyWidth
*
MIN_PREVIEW_SAMPLING_RATIO_TO_KEY_WIDTH
;
mInterpolationDistanceThreshold
=
keyWidth
*
INTERPOLATION_DISTANCE_THRESHOLD_TO_KEY_WIDTH
;
}
private
boolean
needsSampling
(
final
int
x
,
final
int
y
)
{
...
...
@@ -138,14 +143,20 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke {
mInterpolator
.
setInterval
(
p0
,
p1
,
p2
,
p3
);
final
double
m1
=
Math
.
atan2
(
mInterpolator
.
mSlope1Y
,
mInterpolator
.
mSlope1X
);
final
double
m2
=
Math
.
atan2
(
mInterpolator
.
mSlope2Y
,
mInterpolator
.
mSlope2X
);
final
double
dm
=
Math
.
abs
(
angularDiff
(
m2
,
m1
));
final
int
partition
=
Math
.
min
((
int
)
Math
.
ceil
(
dm
/
INTERPOLATION_ANGULAR_THRESHOLD
),
MAX_INTERPOLATION_PARTITION
);
final
double
deltaAngle
=
Math
.
abs
(
angularDiff
(
m2
,
m1
));
final
int
partitionsByAngle
=
(
int
)
Math
.
ceil
(
deltaAngle
/
INTERPOLATION_ANGULAR_THRESHOLD
);
final
double
deltaDistance
=
Math
.
hypot
(
mInterpolator
.
mP1X
-
mInterpolator
.
mP2X
,
mInterpolator
.
mP1Y
-
mInterpolator
.
mP2Y
);
final
int
partitionsByDistance
=
(
int
)
Math
.
ceil
(
deltaDistance
/
mInterpolationDistanceThreshold
);
final
int
partitions
=
Math
.
min
(
MAX_INTERPOLATION_PARTITIONS
,
Math
.
max
(
partitionsByAngle
,
partitionsByDistance
));
final
int
t1
=
eventTimes
.
get
(
d1
);
final
int
dt
=
pt
[
p2
]
-
pt
[
p1
];
d1
++;
for
(
int
i
=
1
;
i
<
partition
;
i
++)
{
final
float
t
=
i
/
(
float
)
partition
;
for
(
int
i
=
1
;
i
<
partition
s
;
i
++)
{
final
float
t
=
i
/
(
float
)
partition
s
;
mInterpolator
.
interpolate
(
t
);
eventTimes
.
add
(
d1
,
(
int
)(
dt
*
t
)
+
t1
);
xCoords
.
add
(
d1
,
(
int
)
mInterpolator
.
mInterpolatedX
);
...
...
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