View Javadoc

1   /*
2    * @(#)$Id: GestureKeyMapping.java 689 2009-07-22 00:10:27Z bsigner $
3    *
4    * Author       :   Ueli Kurmann, igesture@uelikurmann.ch
5    *
6    * Purpose      : 	Gesture-to-keyboard mapping.
7    *
8    * -----------------------------------------------------------------------
9    *
10   * Revision Information:
11   *
12   * Date             Who         Reason
13   *
14   * Mar 09, 2007     ukurmann    Initial Release
15   * Mar 24, 2007     bsigner     Cleanup
16   *
17   * -----------------------------------------------------------------------
18   *
19   * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20   *
21   * This software is the proprietary information of ETH Zurich.
22   * Use is subject to license terms.
23   * 
24   */
25  
26  
27  package org.igesture.app.keyboard;
28  
29  import org.sigtec.util.Constant;
30  import org.ximtec.igesture.io.keyboard.Key;
31  
32  
33  /**
34   * Gesture-to-keyboard mapping.
35   * 
36   * @version 1.0 Mar 2007
37   * @author Ueli Kurmann, igesture@uelikurmann.ch
38   * @author Beat Signer, signer@inf.ethz.ch
39   */
40  public class GestureKeyMapping {
41  
42  
43     private Key[] keys;
44     private String gestureName;
45  
46  
47     public GestureKeyMapping(String gesture, Key... keys) {
48        super();
49        setKeys(keys);
50        this.gestureName = gesture;
51     }
52  
53  
54     public void setGestureName(String gestureName) {
55        this.gestureName = gestureName;
56     } // setGestureName
57  
58  
59     public String getGestureName() {
60        return gestureName;
61     } // getGestureName
62  
63  
64     public void setKeys(Key[] keys) {
65        this.keys = keys;
66     } // setKeys
67  
68  
69     public Key[] getKeys() {
70        return keys;
71     } // getKeys
72  
73  
74     @Override
75     public String toString() {
76        StringBuilder sb = new StringBuilder();
77        sb.append(Constant.OPEN_ANGULAR_BRACKET);
78  
79        for (Key key : keys) {
80           sb.append(key + Constant.PLUS);
81        }
82  
83        sb.deleteCharAt(sb.length() - 1);
84        sb.append(Constant.BLANK + Constant.SHORT_ARROW_RIGHT + Constant.BLANK
85              + gestureName + Constant.CLOSE_ANGULAR_BRACKET);
86        return sb.toString();
87     } // toString
88  
89  }