Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 1 | /* |
Romain Guy | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 2 | * Copyright (C) 2009 The Android Open Source Project |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -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 | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 17 | |
Romain Guy | db567c3 | 2009-05-21 16:23:21 -0700 | [diff] [blame] | 18 | package android.gesture; |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 19 | |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 20 | import java.util.Set; |
Romain Guy | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 21 | import java.util.ArrayList; |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 22 | |
Romain Guy | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 23 | public abstract class GestureLibrary { |
| 24 | protected final GestureStore mStore; |
Romain Guy | c534727 | 2009-05-20 10:37:13 -0700 | [diff] [blame] | 25 | |
Romain Guy | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 26 | protected GestureLibrary() { |
| 27 | mStore = new GestureStore(); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 28 | } |
| 29 | |
Romain Guy | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 30 | public abstract boolean save(); |
| 31 | |
| 32 | public abstract boolean load(); |
| 33 | |
| 34 | public boolean isReadOnly() { |
| 35 | return false; |
| 36 | } |
| 37 | |
| 38 | public Learner getLearner() { |
| 39 | return mStore.getLearner(); |
| 40 | } |
| 41 | |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 42 | public void setOrientationStyle(int style) { |
Romain Guy | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 43 | mStore.setOrientationStyle(style); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | public int getOrientationStyle() { |
Romain Guy | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 47 | return mStore.getOrientationStyle(); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 48 | } |
| 49 | |
Yang Li | ac6a4b8 | 2009-05-21 16:08:35 -0700 | [diff] [blame] | 50 | public void setSequenceType(int type) { |
Romain Guy | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 51 | mStore.setSequenceType(type); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 52 | } |
| 53 | |
Yang Li | ac6a4b8 | 2009-05-21 16:08:35 -0700 | [diff] [blame] | 54 | public int getSequenceType() { |
Romain Guy | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 55 | return mStore.getSequenceType(); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 56 | } |
| 57 | |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 58 | public Set<String> getGestureEntries() { |
Romain Guy | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 59 | return mStore.getGestureEntries(); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 62 | public ArrayList<Prediction> recognize(Gesture gesture) { |
Romain Guy | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 63 | return mStore.recognize(gesture); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 66 | public void addGesture(String entryName, Gesture gesture) { |
Romain Guy | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 67 | mStore.addGesture(entryName, gesture); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 70 | public void removeGesture(String entryName, Gesture gesture) { |
Romain Guy | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 71 | mStore.removeGesture(entryName, gesture); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 72 | } |
| 73 | |
Romain Guy | db567c3 | 2009-05-21 16:23:21 -0700 | [diff] [blame] | 74 | public void removeEntry(String entryName) { |
Romain Guy | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 75 | mStore.removeEntry(entryName); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 76 | } |
| 77 | |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 78 | public ArrayList<Gesture> getGestures(String entryName) { |
Romain Guy | 0a63716 | 2009-05-29 14:43:54 -0700 | [diff] [blame^] | 79 | return mStore.getGestures(entryName); |
Romain Guy | f40f074 | 2009-05-28 21:12:01 -0700 | [diff] [blame] | 80 | } |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 81 | } |