2012-06-29 09:42:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
|
|
* use this file except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations under
|
|
|
|
* the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.android.inputmethod.latin;
|
|
|
|
|
2012-07-13 02:17:25 +00:00
|
|
|
// TODO: This class is not thread-safe.
|
2012-06-29 09:42:15 +00:00
|
|
|
public class InputPointers {
|
2012-07-18 11:31:09 +00:00
|
|
|
private final int mDefaultCapacity;
|
2012-07-19 10:45:20 +00:00
|
|
|
private final ResizableIntArray mXCoordinates;
|
|
|
|
private final ResizableIntArray mYCoordinates;
|
|
|
|
private final ResizableIntArray mPointerIds;
|
|
|
|
private final ResizableIntArray mTimes;
|
2012-07-18 11:31:09 +00:00
|
|
|
|
|
|
|
public InputPointers(int defaultCapacity) {
|
|
|
|
mDefaultCapacity = defaultCapacity;
|
2012-07-19 10:45:20 +00:00
|
|
|
mXCoordinates = new ResizableIntArray(defaultCapacity);
|
|
|
|
mYCoordinates = new ResizableIntArray(defaultCapacity);
|
|
|
|
mPointerIds = new ResizableIntArray(defaultCapacity);
|
|
|
|
mTimes = new ResizableIntArray(defaultCapacity);
|
2012-07-18 11:31:09 +00:00
|
|
|
}
|
2012-06-29 09:42:15 +00:00
|
|
|
|
|
|
|
public void addPointer(int index, int x, int y, int pointerId, int time) {
|
|
|
|
mXCoordinates.add(index, x);
|
|
|
|
mYCoordinates.add(index, y);
|
|
|
|
mPointerIds.add(index, pointerId);
|
|
|
|
mTimes.add(index, time);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addPointer(int x, int y, int pointerId, int time) {
|
|
|
|
mXCoordinates.add(x);
|
|
|
|
mYCoordinates.add(y);
|
|
|
|
mPointerIds.add(pointerId);
|
|
|
|
mTimes.add(time);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void set(InputPointers ip) {
|
|
|
|
mXCoordinates.set(ip.mXCoordinates);
|
|
|
|
mYCoordinates.set(ip.mYCoordinates);
|
|
|
|
mPointerIds.set(ip.mPointerIds);
|
|
|
|
mTimes.set(ip.mTimes);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void copy(InputPointers ip) {
|
|
|
|
mXCoordinates.copy(ip.mXCoordinates);
|
|
|
|
mYCoordinates.copy(ip.mYCoordinates);
|
|
|
|
mPointerIds.copy(ip.mPointerIds);
|
|
|
|
mTimes.copy(ip.mTimes);
|
|
|
|
}
|
|
|
|
|
2012-07-09 07:40:13 +00:00
|
|
|
/**
|
|
|
|
* Append the pointers in the specified {@link InputPointers} to the end of this.
|
2012-07-13 02:17:25 +00:00
|
|
|
* @param src the source {@link InputPointers} to read the data from.
|
2012-07-09 07:40:13 +00:00
|
|
|
* @param startPos the starting index of the pointers in {@code src}.
|
|
|
|
* @param length the number of pointers to be appended.
|
|
|
|
*/
|
|
|
|
public void append(InputPointers src, int startPos, int length) {
|
2012-07-18 08:56:30 +00:00
|
|
|
if (length == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2012-07-13 02:17:25 +00:00
|
|
|
mXCoordinates.append(src.mXCoordinates, startPos, length);
|
|
|
|
mYCoordinates.append(src.mYCoordinates, startPos, length);
|
|
|
|
mPointerIds.append(src.mPointerIds, startPos, length);
|
|
|
|
mTimes.append(src.mTimes, startPos, length);
|
2012-07-09 07:40:13 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 09:42:15 +00:00
|
|
|
public void reset() {
|
2012-07-18 11:31:09 +00:00
|
|
|
final int defaultCapacity = mDefaultCapacity;
|
|
|
|
mXCoordinates.reset(defaultCapacity);
|
|
|
|
mYCoordinates.reset(defaultCapacity);
|
|
|
|
mPointerIds.reset(defaultCapacity);
|
|
|
|
mTimes.reset(defaultCapacity);
|
2012-06-29 09:42:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getPointerSize() {
|
|
|
|
return mXCoordinates.getLength();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int[] getXCoordinates() {
|
2012-07-09 07:40:13 +00:00
|
|
|
return mXCoordinates.getPrimitiveArray();
|
2012-06-29 09:42:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int[] getYCoordinates() {
|
2012-07-09 07:40:13 +00:00
|
|
|
return mYCoordinates.getPrimitiveArray();
|
2012-06-29 09:42:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int[] getPointerIds() {
|
2012-07-09 07:40:13 +00:00
|
|
|
return mPointerIds.getPrimitiveArray();
|
2012-06-29 09:42:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int[] getTimes() {
|
2012-07-09 07:40:13 +00:00
|
|
|
return mTimes.getPrimitiveArray();
|
2012-06-29 09:42:15 +00:00
|
|
|
}
|
|
|
|
}
|