org.thdl.tib.input
Class DuffPane

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
All Implemented Interfaces:
Accessible, EventListener, FocusListener, ImageObserver, KeyListener, MenuContainer, Scrollable, Serializable
Direct Known Subclasses:
DuffCellRenderer, DuffCellRenderer

public class DuffPane
extends TibetanPane
implements KeyListener, FocusListener

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.

Author:
Edward Garrett, Tibetan and Himalayan Digital Library
See Also:
Serialized Form

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 javax.swing.JTextPane
addStyle, createDefaultEditorKit, getCharacterAttributes, getInputAttributes, getLogicalStyle, getParagraphAttributes, getStyle, getStyledDocument, getStyledEditorKit, getUIClassID, insertComponent, insertIcon, paramString, removeStyle, replaceSelection, setCharacterAttributes, setDocument, setEditorKit, setLogicalStyle, setParagraphAttributes, setStyledDocument
 
Methods inherited from class javax.swing.JEditorPane
addHyperlinkListener, createEditorKitForContentType, fireHyperlinkUpdate, getAccessibleContext, getContentType, getEditorKit, getEditorKitClassNameForContentType, getEditorKitForContentType, getHyperlinkListeners, getPage, getPreferredSize, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getStream, getText, read, registerEditorKitForContentType, registerEditorKitForContentType, removeHyperlinkListener, scrollToReference, setContentType, setEditorKitForContentType, setPage, setPage, setText
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

statBar

private org.thdl.util.StatusBar statBar
The status bar to update with messages about the current input mode. Are we expecting a vowel? a subscript? et cetera.


charList

private ArrayList charList
A central part of the Tibetan keyboard. As keys are typed, they are added to charList if they constitute a valid Wylie character. charList is added to in this manner until the user types punctuation, a vowel, or some action or function key. Later, when glyphs are printed to the screen, the newGlyphList is computed on the basis of charList.


oldGlyphList

private List oldGlyphList
This field holds a copy of the last 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.


newGlyphList

private List newGlyphList
A central component of the Tibetan input method. While 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


holdCurrent

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. It is cleared or readjusted when it is clear that the user has moved on to a different character. For example, after the user types 'khr', holdCurrent will contain only 'r', since 'khr' is not a valid character.


isTopHypothesis

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. 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?


isTypingVowel

private boolean isTypingVowel
Is the user in the process of typing a vowel?


isDefinitelyTibetan

private boolean isDefinitelyTibetan
Is it definitely the case that the user is typing Tibetan, rather than Sanskrit?


isDefinitelyTibetan_default

private boolean isDefinitelyTibetan_default
According to the active keyboard, what value isDefinitelyTibetan should be assigned by default when the keyboard is initialized by initKeyboard


isDefinitelyTibetan_withStackKey

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. 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.


isDefinitelySanskrit

private boolean isDefinitelySanskrit
True iff it is definitely the case that the user is typing Sanskrit (for example a Sanskrit stack), rather than Tibetan


isDefinitelySanskrit_default

private boolean isDefinitelySanskrit_default
According to the active keyboard, the value isDefinitelySanskrit should be assigned by default when the keyboard is initialized by initKeyboard


isDefinitelySanskrit_withStackKey

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. 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.


isStackingOn

private boolean isStackingOn
True iff consonant stacking is allowed at the moment. In the Wylie keyboard, consonant stacking is usually on, since stacking is automatic. However, in the TCC and Sambhota keyboards, stacking is off by default, since you can only stack when you've pressed a stacking key.


isStackingOn_default

private boolean isStackingOn_default
True iff, according to the active keyboard, stacking is on by default assuming no stack key has been pressed.


isStackingRightToLeft

private boolean isStackingRightToLeft
Automatic stacking in Wylie is from right to left. For example, if the user types 'brg', the resulting glyph sequence is 'b' plus 'rg', not 'br' plus 'g'. If stacking results from the use of a stack key, it is from left to right.


lastStart

private int lastStart
used for tracking changes in Wylie to TMW conversion


isTibetan

private boolean isTibetan
true iff the user is in Tibetan typing mode. This is true by default.


isRomanEnabled

private boolean isRomanEnabled
true iff the user is allowed to type non-Tibetan. This is true by default


caret

private Caret caret
The caret of TibetanPane.doc, used to keep track of the current entry/edit/deletion position.


rootStyle

private Style rootStyle

skipUpdate

private boolean skipUpdate

isCutAndPasteEnabled

private boolean isCutAndPasteEnabled

romanFontFamily

private String romanFontFamily

romanFontSize

private int romanFontSize

romanAttributeSet

private MutableAttributeSet romanAttributeSet

rtfBoard

private Clipboard rtfBoard

numberOfGlyphsForLastVowel

private int numberOfGlyphsForLastVowel
If the character last displayed was a vowel, this is how many glyphs the vowel was composed of. (Some vowels, such as Wylie 'I', consist of two glyphs.) We use the getter and setter for this variable and never the variable itself.

Constructor Detail

DuffPane

public 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

public DuffPane()

DuffPane

public DuffPane(org.thdl.tib.text.TibetanKeyboard keyboard)

DuffPane

public DuffPane(URL keyboardURL)
Method Detail

initialize

private void initialize(org.thdl.util.StatusBar sb,
                        org.thdl.tib.text.TibetanKeyboard keyboard,
                        URL keyboardURL)
Initializes this object. All constructors should call this.


setStatusBar

public void setStatusBar(org.thdl.util.StatusBar sb)
Sets the status bar to update with mode information. If sb is null, no status bar will be updated.


updateStatus

protected void updateStatus(String newStatus)
If we have a status bar, update it.


appendStatus

protected void appendStatus(String msg)
If we have a status bar, append msg to its current status.


defaultTibFontSize

private static int defaultTibFontSize()

defaultRomanFontSize

private static int defaultRomanFontSize()

setupEditor

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.


setupKeyboard

public void setupKeyboard()
This method sets up the Tibetan keyboard. Initially it is called by the constructor, but it is also called internally whenever the active keyboard is changed. It first sets various values with respect to stacking, and concerning the differences between Tibetan and Sanskrit; and then it initializes the input method.


registerKeyboard

public void registerKeyboard()
Registers the Extended Wylie keyboard, and sets it as the active keyboard. Unpredictable behavior will result if you set the keyboard in TibetanMachineWeb but don't register it here.


registerKeyboard

public void registerKeyboard(URL keyboardURL)
Registers a keyboard, and sets it as the active keyboard. Unpredictable behavior will result if you set the keyboard in TibetanMachineWeb but don't register it in here.

Parameters:
keyboardURL - the URL of the keyboard you want to install

registerKeyboard

public void registerKeyboard(org.thdl.tib.text.TibetanKeyboard keyboard)
Registers a keyboard, and sets it as the active keyboard. Unpredictable behavior will result if you set the keyboard in TibetanMachineWeb but don't register it in here.

Parameters:
keyboard - the keyboard you want to install

newDocument

public void newDocument()
Clears the current document.


initKeyboard

private void initKeyboard()
Initializes the keyboard input interpreter, setting all properties back to their default states. This method is called whenever an action or function key is pressed, and also whenever the user types punctuation or a vowel. It is not called when the user is typing characters that could be part of a stack, or require manipulation of glyphs - e.g. backspacing, redrawing, etc.


enableRoman

public void enableRoman()
Enables typing of Roman (non-Tibetan) text along with Tibetan.


disableRoman

public void disableRoman()
Disables typing of Roman (non-Tibetan) text.


isRomanEnabled

public boolean isRomanEnabled()
Checks to see if Roman input is enabled.

Returns:
true if so, false if not

isRomanMode

public boolean isRomanMode()
Checks to see if currently in Roman input mode.

Returns:
true if so, false if not

toggleLanguage

public void toggleLanguage()
Toggles between Tibetan and Roman input modes. Does nothing if Roman input is disabled.

See Also:
enableRoman(), disableRoman()

append

public void append(String s,
                   MutableAttributeSet attr)
Inserts Roman text into this object's document, at the position of the caret.

Parameters:
attr - the attributes for the text to insert
s - the string of text to insert

append

public void append(int offset,
                   String s,
                   MutableAttributeSet attr)
Inserts Roman text into this object's document.

Parameters:
offset - the position at which to insert text
attr - the attributes for the text to insert
s - the string of text to insert

setTibetanFontSize

public void setTibetanFontSize(int size)
Changes the default font size for Tibetan text entry mode.

Parameters:
size - a point size

setByUserTibetanFontSize

public void setByUserTibetanFontSize(int size)
Like 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().

Parameters:
size - a point size

getTibetanFontSize

public int getTibetanFontSize()
Gets the current point size for Tibetan text.

Returns:
the current default font size for Tibetan text entry mode

setRomanAttributeSet

public void setRomanAttributeSet(String font,
                                 int size)
Changes the default font and font size for non-Tibetan (Roman) text entry mode.

Parameters:
font - a font name
size - a point size

setByUserRomanAttributeSet

public 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.


getRomanFontSize

public int getRomanFontSize()
Gets the current point size for non-Tibetan text.

Returns:
the current default font size for non-Tibetan (Roman) text entry mode

getRomanFontFamily

public String getRomanFontFamily()
Gets the current font used for non-Tibetan text.

Returns:
the current default font for non-Tibetan (Roman) text entry mode

backSpace

private void backSpace(int k)
Backspace and remove k elements from the current caret position.

Parameters:
k - the number of glyphs to remove by backspace

redrawGlyphs

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). For example, the old glyph list might contain 'l' and 'n', because the user had typed 'ln' in Extended Wylie mode. This is what you'd see on the screen. But assume that the new glyph list contains the stacked glyph 'l-ng', because the user has just finished typing 'lng'. This method compares the glyphs, then figures out whether or not backspacing is necessary, and draws whatever characters need to be drawn.

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'.


putVowel

private void putVowel(String v)
Tries to insert the vowel v at the position of the caret. This method must deal with various issues, such as: can the preceding glyph take a vowel? If not, then what? If the preceding glyph can be followed by a vowel, then the method has to figure out what vowel glyph to affix, which may depend on the immediately preceding glyph, but may depend on other factors as well. For example, when affixing gigu to the consonantal stack "k'" (ie k plus achung), the value of the gigu will depend on "k", not "'".

Parameters:
v - the vowel (in Wylie) you want to insert

getNumberOfGlyphsForLastVowel

private int getNumberOfGlyphsForLastVowel()

setNumberOfGlyphsForLastVowel

private void setNumberOfGlyphsForLastVowel(int x)

printAChenWithVowel

private void printAChenWithVowel(String v)
Prints ACHEN together with the vowel v. When using the Wylie keyboard, or any other keyboard in which isAChenRequiredBeforeVowel() is false, this method is called frequently.

Parameters:
v - the vowel (in Wylie) which you want to print with ACHEN

putBindu

private void putBindu()
Puts a bindu/anusvara at the current caret position. In the TibetanMachineWeb font, top vowels (like gigu, drengbu, etc.) are merged together with bindu in a single glyph. This method deals with the problem of correctly displaying a bindu given this complication.


focusGained

public void focusGained(FocusEvent e)
Required by implementations of the FocusListener interface, this method simply initializes the keyboard whenever this object gains focus.

Specified by:
focusGained in interface FocusListener
Parameters:
e - a FocusEvent

focusLost

public void focusLost(FocusEvent e)
Required by implementations of the FocusListener interface, this method resets the keyboard.

Specified by:
focusLost in interface FocusListener
Parameters:
e - a FocusEvent

copyCurrentSelection

public void copyCurrentSelection()
Copies the current selection to the system clipboard, unless cut-and-paste operations are disabled.


cutCurrentSelection

public void cutCurrentSelection()
If this.isEditable(), then this copies the current selection to the system clipboard and then deletes it.


deleteCurrentSelection

public void deleteCurrentSelection()
If this.isEditable(), then this deletes the current selection.


copy

private void copy(int start,
                  int end,
                  boolean remove)
Cuts or copies the specified portion of this object's document to the system clipboard. What is cut/copied is Wylie text - so, if you cut/copy a region of TibetanMachineWeb, it first converts it to Wylie before putting it on the clipboard. If the user tries to cut/copy non-TibetanMachineWeb, only the text preceding the first non-TibetanMachineWeb character is cut/copied.

Parameters:
start - the begin offset of the copy
end - the end offset of the copy
remove - this should be true if the operation is 'cut', false if it is 'copy'

paste

public void paste(int offset)
Pastes the contents of the system clipboard into this object's document, at the specified position. The only kind of text accepted from the clipboard is Wylie text. This Wylie is converted and pasted into the document as TibetanMachineWeb. If the text to paste is invalid Wylie, then it will not be pasted, and instead an error message will appear.

Parameters:
offset - the position in the document you want to paste to

enableCutAndPaste

public void enableCutAndPaste()
Enables cutting and pasting of Tibetan text.


isCutAndPasteOn

public boolean isCutAndPasteOn()
Returns true iff cut-and-paste operations are enabled.


disableCutAndPaste

public void disableCutAndPaste()
Disables cutting and pasting of Tibetan text. Cut and paste must be disabled if Jskad's parent is an applet, because it violates the Java security sandbox to cut and paste from an applet to the system clipboard.


keyPressed

public void keyPressed(KeyEvent e)
This method is required as part of the implementation of the KeyListener interface. Basically this method only handles action keys - Escape, Ctrl-c, Ctrl-x, etc, and TAB and ENTER. Other keystrokes are handled by keyTyped.

Specified by:
keyPressed in interface KeyListener

keyReleased

public void keyReleased(KeyEvent e)
Required of implementations of the Key Listener interface, this method does (almost) nothing.

Specified by:
keyReleased in interface KeyListener
Parameters:
e - the KeyEvent

keyTyped

public void keyTyped(KeyEvent e)
Required of implementations of the KeyListener interface, this method handles the pressing of non-control and non-action keys. If the user is in Tibetan typing mode, then the KeyEvent e is consumed, and passed on to processTibetan(KeyEvent e), which contains the meat of the keyboard logic. If the user is in English mode, then append is called.

Specified by:
keyTyped in interface KeyListener
Parameters:
e - a KeyEvent

processTibetan

public void processTibetan(KeyEvent kev)
Interprets a key typed during Tibetan input mode. This method keeps track of which characters the user has and is typing, and also of whether or not the user is in stacking mode. Most of the keyboard logic can be found here. If there is a nonnull status bar to be updated (passed to the constructor), let's explain to the user which mode we're in, why their keypress has changed nothing, etc. At present, this is really for developers to understand what's going on. For example, if you type s-g-r, you see a single glyph, a three-letter stack, but if you type s-d-r, you see two glyphs. If you examine the status bar, you'll see that the thing determining that is TibTextUtils.getGlyphs, which in turn relies on 'tibwn.ini'.


processTibetanChar

private void processTibetanChar(char c,
                                boolean shouldIBackSpace)
Utility method used by processTibetan(keyEvent).

Parameters:
c - the character the user entered in whatever keyboard is in use
shouldIBackSpace - false iff a press of the backspace key should not backspace, such as when you've selected some text and then pressed backspace
See Also:
processTibetan(KeyEvent)

toWylie

public void toWylie()
Converts the entire document to Extended Wylie.


toWylie

public void toWylie(int start,
                    int end)
Converts the specified portion of this object's document to Extended Wylie.

Parameters:
start - the point from which to begin converting to Wylie
end - the point at which to stop converting to Wylie

toTibetanMachineWeb

public void toTibetanMachineWeb(String wylie,
                                int offset)
Converts a string of Extended Wylie to TibetanMachineWeb, and inserts it at the specified position.

Parameters:
wylie - the string of Wylie to convert
offset - the position at which to insert the conversion

toTibetanMachineWeb

public void toTibetanMachineWeb()
Converts the currently selected text from Extended Wylie to TibetanMachineWeb.


toTibetanMachineWeb

public void toTibetanMachineWeb(int start,
                                int end)
Converts a stretch of text from Extended Wylie to TibetanMachineWeb.

Parameters:
start - the begin point for the conversion
end - the end point for the conversion

getWylie

public String getWylie()
Converts the entire associated document into Extended Wylie. If the document consists of both Tibetan and non-Tibetan fonts, however, the conversion stops at the first non-Tibetan font.

Returns:
the string of Wylie corresponding to the associated document
See Also:
TibetanDocument.getWylie()


These API docs were created 02/02/2003 08:20 PM.
Copyright © 2001-2002 Tibetan and Himalayan Digital Library. All Rights Reserved.
Hosted by SourceForge_Logo