blob: 4cb7707ec31902c3fd5443a5ca22b1dd6a6013d1 [file] [log] [blame]
Joe Onorato6e93a3d2009-04-17 14:18:46 -07001/*
Yang Li35aa84b2009-05-18 18:29:05 -07002 * Copyright (C) 2008-2009 The Android Open Source Project
Joe Onorato6e93a3d2009-04-17 14:18:46 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Romain Guydb567c32009-05-21 16:23:21 -070017package android.gesture;
Joe Onorato6e93a3d2009-04-17 14:18:46 -070018
Romain Guyb6d99b72009-05-21 15:05:50 -070019import java.io.DataInputStream;
20import java.io.IOException;
21
Joe Onorato6e93a3d2009-04-17 14:18:46 -070022/**
Yang Li6fc1f152010-01-15 14:35:27 -080023 * A timed point of a gesture stroke. Multiple points form a stroke.
Joe Onorato6e93a3d2009-04-17 14:18:46 -070024 */
Yang Li35aa84b2009-05-18 18:29:05 -070025
26public class GesturePoint {
Romain Guyc5347272009-05-20 10:37:13 -070027 public final float x;
28 public final float y;
Yang Li35aa84b2009-05-18 18:29:05 -070029
30 public final long timestamp;
31
32 public GesturePoint(float x, float y, long t) {
Romain Guyc5347272009-05-20 10:37:13 -070033 this.x = x;
34 this.y = y;
Yang Li35aa84b2009-05-18 18:29:05 -070035 timestamp = t;
36 }
Romain Guyb6d99b72009-05-21 15:05:50 -070037
38 static GesturePoint deserialize(DataInputStream in) throws IOException {
39 // Read X and Y
40 final float x = in.readFloat();
41 final float y = in.readFloat();
42 // Read timestamp
43 final long timeStamp = in.readLong();
44 return new GesturePoint(x, y, timeStamp);
45 }
Yang Li6fc1f152010-01-15 14:35:27 -080046
47 @Override
48 public Object clone() {
49 return new GesturePoint(x, y, timestamp);
50 }
Joe Onorato6e93a3d2009-04-17 14:18:46 -070051}