net.sourceforge.vietpad
Class VietKey

java.lang.Object
  extended bynet.sourceforge.vietpad.VietKey

public class VietKey
extends Object

Vietnamese keyboard driver or input engine for Java text components. An instance of the VietKeyListener class serves as a preprocessor to this class. Together, they give Swing text components the capability of Vietnamese text input.

Input keys for diacritical marks follow VNI convention:

    1: ', 2: `, 3: ?, 4: ~, 5: ., 6: ^, 7: +, 8: (, 9: -, 0: remove diacritics.
 
Also, repeating the accent key deletes the accent just entered.


Method Summary
static char getAccentInTelex(String curWord, char key, char accent)
          Determines the correct accent for Telex mode.
static boolean isAccentRemoved()
          Determines if accent is removed by repeating accent key, not by designated accent-removing key.
static void setDiacriticsPosClassic(boolean classic)
          Sets the diacritics position to follow the classic style.
static String shiftAccent(String curWord, char key)
          Shifts the accent mark to the second vowel in a two-consecutive-vowel sequence when the user types in the right combination (the letter coming after to vowels), as in to`a + n -> toa`n.
static char toVietChar(char curChar, char accentKey)
          Composes the Vietnamese character.
static char toVietChar(char curChar, int accentIndex)
          Composes the Vietnamese character.
static String toVietWord(String curWord, char accentKey)
          Composes the Vietnamese word.
static String toVietWord(String curWord, int accentIndex)
          Composes the Vietnamese word.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toVietChar

public static char toVietChar(char curChar,
                              char accentKey)
Composes the Vietnamese character.

Parameters:
curChar - the character at current caret position
accentKey - the accent key, ranging from '0' - '9'
Returns:
the result Vietnamese character

toVietChar

public static char toVietChar(char curChar,
                              int accentIndex)
Composes the Vietnamese character.

Parameters:
curChar - the character at current caret position
accentIndex - the code point value of the accent key, ranging from 0 - 9
Returns:
the result Vietnamese character

toVietWord

public static String toVietWord(String curWord,
                                char accentKey)
Composes the Vietnamese word.

Parameters:
curWord - the word at current caret position
accentKey - accent key, ranging from '0' - '9'
Returns:
the result Vietnamese word

toVietWord

public static String toVietWord(String curWord,
                                int accentIndex)
Composes the Vietnamese word.

Parameters:
curWord - the word at current caret position
accentIndex - the code point value of the accent key, ranging from 0 - 9
Returns:
the result Vietnamese word

shiftAccent

public static String shiftAccent(String curWord,
                                 char key)
Shifts the accent mark to the second vowel in a two-consecutive-vowel sequence when the user types in the right combination (the letter coming after to vowels), as in to`a + n -> toa`n.

Parameters:
curWord - the word at current caret position
key - the key input
Returns:
the new word if shifting occurs
the curWord, otherwise

getAccentInTelex

public static char getAccentInTelex(String curWord,
                                    char key,
                                    char accent)
Determines the correct accent for Telex mode.

Parameters:
curWord - the word at current caret position
key - the key input
accent - the accent key for Telex
Returns:
the correct accent: '6', '7', or '8'; '\0' for invalid accent input

isAccentRemoved

public static boolean isAccentRemoved()
Determines if accent is removed by repeating accent key, not by designated accent-removing key.

Returns:
true if accent is removed by repeating accent key
false if accent is removed by VNI '0' key, VIQR '-' key, or Telex 'z' key

setDiacriticsPosClassic

public static void setDiacriticsPosClassic(boolean classic)
Sets the diacritics position to follow the classic style.

Parameters:
classic - true for classic; false for modern