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

public Class InputMethodHighlight

extends Object
Class Inheritance
Imports
java.awt.font.TextAttribute, java.util.Map

An InputMethodHighlight is used to describe the highlight attributes of text being composed. The description can be at two levels: at the abstract level it specifies the conversion state and whether the text is selected; at the concrete level it specifies style attributes used to render the highlight. An InputMethodHighlight must provide the description at the abstract level; it may or may not provide the description at the concrete level. If no concrete style is provided, a renderer should use java.awt.Toolkit#mapInputMethodHighlight to map to a concrete style.

The abstract description consists of three fields: selected, state, and variation. selected indicates whether the text range is the one that the input method is currently working on, for example, the segment for which conversion candidates are currently shown in a menu. state represents the conversion state. State values are defined by the input method framework and should be distinguished in all mappings from abstract to concrete styles. Currently defined state values are raw (unconverted) and converted. These state values are recommended for use before and after the main conversion step of text composition, say, before and after kana->kanji or pinyin->hanzi conversion. The variation field allows input methods to express additional information about the conversion results.

InputMethodHighlight instances are typically used as attribute values returned from AttributedCharacterIterator for the INPUT_METHOD_HIGHLIGHT attribute. They may be wrapped into Annotation instances to indicate separate text segments.

Since
1.2
See Also
java.text.AttributedCharacterIterator

Field Summary

Modifier and TypeField and Description
public static final int
CONVERTED_TEXT

Constant for the converted text state.

public static final int
RAW_TEXT

Constant for the raw text state.

private boolean
public static final InputMethodHighlight
SELECTED_CONVERTED_TEXT_HIGHLIGHT

Constant for the default highlight for selected converted text.

public static final InputMethodHighlight
SELECTED_RAW_TEXT_HIGHLIGHT

Constant for the default highlight for selected raw text.

private int
private Map<TextAttribute, ?>
public static final InputMethodHighlight
UNSELECTED_CONVERTED_TEXT_HIGHLIGHT

Constant for the default highlight for unselected converted text.

public static final InputMethodHighlight
UNSELECTED_RAW_TEXT_HIGHLIGHT

Constant for the default highlight for unselected raw text.

private int

Constructor Summary

AccessConstructor and Description
public
InputMethodHighlight(boolean
Whether the text range is selected
selected
,
int
The conversion state for the text range - RAW_TEXT or CONVERTED_TEXT
state
)

Constructs an input method highlight record.

public
InputMethodHighlight(boolean
Whether the text range is selected
selected
,
int
The conversion state for the text range - RAW_TEXT or CONVERTED_TEXT
state
,
int
The style variation for the text range
variation
)

Constructs an input method highlight record.

public
InputMethodHighlight(boolean
whether the text range is selected
selected
,
int
the conversion state for the text range - RAW_TEXT or CONVERTED_TEXT
state
,
int
the variation for the text range
variation
,
Map<TextAttribute, ?>
the rendering style attributes for the text range, or null
style
)

Constructs an input method highlight record.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

The conversion state for the text range - RAW_TEXT or CONVERTED_TEXT.
getState
()

Returns the conversion state of the text range.

public Map<TextAttribute, ?>

Returns:

the rendering style attributes for the text range, or null
getStyle
()

Returns the rendering style attributes for the text range, or null.

public int

Returns:

the variation of the text range
getVariation
()

Returns the variation of the text range.

public boolean

Returns:

whether the text range is selected
isSelected
()

Returns whether the text range is selected.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CONVERTED_TEXTback to summary
public static final int CONVERTED_TEXT

Constant for the converted text state.

RAW_TEXTback to summary
public static final int RAW_TEXT

Constant for the raw text state.

selectedback to summary
private boolean selected
SELECTED_CONVERTED_TEXT_HIGHLIGHTback to summary
public static final InputMethodHighlight SELECTED_CONVERTED_TEXT_HIGHLIGHT

Constant for the default highlight for selected converted text.

SELECTED_RAW_TEXT_HIGHLIGHTback to summary
public static final InputMethodHighlight SELECTED_RAW_TEXT_HIGHLIGHT

Constant for the default highlight for selected raw text.

stateback to summary
private int state
styleback to summary
private Map<TextAttribute, ?> style
UNSELECTED_CONVERTED_TEXT_HIGHLIGHTback to summary
public static final InputMethodHighlight UNSELECTED_CONVERTED_TEXT_HIGHLIGHT

Constant for the default highlight for unselected converted text.

UNSELECTED_RAW_TEXT_HIGHLIGHTback to summary
public static final InputMethodHighlight UNSELECTED_RAW_TEXT_HIGHLIGHT

Constant for the default highlight for unselected raw text.

variationback to summary
private int variation

Constructor Detail

InputMethodHighlightback to summary
public InputMethodHighlight(boolean selected, int state)

Constructs an input method highlight record. The variation is set to 0, the style to null.

Parameters
selected:boolean

Whether the text range is selected

state:int

The conversion state for the text range - RAW_TEXT or CONVERTED_TEXT

Exceptions
IllegalArgumentException:
if a state other than RAW_TEXT or CONVERTED_TEXT is given
See Also
InputMethodHighlight#RAW_TEXT, InputMethodHighlight#CONVERTED_TEXT
InputMethodHighlightback to summary
public InputMethodHighlight(boolean selected, int state, int variation)

Constructs an input method highlight record. The style is set to null.

Parameters
selected:boolean

Whether the text range is selected

state:int

The conversion state for the text range - RAW_TEXT or CONVERTED_TEXT

variation:int

The style variation for the text range

Exceptions
IllegalArgumentException:
if a state other than RAW_TEXT or CONVERTED_TEXT is given
See Also
InputMethodHighlight#RAW_TEXT, InputMethodHighlight#CONVERTED_TEXT
InputMethodHighlightback to summary
public InputMethodHighlight(boolean selected, int state, int variation, Map<TextAttribute, ?> style)

Constructs an input method highlight record. The style attributes map provided must be unmodifiable.

Parameters
selected:boolean

whether the text range is selected

state:int

the conversion state for the text range - RAW_TEXT or CONVERTED_TEXT

variation:int

the variation for the text range

style:Map<TextAttribute, ?>

the rendering style attributes for the text range, or null

Exceptions
IllegalArgumentException:
if a state other than RAW_TEXT or CONVERTED_TEXT is given
Since
1.3
See Also
InputMethodHighlight#RAW_TEXT, InputMethodHighlight#CONVERTED_TEXT

Method Detail

getStateback to summary
public int getState()

Returns the conversion state of the text range.

Returns:int

The conversion state for the text range - RAW_TEXT or CONVERTED_TEXT.

See Also
InputMethodHighlight#RAW_TEXT, InputMethodHighlight#CONVERTED_TEXT
getStyleback to summary
public Map<TextAttribute, ?> getStyle()

Returns the rendering style attributes for the text range, or null.

Returns:Map<TextAttribute, ?>

the rendering style attributes for the text range, or null

Since
1.3
getVariationback to summary
public int getVariation()

Returns the variation of the text range.

Returns:int

the variation of the text range

isSelectedback to summary
public boolean isSelected()

Returns whether the text range is selected.

Returns:boolean

whether the text range is selected