Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 1 | /* |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 2 | * Copyright (C) 2008-2009 The Android Open Source Project |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 3 | * |
| 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 Guy | db567c3 | 2009-05-21 16:23:21 -0700 | [diff] [blame] | 17 | package android.gesture; |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 18 | |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 19 | import java.io.DataInputStream; |
| 20 | import java.io.IOException; |
| 21 | |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 22 | /** |
Yang Li | 6fc1f15 | 2010-01-15 14:35:27 -0800 | [diff] [blame] | 23 | * A timed point of a gesture stroke. Multiple points form a stroke. |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 24 | */ |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 25 | |
| 26 | public class GesturePoint { |
Romain Guy | c534727 | 2009-05-20 10:37:13 -0700 | [diff] [blame] | 27 | public final float x; |
| 28 | public final float y; |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 29 | |
| 30 | public final long timestamp; |
| 31 | |
| 32 | public GesturePoint(float x, float y, long t) { |
Romain Guy | c534727 | 2009-05-20 10:37:13 -0700 | [diff] [blame] | 33 | this.x = x; |
| 34 | this.y = y; |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 35 | timestamp = t; |
| 36 | } |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 37 | |
| 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 Li | 6fc1f15 | 2010-01-15 14:35:27 -0800 | [diff] [blame] | 46 | |
| 47 | @Override |
| 48 | public Object clone() { |
| 49 | return new GesturePoint(x, y, timestamp); |
| 50 | } |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 51 | } |