APIdia Launch Partner
Top Description Fields Constructors Methods
sun.awt.im

pack-priv Class CompositionAreaHandler

extends Object
implements InputMethodListener, InputMethodRequests
Class Inheritance
All Implemented Interfaces
java.awt.im.InputMethodRequests, java.awt.event.InputMethodListener, java.util.EventListener
Imports
java.awt.Component, .Container, .Rectangle, java.awt.event.InputMethodEvent, .InputMethodListener, java.awt.font.TextAttribute, .TextHitInfo, java.awt.im.InputMethodRequests, java.lang.ref.WeakReference, java.text.AttributedCharacterIterator, .AttributedCharacterIterator.Attribute, .AttributedString

A composition area handler handles events and input method requests for the composition area. Typically each input method context has its own composition area handler if it supports passive clients or below-the-spot input, but all handlers share a single composition area.
Author
JavaSoft International

Field Summary

Modifier and TypeField and Description
private TextHitInfo
private WeakReference<Component>
private AttributedCharacterIterator
private static CompositionArea
private static Object
private static CompositionAreaHandler
private static final AttributedCharacterIterator
private static final AttributedCharacterIterator.Attribute[]
private InputMethodContext

Constructor Summary

AccessConstructor and Description
pack-priv
CompositionAreaHandler(InputMethodContext context)

Constructs the composition area handler.

Method Summary

Modifier and TypeMethod and Description
public AttributedCharacterIterator
cancelLatestCommittedText(AttributedCharacterIterator.Attribute[] attributes)

Implements java.awt.im.InputMethodRequests.cancelLatestCommittedText.

Gets the latest committed text from the text editing component and removes it from the component's text body.

public void
caretPositionChanged(InputMethodEvent event)

Implements java.awt.event.InputMethodListener.caretPositionChanged.

Invoked when the caret within composed text has changed.

pack-priv static void
closeCompositionArea()

Releases and closes the composition area if it has been created, independent of the current owner.

private void
createCompositionArea()

Creates the composition area.

pack-priv InputMethodRequests
getClientInputMethodRequests()

Returns the input method request handler of the client component.

public AttributedCharacterIterator
getCommittedText(int beginIndex, int endIndex, AttributedCharacterIterator.Attribute[] attributes)

Implements java.awt.im.InputMethodRequests.getCommittedText.

Gets an iterator providing access to the entire text and attributes contained in the text editing component except for uncommitted text.

public int
getCommittedTextLength()

Implements java.awt.im.InputMethodRequests.getCommittedTextLength.

Gets the length of the entire text contained in the text editing component except for uncommitted (composed) text.

public int
getInsertPositionOffset()

Implements java.awt.im.InputMethodRequests.getInsertPositionOffset.

Gets the offset of the insert position in the committed text contained in the text editing component.

public TextHitInfo
getLocationOffset(int x, int y)

Implements java.awt.im.InputMethodRequests.getLocationOffset.

Gets the offset within the composed text for the specified absolute x and y coordinates on the screen.

public AttributedCharacterIterator
getSelectedText(AttributedCharacterIterator.Attribute[] attributes)

Implements java.awt.im.InputMethodRequests.getSelectedText.

Gets the currently selected text from the text editing component.

public Rectangle
getTextLocation(TextHitInfo offset)

Implements java.awt.im.InputMethodRequests.getTextLocation.

Gets the location of a specified offset in the current composed text, or of the selection in committed text.

pack-priv void
grabCompositionArea(boolean doUpdate)

Grabs the composition area, makes this handler its owner, and installs the handler and its input context into the composition area for event and input method request handling.

public void
inputMethodTextChanged(InputMethodEvent event)

Implements java.awt.event.InputMethodListener.inputMethodTextChanged.

Invoked when the text entered through an input method has changed.

pack-priv boolean
isCompositionAreaVisible()

Returns whether the composition area is currently visible

pack-priv void
pack-priv void
releaseCompositionArea()

Releases and closes the composition area if it is currently owned by this composition area handler.

pack-priv void
setClientComponent(Component clientComponent)

pack-priv void
setCompositionAreaUndecorated(boolean undecorated)

set the compositionArea frame decoration

pack-priv void
setCompositionAreaVisible(boolean visible)

Shows or hides the composition Area

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

caretback to summary
private TextHitInfo caret
clientComponentback to summary
private WeakReference<Component> clientComponent
composedTextback to summary
private AttributedCharacterIterator composedText
compositionAreaback to summary
private static CompositionArea compositionArea
compositionAreaLockback to summary
private static Object compositionAreaLock
compositionAreaOwnerback to summary
private static CompositionAreaHandler compositionAreaOwner
EMPTY_TEXTback to summary
private static final AttributedCharacterIterator EMPTY_TEXT
IM_ATTRIBUTESback to summary
private static final AttributedCharacterIterator.Attribute[] IM_ATTRIBUTES
inputMethodContextback to summary
private InputMethodContext inputMethodContext

Constructor Detail

CompositionAreaHandlerback to summary
pack-priv CompositionAreaHandler(InputMethodContext context)

Constructs the composition area handler.

Method Detail

cancelLatestCommittedTextback to summary
public AttributedCharacterIterator cancelLatestCommittedText(AttributedCharacterIterator.Attribute[] attributes)

Implements java.awt.im.InputMethodRequests.cancelLatestCommittedText.

Doc from java.awt.im.InputMethodRequests.cancelLatestCommittedText.

Gets the latest committed text from the text editing component and removes it from the component's text body. This is used for the "Undo Commit" feature in some input methods, where the committed text reverts to its previous composed state. The composed text will be sent to the component using an InputMethodEvent.

Generally, this feature should only be supported immediately after the text was committed, not after the user performed other operations on the text. When the feature is not supported, return null.

The input method may provide a list of attributes that it is interested in. In that case, information about other attributes that the implementor may have need not be made accessible through the iterator. If the list is null, all available attribute information should be made accessible.

caretPositionChangedback to summary
public void caretPositionChanged(InputMethodEvent event)

Implements java.awt.event.InputMethodListener.caretPositionChanged.

Doc from java.awt.event.InputMethodListener.caretPositionChanged.

Invoked when the caret within composed text has changed.

closeCompositionAreaback to summary
pack-priv static void closeCompositionArea()

Releases and closes the composition area if it has been created, independent of the current owner.

createCompositionAreaback to summary
private void createCompositionArea()

Creates the composition area.

getClientInputMethodRequestsback to summary
pack-priv InputMethodRequests getClientInputMethodRequests()

Returns the input method request handler of the client component. When using the composition window for an active client (below-the-spot input), input method requests that do not relate to the display of the composed text are forwarded to the client component.

getCommittedTextback to summary
public AttributedCharacterIterator getCommittedText(int beginIndex, int endIndex, AttributedCharacterIterator.Attribute[] attributes)

Implements java.awt.im.InputMethodRequests.getCommittedText.

Doc from java.awt.im.InputMethodRequests.getCommittedText.

Gets an iterator providing access to the entire text and attributes contained in the text editing component except for uncommitted text. Uncommitted (composed) text should be ignored for index calculations and should not be made accessible through the iterator.

The input method may provide a list of attributes that it is interested in. In that case, information about other attributes that the implementor may have need not be made accessible through the iterator. If the list is null, all available attribute information should be made accessible.

getCommittedTextLengthback to summary
public int getCommittedTextLength()

Implements java.awt.im.InputMethodRequests.getCommittedTextLength.

Doc from java.awt.im.InputMethodRequests.getCommittedTextLength.

Gets the length of the entire text contained in the text editing component except for uncommitted (composed) text.

getInsertPositionOffsetback to summary
public int getInsertPositionOffset()

Implements java.awt.im.InputMethodRequests.getInsertPositionOffset.

Doc from java.awt.im.InputMethodRequests.getInsertPositionOffset.

Gets the offset of the insert position in the committed text contained in the text editing component. This is the offset at which characters entered through an input method are inserted. This information is used by an input method, for example, to examine the text surrounding the insert position.

getLocationOffsetback to summary
public TextHitInfo getLocationOffset(int x, int y)

Implements java.awt.im.InputMethodRequests.getLocationOffset.

Doc from java.awt.im.InputMethodRequests.getLocationOffset.

Gets the offset within the composed text for the specified absolute x and y coordinates on the screen. This information is used, for example to handle mouse clicks and the mouse cursor. The offset is relative to the composed text, so offset 0 indicates the beginning of the composed text.

Return null if the location is outside the area occupied by the composed text.

getSelectedTextback to summary
public AttributedCharacterIterator getSelectedText(AttributedCharacterIterator.Attribute[] attributes)

Implements java.awt.im.InputMethodRequests.getSelectedText.

Doc from java.awt.im.InputMethodRequests.getSelectedText.

Gets the currently selected text from the text editing component. This may be used for a variety of purposes. One of them is the "Reconvert" feature in some input methods. In this case, the input method will typically send an input method event to replace the selected text with composed text. Depending on the input method's capabilities, this may be the original composed text for the selected text, the latest composed text entered anywhere in the text, or a version of the text that's converted back from the selected text.

The input method may provide a list of attributes that it is interested in. In that case, information about other attributes that the implementor may have need not be made accessible through the iterator. If the list is null, all available attribute information should be made accessible.

getTextLocationback to summary
public Rectangle getTextLocation(TextHitInfo offset)

Implements java.awt.im.InputMethodRequests.getTextLocation.

Doc from java.awt.im.InputMethodRequests.getTextLocation.

Gets the location of a specified offset in the current composed text, or of the selection in committed text. This information is, for example, used to position the candidate window near the composed text, or a composition window near the location where committed text will be inserted.

If the component has composed text (because the most recent InputMethodEvent sent to it contained composed text), then the offset is relative to the composed text - offset 0 indicates the first character in the composed text. The location returned should be for this character.

If the component doesn't have composed text, the offset should be ignored, and the location returned should reflect the beginning (in line direction) of the highlight in the last line containing selected text. For example, for horizontal left-to-right text (such as English), the location to the left of the left-most character on the last line containing selected text is returned. For vertical top-to-bottom text, with lines proceeding from right to left, the location to the top of the left-most line containing selected text is returned.

The location is represented as a 0-thickness caret, that is, it has 0 width if the text is drawn horizontally, and 0 height if the text is drawn vertically. Other text orientations need to be mapped to horizontal or vertical orientation. The rectangle uses absolute screen coordinates.

grabCompositionAreaback to summary
pack-priv void grabCompositionArea(boolean doUpdate)

Grabs the composition area, makes this handler its owner, and installs the handler and its input context into the composition area for event and input method request handling. If doUpdate is true, updates the composition area with previously sent composed text.

inputMethodTextChangedback to summary
public void inputMethodTextChanged(InputMethodEvent event)

Implements java.awt.event.InputMethodListener.inputMethodTextChanged.

Doc from java.awt.event.InputMethodListener.inputMethodTextChanged.

Invoked when the text entered through an input method has changed.

isCompositionAreaVisibleback to summary
pack-priv boolean isCompositionAreaVisible()

Returns whether the composition area is currently visible

processInputMethodEventback to summary
pack-priv void processInputMethodEvent(InputMethodEvent event)
releaseCompositionAreaback to summary
pack-priv void releaseCompositionArea()

Releases and closes the composition area if it is currently owned by this composition area handler.

setClientComponentback to summary
pack-priv void setClientComponent(Component clientComponent)
setCompositionAreaUndecoratedback to summary
pack-priv void setCompositionAreaUndecorated(boolean undecorated)

set the compositionArea frame decoration

setCompositionAreaVisibleback to summary
pack-priv void setCompositionAreaVisible(boolean visible)

Shows or hides the composition Area