54 * main conversion step of text composition, say, before and after kana->kanji 55 * or pinyin->hanzi conversion. 56 * The <code>variation</code> field allows input methods to express additional 57 * information about the conversion results. 58 * <p> 59 * 60 * InputMethodHighlight instances are typically used as attribute values 61 * returned from AttributedCharacterIterator for the INPUT_METHOD_HIGHLIGHT 62 * attribute. They may be wrapped into {@link java.text.Annotation Annotation} 63 * instances to indicate separate text segments. 64 * 65 * @see java.text.AttributedCharacterIterator 66 * @since 1.2 67 */ 68 69 public class InputMethodHighlight { 70 71 /** 72 * Constant for the raw text state. 73 */ 74 public final static int RAW_TEXT = 0; 75 76 /** 77 * Constant for the converted text state. 78 */ 79 public final static int CONVERTED_TEXT = 1; 80 81 82 /** 83 * Constant for the default highlight for unselected raw text. 84 */ 85 public final static InputMethodHighlight UNSELECTED_RAW_TEXT_HIGHLIGHT = 86 new InputMethodHighlight(false, RAW_TEXT); 87 88 /** 89 * Constant for the default highlight for selected raw text. 90 */ 91 public final static InputMethodHighlight SELECTED_RAW_TEXT_HIGHLIGHT = 92 new InputMethodHighlight(true, RAW_TEXT); 93 94 /** 95 * Constant for the default highlight for unselected converted text. 96 */ 97 public final static InputMethodHighlight UNSELECTED_CONVERTED_TEXT_HIGHLIGHT = 98 new InputMethodHighlight(false, CONVERTED_TEXT); 99 100 /** 101 * Constant for the default highlight for selected converted text. 102 */ 103 public final static InputMethodHighlight SELECTED_CONVERTED_TEXT_HIGHLIGHT = 104 new InputMethodHighlight(true, CONVERTED_TEXT); 105 106 107 /** 108 * Constructs an input method highlight record. 109 * The variation is set to 0, the style to null. 110 * @param selected Whether the text range is selected 111 * @param state The conversion state for the text range - RAW_TEXT or CONVERTED_TEXT 112 * @see InputMethodHighlight#RAW_TEXT 113 * @see InputMethodHighlight#CONVERTED_TEXT 114 * @exception IllegalArgumentException if a state other than RAW_TEXT or CONVERTED_TEXT is given 115 */ 116 public InputMethodHighlight(boolean selected, int state) { 117 this(selected, state, 0, null); 118 } 119 120 /** 121 * Constructs an input method highlight record. 122 * The style is set to null. 123 * @param selected Whether the text range is selected | 54 * main conversion step of text composition, say, before and after kana->kanji 55 * or pinyin->hanzi conversion. 56 * The <code>variation</code> field allows input methods to express additional 57 * information about the conversion results. 58 * <p> 59 * 60 * InputMethodHighlight instances are typically used as attribute values 61 * returned from AttributedCharacterIterator for the INPUT_METHOD_HIGHLIGHT 62 * attribute. They may be wrapped into {@link java.text.Annotation Annotation} 63 * instances to indicate separate text segments. 64 * 65 * @see java.text.AttributedCharacterIterator 66 * @since 1.2 67 */ 68 69 public class InputMethodHighlight { 70 71 /** 72 * Constant for the raw text state. 73 */ 74 public static final int RAW_TEXT = 0; 75 76 /** 77 * Constant for the converted text state. 78 */ 79 public static final int CONVERTED_TEXT = 1; 80 81 82 /** 83 * Constant for the default highlight for unselected raw text. 84 */ 85 public static final InputMethodHighlight UNSELECTED_RAW_TEXT_HIGHLIGHT = 86 new InputMethodHighlight(false, RAW_TEXT); 87 88 /** 89 * Constant for the default highlight for selected raw text. 90 */ 91 public static final InputMethodHighlight SELECTED_RAW_TEXT_HIGHLIGHT = 92 new InputMethodHighlight(true, RAW_TEXT); 93 94 /** 95 * Constant for the default highlight for unselected converted text. 96 */ 97 public static final InputMethodHighlight UNSELECTED_CONVERTED_TEXT_HIGHLIGHT = 98 new InputMethodHighlight(false, CONVERTED_TEXT); 99 100 /** 101 * Constant for the default highlight for selected converted text. 102 */ 103 public static final InputMethodHighlight SELECTED_CONVERTED_TEXT_HIGHLIGHT = 104 new InputMethodHighlight(true, CONVERTED_TEXT); 105 106 107 /** 108 * Constructs an input method highlight record. 109 * The variation is set to 0, the style to null. 110 * @param selected Whether the text range is selected 111 * @param state The conversion state for the text range - RAW_TEXT or CONVERTED_TEXT 112 * @see InputMethodHighlight#RAW_TEXT 113 * @see InputMethodHighlight#CONVERTED_TEXT 114 * @exception IllegalArgumentException if a state other than RAW_TEXT or CONVERTED_TEXT is given 115 */ 116 public InputMethodHighlight(boolean selected, int state) { 117 this(selected, state, 0, null); 118 } 119 120 /** 121 * Constructs an input method highlight record. 122 * The style is set to null. 123 * @param selected Whether the text range is selected |