01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Dmitry A. Durnev
19: * @version $Revision$
20: */package java.awt.im;
21:
22: import java.util.Map;
23: import java.awt.font.TextAttribute;
24:
25: import org.apache.harmony.awt.internal.nls.Messages;
26:
27: public class InputMethodHighlight {
28:
29: public static final int RAW_TEXT = 0;
30:
31: public static final int CONVERTED_TEXT = 1;
32:
33: public static final InputMethodHighlight UNSELECTED_RAW_TEXT_HIGHLIGHT = new InputMethodHighlight(
34: false, RAW_TEXT);
35:
36: public static final InputMethodHighlight SELECTED_RAW_TEXT_HIGHLIGHT = new InputMethodHighlight(
37: true, RAW_TEXT);
38:
39: public static final InputMethodHighlight UNSELECTED_CONVERTED_TEXT_HIGHLIGHT = new InputMethodHighlight(
40: false, CONVERTED_TEXT);
41:
42: public static final InputMethodHighlight SELECTED_CONVERTED_TEXT_HIGHLIGHT = new InputMethodHighlight(
43: true, CONVERTED_TEXT);
44:
45: private boolean selected;
46: private int state;
47: private int variation;
48: private Map<TextAttribute, ?> style;
49:
50: public InputMethodHighlight(boolean selected, int state,
51: int variation) {
52: this (selected, state, variation, null);
53: }
54:
55: public InputMethodHighlight(boolean selected, int state,
56: int variation, Map<java.awt.font.TextAttribute, ?> style) {
57: if ((state != RAW_TEXT) && (state != CONVERTED_TEXT)) {
58: // awt.20B=unknown input method highlight state
59: throw new IllegalArgumentException(Messages
60: .getString("awt.20B")); //$NON-NLS-1$
61: }
62: this .selected = selected;
63: this .state = state;
64: this .variation = variation;
65: this .style = style;
66: }
67:
68: public InputMethodHighlight(boolean selected, int state) {
69: this (selected, state, 0, null);
70: }
71:
72: public int getState() {
73: return state;
74: }
75:
76: public Map<java.awt.font.TextAttribute, ?> getStyle() {
77: return style;
78: }
79:
80: public int getVariation() {
81: return variation;
82: }
83:
84: public boolean isSelected() {
85: return selected;
86: }
87: }
|