001: /*
002: * (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
003: *
004: * The program is provided "as is" without any warranty express or
005: * implied, including the warranty of non-infringement and the implied
006: * warranties of merchantibility and fitness for a particular purpose.
007: * IBM will not be liable for any damages suffered by you as a result
008: * of using the Program. In no event will IBM be liable for any
009: * special, indirect or consequential damages or lost profits even if
010: * IBM has been advised of the possibility of their occurrence. IBM
011: * will not be liable for any third party claims against you.
012: */
013: /*
014: *
015: * (C) Copyright IBM Corp. 1998, All Rights Reserved
016: */
017:
018: package com.ibm.richtext.textpanel;
019:
020: import java.awt.event.KeyEvent;
021:
022: /**
023: * KeyRemap maps keys on a standard US keyboard to characters
024: * in other alphabets. Currently, mappings to Arabic, Hebrew
025: * and Thai are supported. In the future, clients may be
026: * to define their own mappings by subclassing this class.
027: * <P>
028: * @see TextPanel#setKeyRemap
029: */
030:
031: public class KeyRemap {
032:
033: static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
034:
035: /**
036: * Create a new KeyRemap.
037: */
038: protected KeyRemap() {
039: }
040:
041: /**
042: * This method returns the character on the simulated keyboard
043: * which is (most likely) generated by typing the character c
044: * on the actual keyboard. For greater accuracy, use the remap
045: * method which takes a KeyEvent, since it can take modifier
046: * keys into account.
047: * @arg c a character on the actual keyboard
048: * @return the character on the simulated keyboard which would
049: * result from the key combination which produced the
050: * given character on the actual keyboard
051: */
052: /*public*/char remap(char c) {
053:
054: return c;
055: }
056:
057: /**
058: * Return the character on the simulated keyboard
059: * which keyEvent generates.
060: * @arg keyEvent a key event from the actual keyboard
061: * @return the character on the simulated keyboard generated by
062: * keyEvent
063: */
064: /*public*/char remap(KeyEvent keyEvent) {
065:
066: return remap(keyEvent.getKeyChar());
067: }
068:
069: private static final KeyRemap IDENTITY = new KeyRemap();
070: private static final KeyRemap ARABIC_TRANSLITERATION = new ArabicTransliteration();
071: private static final KeyRemap HEBREW_TRANSLITERATION = new HebrewTransliteration();
072: private static final KeyRemap ISRAEL_NIKUD = new IsraelNikudKeyboard();
073: private static final KeyRemap THAI = new ThaiKeyRemap();
074:
075: /**
076: * Return a KeyRemap which maps every character to itself.
077: */
078: public static KeyRemap getIdentityRemap() {
079:
080: return IDENTITY;
081: }
082:
083: /**
084: * Return a KeyRemap which maps keys to
085: * characters in the Arabic alphabet, using a simple transliteration.
086: */
087: public static KeyRemap getArabicTransliteration() {
088:
089: return ARABIC_TRANSLITERATION;
090: }
091:
092: /**
093: * Return a KeyRemap which maps keys to
094: * characters in the Hebrew alphabet, using a simple transliteration.
095: */
096: public static KeyRemap getHebrewTransliteration() {
097:
098: return HEBREW_TRANSLITERATION;
099: }
100:
101: /**
102: * Return a KeyRemap which emulates a standard Hebrew keyboard.
103: */
104: public static KeyRemap getIsraelNikud() {
105:
106: return ISRAEL_NIKUD;
107: }
108:
109: /**
110: * Return a KeyRemap which emulates a Thai Ketmanee keyboard.
111: */
112: public static KeyRemap getThaiKetmanee() {
113:
114: return THAI;
115: }
116: }
|