|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.text.JTextComponent | +--javax.swing.JEditorPane | +--javax.swing.JTextPane | +--org.thdl.tib.input.TibetanPane | +--org.thdl.tib.input.DuffPane
Enables input of Tibetan text using Tibetan Computer Company's free cross-platform TibetanMachineWeb fonts. Two modes of text entry are allowed. In Tibetan mode, keystrokes are intercepted and reinterpreted according to the Tibetan keyboard installed. The result, of course, is Tibetan text, in the TibetanMachineWeb encoding. In Roman mode, keystrokes are not intercepted, and the font defaults to a Roman or user-defined font.
Nested Class Summary | |
(package private) class |
DuffPane.RTFSelection
|
Field Summary | |
private Caret |
caret
The caret of TibetanPane.doc , used to keep track of the
current entry/edit/deletion position. |
private ArrayList |
charList
A central part of the Tibetan keyboard. |
private StringBuffer |
holdCurrent
This field keeps track of what is currently being typed, to account for characters (such as Wylie 'tsh') which correspond to more than one keystroke in the keyboard. |
private boolean |
isCutAndPasteEnabled
|
private boolean |
isDefinitelySanskrit
True iff it is definitely the case that the user is typing Sanskrit (for example a Sanskrit stack), rather than Tibetan |
private boolean |
isDefinitelySanskrit_default
According to the active keyboard, the value isDefinitelySanskrit should be assigned by default when the
keyboard is initialized by initKeyboard |
private boolean |
isDefinitelySanskrit_withStackKey
According to the active keyboard, the value that should be assigned to isDefinitelySanskrit if the
user has initiated a stack by typing a stack key. |
private boolean |
isDefinitelyTibetan
Is it definitely the case that the user is typing Tibetan, rather than Sanskrit? |
private boolean |
isDefinitelyTibetan_default
According to the active keyboard, what value isDefinitelyTibetan should be assigned by default when the
keyboard is initialized by initKeyboard |
private boolean |
isDefinitelyTibetan_withStackKey
According to the active keyboard, what value isDefinitelyTibetan should be assigned if the user has initiated a
stack by typing a stack key. |
private boolean |
isRomanEnabled
true iff the user is allowed to type non-Tibetan. |
private boolean |
isStackingOn
True iff consonant stacking is allowed at the moment. |
private boolean |
isStackingOn_default
True iff, according to the active keyboard, stacking is on by default assuming no stack key has been pressed. |
private boolean |
isStackingRightToLeft
Automatic stacking in Wylie is from right to left. |
private boolean |
isTibetan
true iff the user is in Tibetan typing mode. |
private boolean |
isTopHypothesis
This field says whether or not the character atop charList
has been finalized, and therefore whether subsequent keystrokes are
allowed to displace this character. |
private boolean |
isTypingVowel
Is the user in the process of typing a vowel? |
private int |
lastStart
used for tracking changes in Wylie to TMW conversion |
private List |
newGlyphList
A central component of the Tibetan input method. |
private int |
numberOfGlyphsForLastVowel
If the character last displayed was a vowel, this is how many glyphs the vowel was composed of. |
private List |
oldGlyphList
This field holds a copy of the last newGlyphList . |
private MutableAttributeSet |
romanAttributeSet
|
private String |
romanFontFamily
|
private int |
romanFontSize
|
private Style |
rootStyle
|
private Clipboard |
rtfBoard
|
private boolean |
skipUpdate
|
private org.thdl.util.StatusBar |
statBar
The status bar to update with messages about the current input mode. |
Fields inherited from class org.thdl.tib.input.TibetanPane |
doc, rtfEd, rtfFlavor |
Fields inherited from class javax.swing.JTextPane |
|
Fields inherited from class javax.swing.JEditorPane |
|
Fields inherited from class javax.swing.text.JTextComponent |
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY |
Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Container |
|
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
DuffPane()
|
|
DuffPane(org.thdl.util.StatusBar sb)
Creates a new DuffPane that updates sb, if sb is not null, with messages about how the users' keypresses are being interpreted. |
|
DuffPane(org.thdl.tib.text.TibetanKeyboard keyboard)
|
|
DuffPane(URL keyboardURL)
|
Method Summary | |
void |
append(int offset,
String s,
MutableAttributeSet attr)
Inserts Roman text into this object's document. |
void |
append(String s,
MutableAttributeSet attr)
Inserts Roman text into this object's document, at the position of the caret. |
protected void |
appendStatus(String msg)
If we have a status bar, append msg to its current status. |
private void |
backSpace(int k)
Backspace and remove k elements from the current caret position. |
private void |
copy(int start,
int end,
boolean remove)
Cuts or copies the specified portion of this object's document to the system clipboard. |
void |
copyCurrentSelection()
Copies the current selection to the system clipboard, unless cut-and-paste operations are disabled. |
void |
cutCurrentSelection()
If this.isEditable(), then this copies the current selection to the system clipboard and then deletes it. |
private static int |
defaultRomanFontSize()
|
private static int |
defaultTibFontSize()
|
void |
deleteCurrentSelection()
If this.isEditable(), then this deletes the current selection. |
void |
disableCutAndPaste()
Disables cutting and pasting of Tibetan text. |
void |
disableRoman()
Disables typing of Roman (non-Tibetan) text. |
void |
enableCutAndPaste()
Enables cutting and pasting of Tibetan text. |
void |
enableRoman()
Enables typing of Roman (non-Tibetan) text along with Tibetan. |
void |
focusGained(FocusEvent e)
Required by implementations of the FocusListener interface,
this method simply initializes the keyboard whenever this
object gains focus. |
void |
focusLost(FocusEvent e)
Required by implementations of the FocusListener interface,
this method resets the keyboard. |
private int |
getNumberOfGlyphsForLastVowel()
|
String |
getRomanFontFamily()
Gets the current font used for non-Tibetan text. |
int |
getRomanFontSize()
Gets the current point size for non-Tibetan text. |
int |
getTibetanFontSize()
Gets the current point size for Tibetan text. |
String |
getWylie()
Converts the entire associated document into Extended Wylie. |
private void |
initialize(org.thdl.util.StatusBar sb,
org.thdl.tib.text.TibetanKeyboard keyboard,
URL keyboardURL)
Initializes this object. |
private void |
initKeyboard()
Initializes the keyboard input interpreter, setting all properties back to their default states. |
boolean |
isCutAndPasteOn()
Returns true iff cut-and-paste operations are enabled. |
boolean |
isRomanEnabled()
Checks to see if Roman input is enabled. |
boolean |
isRomanMode()
Checks to see if currently in Roman input mode. |
void |
keyPressed(KeyEvent e)
This method is required as part of the implementation of the KeyListener interface. |
void |
keyReleased(KeyEvent e)
Required of implementations of the Key Listener interface, this method does (almost) nothing. |
void |
keyTyped(KeyEvent e)
Required of implementations of the KeyListener interface, this method handles the pressing of non-control and non-action keys. |
void |
newDocument()
Clears the current document. |
void |
paste(int offset)
Pastes the contents of the system clipboard into this object's document, at the specified position. |
private void |
printAChenWithVowel(String v)
Prints ACHEN together with the vowel v. |
void |
processTibetan(KeyEvent kev)
Interprets a key typed during Tibetan input mode. |
private void |
processTibetanChar(char c,
boolean shouldIBackSpace)
Utility method used by processTibetan(keyEvent). |
private void |
putBindu()
Puts a bindu/anusvara at the current caret position. |
private void |
putVowel(String v)
Tries to insert the vowel v at the position of the caret. |
private List |
redrawGlyphs(List oldGlyphList,
List newGlyphList)
Takes an old glyph list, which should be the currently visible set of glyphs preceding the cursor, and then tries to redraw the glyphs in light of the newly acquired keyboard input (which led to a revised 'new' glyph list). |
void |
registerKeyboard()
Registers the Extended Wylie keyboard, and sets it as the active keyboard. |
void |
registerKeyboard(org.thdl.tib.text.TibetanKeyboard keyboard)
Registers a keyboard, and sets it as the active keyboard. |
void |
registerKeyboard(URL keyboardURL)
Registers a keyboard, and sets it as the active keyboard. |
void |
setByUserRomanAttributeSet(String font,
int size)
Like setRomanAttributeSet(java.lang.String, int) , but allows for noting the
(explicit or implicit) choice in the user's preferences
file. |
void |
setByUserTibetanFontSize(int size)
Like setTibetanFontSize(int) , but should be called only
when the user has somewhat explicitly chosen the font size. |
private void |
setNumberOfGlyphsForLastVowel(int x)
|
void |
setRomanAttributeSet(String font,
int size)
Changes the default font and font size for non-Tibetan (Roman) text entry mode. |
void |
setStatusBar(org.thdl.util.StatusBar sb)
Sets the status bar to update with mode information. |
void |
setTibetanFontSize(int size)
Changes the default font size for Tibetan text entry mode. |
private void |
setupEditor()
This method sets up the editor, assigns fonts and point sizes, sets the document, the caret, and adds key and focus listeners. |
void |
setupKeyboard()
This method sets up the Tibetan keyboard. |
void |
toggleLanguage()
Toggles between Tibetan and Roman input modes. |
void |
toTibetanMachineWeb()
Converts the currently selected text from Extended Wylie to TibetanMachineWeb. |
void |
toTibetanMachineWeb(int start,
int end)
Converts a stretch of text from Extended Wylie to TibetanMachineWeb. |
void |
toTibetanMachineWeb(String wylie,
int offset)
Converts a string of Extended Wylie to TibetanMachineWeb, and inserts it at the specified position. |
void |
toWylie()
Converts the entire document to Extended Wylie. |
void |
toWylie(int start,
int end)
Converts the specified portion of this object's document to Extended Wylie. |
protected void |
updateStatus(String newStatus)
If we have a status bar, update it. |
Methods inherited from class org.thdl.tib.input.TibetanPane |
getTibDoc |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private org.thdl.util.StatusBar statBar
private ArrayList charList
newGlyphList
is computed on the basis of charList.
private List oldGlyphList
newGlyphList
.
Then, when a key is pressed, charList
is updated, a new
newGlyphList is computed, and the newGlyphList is compared against
this field. The text on the screen is then modified to reflect
the new newGlyphList.
private List newGlyphList
charList
keeps track of the characters that have been entered, it does not organize them
correctly into the proper glyphs. For example, charList might have four characters
in it, 'b', 's', 'g', and 'r', but it does not know that they should be drawn as
two glyphs, 'b' and 's-g-r'. newGlyphList is a list of glyphs
(DuffCodes
) which is formed by
private StringBuffer holdCurrent
private boolean isTopHypothesis
charList
has been finalized, and therefore whether subsequent keystrokes are
allowed to displace this character. For example, if 'k' is at the
top of charList, and isTopHypothesis is true, then typing 'h' would
replace 'k' with 'kh'. On the other hand, were isTopHypothesis
false, then typing 'h' would add 'h' to the top of charList instead.
In short, is the top character on charList
a fact or just a
hypothesis?
private boolean isTypingVowel
private boolean isDefinitelyTibetan
private boolean isDefinitelyTibetan_default
isDefinitelyTibetan
should be assigned by default when the
keyboard is initialized by initKeyboard
private boolean isDefinitelyTibetan_withStackKey
isDefinitelyTibetan
should be assigned if the user has initiated a
stack by typing a stack key. For example, in the Wylie keyboard,
there is a Sanskrit stacking key ('+'), but no Tibetan stacking key.
Therefore, if the user is stacking with '+', this field should be
false, since what the user is typing must be Sanskrit, not Tibetan.
private boolean isDefinitelySanskrit
private boolean isDefinitelySanskrit_default
isDefinitelySanskrit
should be assigned by default when the
keyboard is initialized by initKeyboard
private boolean isDefinitelySanskrit_withStackKey
isDefinitelySanskrit
if the
user has initiated a stack by typing a stack key.
For example, in the Wylie keyboard, there is a Sanskrit
stacking key ('+'), but no Tibetan stacking key.
Therefore, if the user is stacking with '+', this field
should be true, since what the user is typing must
be Sanskrit, not Tibetan.
private boolean isStackingOn
private boolean isStackingOn_default
private boolean isStackingRightToLeft
private int lastStart
private boolean isTibetan
private boolean isRomanEnabled
private Caret caret
TibetanPane.doc
, used to keep track of the
current entry/edit/deletion position.
private Style rootStyle
private boolean skipUpdate
private boolean isCutAndPasteEnabled
private String romanFontFamily
private int romanFontSize
private MutableAttributeSet romanAttributeSet
private Clipboard rtfBoard
private int numberOfGlyphsForLastVowel
Constructor Detail |
public DuffPane(org.thdl.util.StatusBar sb)
public DuffPane()
public DuffPane(org.thdl.tib.text.TibetanKeyboard keyboard)
public DuffPane(URL keyboardURL)
Method Detail |
private void initialize(org.thdl.util.StatusBar sb, org.thdl.tib.text.TibetanKeyboard keyboard, URL keyboardURL)
public void setStatusBar(org.thdl.util.StatusBar sb)
protected void updateStatus(String newStatus)
protected void appendStatus(String msg)
private static int defaultTibFontSize()
private static int defaultRomanFontSize()
private void setupEditor()
public void setupKeyboard()
public void registerKeyboard()
TibetanMachineWeb
but don't register it here.
public void registerKeyboard(URL keyboardURL)
TibetanMachineWeb
but don't
register it in here.
keyboardURL
- the URL of the keyboard you want to installpublic void registerKeyboard(org.thdl.tib.text.TibetanKeyboard keyboard)
TibetanMachineWeb
but don't register it in here.
keyboard
- the keyboard you want to installpublic void newDocument()
private void initKeyboard()
public void enableRoman()
public void disableRoman()
public boolean isRomanEnabled()
public boolean isRomanMode()
public void toggleLanguage()
enableRoman()
,
disableRoman()
public void append(String s, MutableAttributeSet attr)
attr
- the attributes for the text to inserts
- the string of text to insertpublic void append(int offset, String s, MutableAttributeSet attr)
offset
- the position at which to insert textattr
- the attributes for the text to inserts
- the string of text to insertpublic void setTibetanFontSize(int size)
size
- a point sizepublic void setByUserTibetanFontSize(int size)
setTibetanFontSize(int)
, but should be called only
when the user has somewhat explicitly chosen the font size.
This will set the font size but also record this as a user
preference. Then you can choose to save the user preferences
via ThdlOptions.saveUserPreferences()
.
size
- a point sizepublic int getTibetanFontSize()
public void setRomanAttributeSet(String font, int size)
font
- a font namesize
- a point sizepublic void setByUserRomanAttributeSet(String font, int size)
setRomanAttributeSet(java.lang.String, int)
, but allows for noting the
(explicit or implicit) choice in the user's preferences
file.
public int getRomanFontSize()
public String getRomanFontFamily()
private void backSpace(int k)
k
- the number of glyphs to remove by backspaceprivate List redrawGlyphs(List oldGlyphList, List newGlyphList)
For example, suppose that oldGlyphList contains the two glyphs 'l' and 'n', and newGlyphList contains a single glyph, 'lng'. In this case, redrawGlyphs will be instructed to backspace over both 'l' and 'n', and then insert 'lng'.
private void putVowel(String v)
v
- the vowel (in Wylie) you want to insertprivate int getNumberOfGlyphsForLastVowel()
private void setNumberOfGlyphsForLastVowel(int x)
private void printAChenWithVowel(String v)
isAChenRequiredBeforeVowel()
is false, this method is called frequently.
v
- the vowel (in Wylie) which you want to print with ACHENprivate void putBindu()
public void focusGained(FocusEvent e)
FocusListener
interface,
this method simply initializes the keyboard whenever this
object gains focus.
focusGained
in interface FocusListener
e
- a FocusEventpublic void focusLost(FocusEvent e)
FocusListener
interface,
this method resets the keyboard.
focusLost
in interface FocusListener
e
- a FocusEventpublic void copyCurrentSelection()
public void cutCurrentSelection()
public void deleteCurrentSelection()
private void copy(int start, int end, boolean remove)
start
- the begin offset of the copyend
- the end offset of the copyremove
- this should be true if the operation is 'cut',
false if it is 'copy'public void paste(int offset)
offset
- the position in the document you want to paste topublic void enableCutAndPaste()
public boolean isCutAndPasteOn()
public void disableCutAndPaste()
public void keyPressed(KeyEvent e)
keyPressed
in interface KeyListener
public void keyReleased(KeyEvent e)
keyReleased
in interface KeyListener
e
- the KeyEventpublic void keyTyped(KeyEvent e)
processTibetan(KeyEvent e)
, which
contains the meat of the keyboard logic. If the user is in English mode, then
append
is called.
keyTyped
in interface KeyListener
e
- a KeyEventpublic void processTibetan(KeyEvent kev)
private void processTibetanChar(char c, boolean shouldIBackSpace)
c
- the character the user entered in whatever keyboard
is in useshouldIBackSpace
- false iff a press of the backspace key
should not backspace, such as when you've selected some text
and then pressed backspaceprocessTibetan(KeyEvent)
public void toWylie()
public void toWylie(int start, int end)
start
- the point from which to begin converting to Wylieend
- the point at which to stop converting to Wyliepublic void toTibetanMachineWeb(String wylie, int offset)
wylie
- the string of Wylie to convertoffset
- the position at which to insert the conversionpublic void toTibetanMachineWeb()
public void toTibetanMachineWeb(int start, int end)
start
- the begin point for the conversionend
- the end point for the conversionpublic String getWylie()
TibetanDocument.getWylie()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |