16e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato/* 235aa84b1f9f5e42dd00cb66df993ed1628c8963bYang Li * Copyright (C) 2008-2009 The Android Open Source Project 36e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato * 46e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato * Licensed under the Apache License, Version 2.0 (the "License"); 56e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato * you may not use this file except in compliance with the License. 66e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato * You may obtain a copy of the License at 76e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato * 86e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato * http://www.apache.org/licenses/LICENSE-2.0 96e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato * 106e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato * Unless required by applicable law or agreed to in writing, software 116e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato * distributed under the License is distributed on an "AS IS" BASIS, 126e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato * See the License for the specific language governing permissions and 146e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato * limitations under the License. 156e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato */ 166e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato 17db567c390bd56c05614eaa83c02dbb99f97ad9ccRomain Guypackage android.gesture; 186e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato 19b6d99b7d17fd1bb1326a70744bd01be5d1586487Romain Guyimport java.io.DataInputStream; 20b6d99b7d17fd1bb1326a70744bd01be5d1586487Romain Guyimport java.io.IOException; 21b6d99b7d17fd1bb1326a70744bd01be5d1586487Romain Guy 226e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato/** 236fc1f151341c628125e7d20c1667a23862f32ce4Yang Li * A timed point of a gesture stroke. Multiple points form a stroke. 246e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato */ 2535aa84b1f9f5e42dd00cb66df993ed1628c8963bYang Li 2635aa84b1f9f5e42dd00cb66df993ed1628c8963bYang Lipublic class GesturePoint { 27c534727972c3835ed997e84a349f259915ef2cddRomain Guy public final float x; 28c534727972c3835ed997e84a349f259915ef2cddRomain Guy public final float y; 2935aa84b1f9f5e42dd00cb66df993ed1628c8963bYang Li 3035aa84b1f9f5e42dd00cb66df993ed1628c8963bYang Li public final long timestamp; 3135aa84b1f9f5e42dd00cb66df993ed1628c8963bYang Li 3235aa84b1f9f5e42dd00cb66df993ed1628c8963bYang Li public GesturePoint(float x, float y, long t) { 33c534727972c3835ed997e84a349f259915ef2cddRomain Guy this.x = x; 34c534727972c3835ed997e84a349f259915ef2cddRomain Guy this.y = y; 3535aa84b1f9f5e42dd00cb66df993ed1628c8963bYang Li timestamp = t; 3635aa84b1f9f5e42dd00cb66df993ed1628c8963bYang Li } 37b6d99b7d17fd1bb1326a70744bd01be5d1586487Romain Guy 38b6d99b7d17fd1bb1326a70744bd01be5d1586487Romain Guy static GesturePoint deserialize(DataInputStream in) throws IOException { 39b6d99b7d17fd1bb1326a70744bd01be5d1586487Romain Guy // Read X and Y 40b6d99b7d17fd1bb1326a70744bd01be5d1586487Romain Guy final float x = in.readFloat(); 41b6d99b7d17fd1bb1326a70744bd01be5d1586487Romain Guy final float y = in.readFloat(); 42b6d99b7d17fd1bb1326a70744bd01be5d1586487Romain Guy // Read timestamp 43b6d99b7d17fd1bb1326a70744bd01be5d1586487Romain Guy final long timeStamp = in.readLong(); 44b6d99b7d17fd1bb1326a70744bd01be5d1586487Romain Guy return new GesturePoint(x, y, timeStamp); 45b6d99b7d17fd1bb1326a70744bd01be5d1586487Romain Guy } 466fc1f151341c628125e7d20c1667a23862f32ce4Yang Li 476fc1f151341c628125e7d20c1667a23862f32ce4Yang Li @Override 486fc1f151341c628125e7d20c1667a23862f32ce4Yang Li public Object clone() { 496fc1f151341c628125e7d20c1667a23862f32ce4Yang Li return new GesturePoint(x, y, timestamp); 506fc1f151341c628125e7d20c1667a23862f32ce4Yang Li } 516e93a3db56d6add29b43077718a4cad9ccfc047fJoe Onorato} 52