2 * (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
\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
15 * (C) Copyright IBM Corp. 1998, All Rights Reserved
\r
18 package com.ibm.richtext.textpanel;
\r
20 import java.awt.event.KeyEvent;
\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
28 * @see TextPanel#setKeyRemap
\r
31 public class KeyRemap {
\r
33 static final String COPYRIGHT =
\r
34 "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
\r
36 * Create a new KeyRemap.
\r
38 protected KeyRemap() {
\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
52 /*public*/ char remap(char c) {
\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
64 /*public*/ char remap(KeyEvent keyEvent) {
\r
66 return remap(keyEvent.getKeyChar());
\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
76 * Return a KeyRemap which maps every character to itself.
\r
78 public static KeyRemap getIdentityRemap() {
\r
84 * Return a KeyRemap which maps keys to
\r
85 * characters in the Arabic alphabet, using a simple transliteration.
\r
87 public static KeyRemap getArabicTransliteration() {
\r
89 return ARABIC_TRANSLITERATION;
\r
93 * Return a KeyRemap which maps keys to
\r
94 * characters in the Hebrew alphabet, using a simple transliteration.
\r
96 public static KeyRemap getHebrewTransliteration() {
\r
98 return HEBREW_TRANSLITERATION;
\r
102 * Return a KeyRemap which emulates a standard Hebrew keyboard.
\r
104 public static KeyRemap getIsraelNikud() {
\r
106 return ISRAEL_NIKUD;
\r
110 * Return a KeyRemap which emulates a Thai Ketmanee keyboard.
\r
112 public static KeyRemap getThaiKetmanee() {
\r