]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/richtext/textpanel/KeyRemap.java
icu4jsrc
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / richtext / textpanel / KeyRemap.java
1 /*\r
2  * (C) Copyright IBM Corp. 1998-2004.  All Rights Reserved.\r
3  *\r
4  * The program is provided "as is" without any warranty express or\r
5  * implied, including the warranty of non-infringement and the implied\r
6  * warranties of merchantibility and fitness for a particular purpose.\r
7  * IBM will not be liable for any damages suffered by you as a result\r
8  * of using the Program. In no event will IBM be liable for any\r
9  * special, indirect or consequential damages or lost profits even if\r
10  * IBM has been advised of the possibility of their occurrence. IBM\r
11  * will not be liable for any third party claims against you.\r
12  */\r
13 /*\r
14  *\r
15  * (C) Copyright IBM Corp. 1998, All Rights Reserved\r
16  */\r
17 \r
18 package com.ibm.richtext.textpanel;\r
19 \r
20 import java.awt.event.KeyEvent;\r
21 \r
22 /**\r
23  * KeyRemap maps keys on a standard US keyboard to characters\r
24  * in other alphabets.  Currently, mappings to Arabic, Hebrew\r
25  * and Thai are supported.  In the future, clients may be\r
26  * to define their own mappings by subclassing this class.\r
27  * <P>\r
28  * @see TextPanel#setKeyRemap\r
29  */\r
30 \r
31 public class KeyRemap {\r
32 \r
33     static final String COPYRIGHT =\r
34                 "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";\r
35     /**\r
36      * Create a new KeyRemap.\r
37      */\r
38     protected KeyRemap() {\r
39     }\r
40 \r
41     /**\r
42      * This method returns the character on the simulated keyboard\r
43      * which is (most likely) generated by typing the character c\r
44      * on the actual keyboard.  For greater accuracy, use the remap\r
45      * method which takes a KeyEvent, since it can take modifier\r
46      * keys into account.\r
47      * @arg c a character on the actual keyboard\r
48      * @return the character on the simulated keyboard which would\r
49      *         result from the key combination which produced the\r
50      *         given character on the actual keyboard\r
51      */\r
52     /*public*/ char remap(char c) {\r
53 \r
54         return c;\r
55     }\r
56 \r
57     /**\r
58      * Return the character on the simulated keyboard\r
59      * which keyEvent generates.\r
60      * @arg keyEvent a key event from the actual keyboard\r
61      * @return the character on the simulated keyboard generated by\r
62      *         keyEvent\r
63      */\r
64     /*public*/ char remap(KeyEvent keyEvent) {\r
65 \r
66         return remap(keyEvent.getKeyChar());\r
67     }\r
68 \r
69     private static final KeyRemap IDENTITY = new KeyRemap();\r
70     private static final KeyRemap ARABIC_TRANSLITERATION = new ArabicTransliteration();\r
71     private static final KeyRemap HEBREW_TRANSLITERATION = new HebrewTransliteration();\r
72     private static final KeyRemap ISRAEL_NIKUD = new IsraelNikudKeyboard();\r
73     private static final KeyRemap THAI = new ThaiKeyRemap();\r
74 \r
75     /**\r
76      * Return a KeyRemap which maps every character to itself.\r
77      */\r
78     public static KeyRemap getIdentityRemap() {\r
79 \r
80         return IDENTITY;\r
81     }\r
82 \r
83     /**\r
84      * Return a KeyRemap which maps keys to\r
85      * characters in the Arabic alphabet, using a simple transliteration.\r
86      */\r
87     public static KeyRemap getArabicTransliteration() {\r
88 \r
89         return ARABIC_TRANSLITERATION;\r
90     }\r
91 \r
92     /**\r
93      * Return a KeyRemap which maps keys to\r
94      * characters in the Hebrew alphabet, using a simple transliteration.\r
95      */\r
96     public static KeyRemap getHebrewTransliteration() {\r
97 \r
98         return HEBREW_TRANSLITERATION;\r
99     }\r
100 \r
101     /**\r
102      * Return a KeyRemap which emulates a standard Hebrew keyboard.\r
103      */\r
104     public static KeyRemap getIsraelNikud() {\r
105 \r
106         return ISRAEL_NIKUD;\r
107     }\r
108     \r
109     /**\r
110      * Return a KeyRemap which emulates a Thai Ketmanee keyboard.\r
111      */\r
112     public static KeyRemap getThaiKetmanee() {\r
113         \r
114         return THAI;\r
115     }\r
116 }\r