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
7519091f
Commit
7519091f
authored
12 years ago
by
Tadashi G. Takaoka
Browse files
Options
Downloads
Patches
Plain Diff
Use ResizableIntArray in GestureStroke
Change-Id: I034e80df03c7c6c0895fdf2c03763627d410d425
parent
2474b37a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
+28
-24
28 additions, 24 deletions
.../android/inputmethod/keyboard/internal/GestureStroke.java
java/src/com/android/inputmethod/latin/InputPointers.java
+21
-0
21 additions, 0 deletions
java/src/com/android/inputmethod/latin/InputPointers.java
with
49 additions
and
24 deletions
java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
+
28
−
24
View file @
7519091f
...
...
@@ -21,13 +21,15 @@ import android.util.FloatMath;
import
com.android.inputmethod.latin.Constants
;
import
com.android.inputmethod.latin.InputPointers
;
import
com.android.inputmethod.latin.ResizableIntArray
;
public
class
GestureStroke
{
public
static
final
int
DEFAULT_CAPACITY
=
128
;
private
final
int
mPointerId
;
// TODO: Replace this {@link InputPointers} with a set of {@link ScalableIntArray}s.
private
final
InputPointers
mInputPointers
=
new
InputPointers
(
DEFAULT_CAPACITY
);
private
final
ResizableIntArray
mEventTimes
=
new
ResizableIntArray
(
DEFAULT_CAPACITY
);
private
final
ResizableIntArray
mXCoordinates
=
new
ResizableIntArray
(
DEFAULT_CAPACITY
);
private
final
ResizableIntArray
mYCoordinates
=
new
ResizableIntArray
(
DEFAULT_CAPACITY
);
private
float
mLength
;
private
float
mAngle
;
private
int
mIncrementalRecognitionSize
;
...
...
@@ -85,7 +87,9 @@ public class GestureStroke {
mIncrementalRecognitionSize
=
0
;
mLastIncrementalBatchSize
=
0
;
mLastPointTime
=
0
;
mInputPointers
.
reset
();
mEventTimes
.
setLength
(
0
);
mXCoordinates
.
setLength
(
0
);
mYCoordinates
.
setLength
(
0
);
mDrawingRect
.
setEmpty
();
}
...
...
@@ -96,26 +100,24 @@ public class GestureStroke {
}
public
void
addPoint
(
final
int
x
,
final
int
y
,
final
int
time
,
final
boolean
isHistorical
)
{
final
int
size
=
m
InputPointers
.
getPointerSize
();
final
int
size
=
m
EventTimes
.
getLength
();
if
(
size
==
0
)
{
mInputPointers
.
addPointer
(
x
,
y
,
mPointerId
,
time
);
mEventTimes
.
add
(
time
);
mXCoordinates
.
add
(
x
);
mYCoordinates
.
add
(
y
);
if
(!
isHistorical
)
{
updateLastPoint
(
x
,
y
,
time
);
}
return
;
}
final
int
[]
xCoords
=
mInputPointers
.
getXCoordinates
();
final
int
[]
yCoords
=
mInputPointers
.
getYCoordinates
();
final
int
lastX
=
xCoords
[
size
-
1
];
final
int
lastY
=
yCoords
[
size
-
1
];
final
int
lastX
=
mXCoordinates
.
get
(
size
-
1
);
final
int
lastY
=
mYCoordinates
.
get
(
size
-
1
);
final
float
dist
=
getDistance
(
lastX
,
lastY
,
x
,
y
);
if
(
dist
>
mMinGestureSampleLength
)
{
mInputPointers
.
addPointer
(
x
,
y
,
mPointerId
,
time
);
if
(
mDrawingRect
.
isEmpty
())
{
mDrawingRect
.
set
(
x
-
1
,
y
-
1
,
x
+
1
,
y
+
1
);
}
else
{
mDrawingRect
.
union
(
x
,
y
);
}
mEventTimes
.
add
(
time
);
mXCoordinates
.
add
(
x
);
mYCoordinates
.
add
(
y
);
mLength
+=
dist
;
final
float
angle
=
getAngle
(
lastX
,
lastY
,
x
,
y
);
if
(
size
>
1
)
{
...
...
@@ -142,15 +144,17 @@ public class GestureStroke {
}
public
void
appendAllBatchPoints
(
final
InputPointers
out
)
{
final
int
size
=
mInputPointers
.
getPointerSize
();
out
.
append
(
mInputPointers
,
mLastIncrementalBatchSize
,
size
-
mLastIncrementalBatchSize
);
mLastIncrementalBatchSize
=
size
;
appendBatchPoints
(
out
,
mEventTimes
.
getLength
());
}
public
void
appendIncrementalBatchPoints
(
final
InputPointers
out
)
{
out
.
append
(
mInputPointers
,
mLastIncrementalBatchSize
,
mIncrementalRecognitionSize
-
mLastIncrementalBatchSize
);
mLastIncrementalBatchSize
=
mIncrementalRecognitionSize
;
appendBatchPoints
(
out
,
mIncrementalRecognitionSize
);
}
private
void
appendBatchPoints
(
final
InputPointers
out
,
final
int
size
)
{
out
.
append
(
mPointerId
,
mEventTimes
,
mXCoordinates
,
mYCoordinates
,
mLastIncrementalBatchSize
,
size
-
mLastIncrementalBatchSize
);
mLastIncrementalBatchSize
=
size
;
}
private
static
float
getDistance
(
final
int
p1x
,
final
int
p1y
,
...
...
@@ -179,9 +183,9 @@ public class GestureStroke {
public
void
drawGestureTrail
(
Canvas
canvas
,
Paint
paint
,
int
lastX
,
int
lastY
)
{
// TODO: These paint parameter interpolation should be tunable, possibly introduce an object
// that implements an interface such as Paint getPaint(int step, int strokePoints)
final
int
size
=
m
InputPo
inte
r
s
.
get
PointerSize
();
int
[]
xCoords
=
m
InputPo
inte
r
s
.
get
XCoordinates
();
int
[]
yCoords
=
m
InputPo
inte
r
s
.
get
YCoordinates
();
final
int
size
=
m
XCoord
in
a
tes
.
get
Length
();
int
[]
xCoords
=
m
XCoord
in
a
tes
.
get
PrimitiveArray
();
int
[]
yCoords
=
m
YCoord
in
a
tes
.
get
PrimitiveArray
();
int
alpha
=
Constants
.
Color
.
ALPHA_OPAQUE
;
for
(
int
i
=
size
-
1
;
i
>
0
&&
alpha
>
0
;
i
--)
{
paint
.
setAlpha
(
alpha
);
...
...
This diff is collapsed.
Click to expand it.
java/src/com/android/inputmethod/latin/InputPointers.java
+
21
−
0
View file @
7519091f
...
...
@@ -76,6 +76,27 @@ public class InputPointers {
mTimes
.
append
(
src
.
mTimes
,
startPos
,
length
);
}
/**
* Append the times, x-coordinates and y-coordinates in the specified {@link ResizableIntArray}
* to the end of this.
* @param pointerId the pointer id of the source.
* @param times the source {@link ResizableIntArray} to read the event times from.
* @param xCoordinates the source {@link ResizableIntArray} to read the x-coordinates from.
* @param yCoordinates the source {@link ResizableIntArray} to read the y-coordinates from.
* @param startPos the starting index of the data in {@code times} and etc.
* @param length the number of data to be appended.
*/
public
void
append
(
int
pointerId
,
ResizableIntArray
times
,
ResizableIntArray
xCoordinates
,
ResizableIntArray
yCoordinates
,
int
startPos
,
int
length
)
{
if
(
length
==
0
)
{
return
;
}
mXCoordinates
.
append
(
xCoordinates
,
startPos
,
length
);
mYCoordinates
.
append
(
yCoordinates
,
startPos
,
length
);
mPointerIds
.
fill
(
pointerId
,
startPos
,
length
);
mTimes
.
append
(
times
,
startPos
,
length
);
}
public
void
reset
()
{
final
int
defaultCapacity
=
mDefaultCapacity
;
mXCoordinates
.
reset
(
defaultCapacity
);
...
...
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