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
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. |
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. |
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. |
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. |
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. |
void |
processTibetan(KeyEvent kev)
Interprets a key typed during Tibetan input mode. |
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. |
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. |
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 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 |
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)
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.
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.
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 inserts
- 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 textattr
- the attributes for the text to inserts
- 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 namesize
- 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
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.
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'.
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 Wylieend
- 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 convertoffset
- 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 conversionend
- 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:19 PM.
Copyright © 2001-2002 Tibetan and Himalayan Digital Library. All Rights Reserved.
Hosted by