Showing the changes to java/pkg/java/awt/im (18 of 18352 files). Show all
Unified · Split
Binary file not shown.
| @@ -0,0 +1,339 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package java.awt.im; | |
| 27 | + | |
| 28 | +import java.awt.Component; | |
| 29 | +import java.util.Locale; | |
| 30 | +import java.awt.AWTEvent; | |
| 31 | +import java.beans.Transient; | |
| 32 | +import java.lang.Character.Subset; | |
| 33 | +import sun.awt.im.InputMethodContext; | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * Provides methods to control text input facilities such as input | |
| 37 | + * methods and keyboard layouts. | |
| 38 | + * Two methods handle both input methods and keyboard layouts: selectInputMethod | |
| 39 | + * lets a client component select an input method or keyboard layout by locale, | |
| 40 | + * getLocale lets a client component obtain the locale of the current input method | |
| 41 | + * or keyboard layout. | |
| 42 | + * The other methods more specifically support interaction with input methods: | |
| 43 | + * They let client components control the behavior of input methods, and | |
| 44 | + * dispatch events from the client component to the input method. | |
| 45 | + * | |
| 46 | + * <p> | |
| 47 | + * By default, one InputContext instance is created per Window instance, | |
| 48 | + * and this input context is shared by all components within the window's | |
| 49 | + * container hierarchy. However, this means that only one text input | |
| 50 | + * operation is possible at any one time within a window, and that the | |
| 51 | + * text needs to be committed when moving the focus from one text component | |
| 52 | + * to another. If this is not desired, text components can create their | |
| 53 | + * own input context instances. | |
| 54 | + * | |
| 55 | + * <p> | |
| 56 | + * The Java Platform supports input methods that have been developed in the Java | |
| 57 | + * programming language, using the interfaces in the {@link java.awt.im.spi} package, | |
| 58 | + * and installed into a Java SE Runtime Environment as extensions. Implementations | |
| 59 | + * may also support using the native input methods of the platforms they run on; | |
| 60 | + * however, not all platforms and locales provide input methods. Keyboard layouts | |
| 61 | + * are provided by the host platform. | |
| 62 | + * | |
| 63 | + * <p> | |
| 64 | + * Input methods are <em>unavailable</em> if (a) no input method written | |
| 65 | + * in the Java programming language has been installed and (b) the Java Platform implementation | |
| 66 | + * or the underlying platform does not support native input methods. In this case, | |
| 67 | + * input contexts can still be created and used; their behavior is specified with | |
| 68 | + * the individual methods below. | |
| 69 | + * | |
| 70 | + * @see java.awt.Component#getInputContext | |
| 71 | + * @see java.awt.Component#enableInputMethods | |
| 72 | + * @author JavaSoft Asia/Pacific | |
| 73 | + * @since 1.2 | |
| 74 | + */ | |
| 75 | + | |
| 76 | +public class InputContext { | |
| 77 | + | |
| 78 | + /** | |
| 79 | + * Constructs an InputContext. | |
| 80 | + * This method is protected so clients cannot instantiate | |
| 81 | + * InputContext directly. Input contexts are obtained by | |
| 82 | + * calling {@link #getInstance}. | |
| 83 | + */ | |
| 84 | + protected InputContext() { | |
| 85 | + // real implementation is in sun.awt.im.InputContext | |
| 86 | + } | |
| 87 | + | |
| 88 | + /** | |
| 89 | + * Returns a new InputContext instance. | |
| 90 | + */ | |
| 91 | + public static InputContext getInstance() { | |
| 92 | + return new sun.awt.im.InputMethodContext(); | |
| 93 | + } | |
| 94 | + | |
| 95 | + /** | |
| 96 | + * Attempts to select an input method or keyboard layout that | |
| 97 | + * supports the given locale, and returns a value indicating whether such | |
| 98 | + * an input method or keyboard layout has been successfully selected. The | |
| 99 | + * following steps are taken until an input method has been selected: | |
| 100 | + * | |
| 101 | + * <p> | |
| 102 | + * <ul> | |
| 103 | + * <li> | |
| 104 | + * If the currently selected input method or keyboard layout supports the | |
| 105 | + * requested locale, it remains selected.</li> | |
| 106 | + * | |
| 107 | + * <li> | |
| 108 | + * If there is no input method or keyboard layout available that supports | |
| 109 | + * the requested locale, the current input method or keyboard layout remains | |
| 110 | + * selected.</li> | |
| 111 | + * | |
| 112 | + * <li> | |
| 113 | + * If the user has previously selected an input method or keyboard layout | |
| 114 | + * for the requested locale from the user interface, then the most recently | |
| 115 | + * selected such input method or keyboard layout is reselected.</li> | |
| 116 | + * | |
| 117 | + * <li> | |
| 118 | + * Otherwise, an input method or keyboard layout that supports the requested | |
| 119 | + * locale is selected in an implementation dependent way.</li> | |
| 120 | + * | |
| 121 | + * <p> | |
| 122 | + * </ul> | |
| 123 | + * Before switching away from an input method, any currently uncommitted text | |
| 124 | + * is committed. If no input method or keyboard layout supporting the requested | |
| 125 | + * locale is available, then false is returned. | |
| 126 | + * | |
| 127 | + * <p> | |
| 128 | + * Not all host operating systems provide API to determine the locale of | |
| 129 | + * the currently selected native input method or keyboard layout, and to | |
| 130 | + * select a native input method or keyboard layout by locale. | |
| 131 | + * For host operating systems that don't provide such API, | |
| 132 | + * <code>selectInputMethod</code> assumes that native input methods or | |
| 133 | + * keyboard layouts provided by the host operating system support only the | |
| 134 | + * system's default locale. | |
| 135 | + * | |
| 136 | + * <p> | |
| 137 | + * A text editing component may call this method, for example, when | |
| 138 | + * the user changes the insertion point, so that the user can | |
| 139 | + * immediately continue typing in the language of the surrounding text. | |
| 140 | + * | |
| 141 | + * @param locale The desired new locale. | |
| 142 | + * @return true if the input method or keyboard layout that's active after | |
| 143 | + * this call supports the desired locale. | |
| 144 | + * @exception NullPointerException if <code>locale</code> is null | |
| 145 | + */ | |
| 146 | + public boolean selectInputMethod(Locale locale) { | |
| 147 | + // real implementation is in sun.awt.im.InputContext | |
| 148 | + return false; | |
| 149 | + } | |
| 150 | + | |
| 151 | + /** | |
| 152 | + * Returns the current locale of the current input method or keyboard | |
| 153 | + * layout. | |
| 154 | + * Returns null if the input context does not have a current input method | |
| 155 | + * or keyboard layout or if the current input method's | |
| 156 | + * {@link java.awt.im.spi.InputMethod#getLocale()} method returns null. | |
| 157 | + * | |
| 158 | + * <p> | |
| 159 | + * Not all host operating systems provide API to determine the locale of | |
| 160 | + * the currently selected native input method or keyboard layout. | |
| 161 | + * For host operating systems that don't provide such API, | |
| 162 | + * <code>getLocale</code> assumes that the current locale of all native | |
| 163 | + * input methods or keyboard layouts provided by the host operating system | |
| 164 | + * is the system's default locale. | |
| 165 | + * | |
| 166 | + * @return the current locale of the current input method or keyboard layout | |
| 167 | + * @since 1.3 | |
| 168 | + */ | |
| 169 | + public Locale getLocale() { | |
| 170 | + // real implementation is in sun.awt.im.InputContext | |
| 171 | + return null; | |
| 172 | + } | |
| 173 | + | |
| 174 | + /** | |
| 175 | + * Sets the subsets of the Unicode character set that input methods of this input | |
| 176 | + * context should be allowed to input. Null may be passed in to | |
| 177 | + * indicate that all characters are allowed. The initial value | |
| 178 | + * is null. The setting applies to the current input method as well | |
| 179 | + * as input methods selected after this call is made. However, | |
| 180 | + * applications cannot rely on this call having the desired effect, | |
| 181 | + * since this setting cannot be passed on to all host input methods - | |
| 182 | + * applications still need to apply their own character validation. | |
| 183 | + * If no input methods are available, then this method has no effect. | |
| 184 | + * | |
| 185 | + * @param subsets The subsets of the Unicode character set from which characters may be input | |
| 186 | + */ | |
| 187 | + public void setCharacterSubsets(Subset[] subsets) { | |
| 188 | + // real implementation is in sun.awt.im.InputContext | |
| 189 | + } | |
| 190 | + | |
| 191 | + /** | |
| 192 | + * Enables or disables the current input method for composition, | |
| 193 | + * depending on the value of the parameter <code>enable</code>. | |
| 194 | + * <p> | |
| 195 | + * An input method that is enabled for composition interprets incoming | |
| 196 | + * events for both composition and control purposes, while a | |
| 197 | + * disabled input method does not interpret events for composition. | |
| 198 | + * Note however that events are passed on to the input method regardless | |
| 199 | + * whether it is enabled or not, and that an input method that is disabled | |
| 200 | + * for composition may still interpret events for control purposes, | |
| 201 | + * including to enable or disable itself for composition. | |
| 202 | + * <p> | |
| 203 | + * For input methods provided by host operating systems, it is not always possible to | |
| 204 | + * determine whether this operation is supported. For example, an input method may enable | |
| 205 | + * composition only for some locales, and do nothing for other locales. For such input | |
| 206 | + * methods, it is possible that this method does not throw | |
| 207 | + * {@link java.lang.UnsupportedOperationException UnsupportedOperationException}, | |
| 208 | + * but also does not affect whether composition is enabled. | |
| 209 | + * | |
| 210 | + * @param enable whether to enable the current input method for composition | |
| 211 | + * @throws UnsupportedOperationException if there is no current input | |
| 212 | + * method available or the current input method does not support | |
| 213 | + * the enabling/disabling operation | |
| 214 | + * @see #isCompositionEnabled | |
| 215 | + * @since 1.3 | |
| 216 | + */ | |
| 217 | + public void setCompositionEnabled(boolean enable) { | |
| 218 | + // real implementation is in sun.awt.im.InputContext | |
| 219 | + } | |
| 220 | + | |
| 221 | + /** | |
| 222 | + * Determines whether the current input method is enabled for composition. | |
| 223 | + * An input method that is enabled for composition interprets incoming | |
| 224 | + * events for both composition and control purposes, while a | |
| 225 | + * disabled input method does not interpret events for composition. | |
| 226 | + * | |
| 227 | + * @return <code>true</code> if the current input method is enabled for | |
| 228 | + * composition; <code>false</code> otherwise | |
| 229 | + * @throws UnsupportedOperationException if there is no current input | |
| 230 | + * method available or the current input method does not support | |
| 231 | + * checking whether it is enabled for composition | |
| 232 | + * @see #setCompositionEnabled | |
| 233 | + * @since 1.3 | |
| 234 | + */ | |
| 235 | + @Transient | |
| 236 | + public boolean isCompositionEnabled() { | |
| 237 | + // real implementation is in sun.awt.im.InputContext | |
| 238 | + return false; | |
| 239 | + } | |
| 240 | + | |
| 241 | + /** | |
| 242 | + * Asks the current input method to reconvert text from the | |
| 243 | + * current client component. The input method obtains the text to | |
| 244 | + * be reconverted from the client component using the | |
| 245 | + * {@link InputMethodRequests#getSelectedText InputMethodRequests.getSelectedText} | |
| 246 | + * method. The other <code>InputMethodRequests</code> methods | |
| 247 | + * must be prepared to deal with further information requests by | |
| 248 | + * the input method. The composed and/or committed text will be | |
| 249 | + * sent to the client component as a sequence of | |
| 250 | + * <code>InputMethodEvent</code>s. If the input method cannot | |
| 251 | + * reconvert the given text, the text is returned as committed | |
| 252 | + * text in an <code>InputMethodEvent</code>. | |
| 253 | + * | |
| 254 | + * @throws UnsupportedOperationException if there is no current input | |
| 255 | + * method available or the current input method does not support | |
| 256 | + * the reconversion operation. | |
| 257 | + * | |
| 258 | + * @since 1.3 | |
| 259 | + */ | |
| 260 | + public void reconvert() { | |
| 261 | + // real implementation is in sun.awt.im.InputContext | |
| 262 | + } | |
| 263 | + | |
| 264 | + /** | |
| 265 | + * Dispatches an event to the active input method. Called by AWT. | |
| 266 | + * If no input method is available, then the event will never be consumed. | |
| 267 | + * | |
| 268 | + * @param event The event | |
| 269 | + * @exception NullPointerException if <code>event</code> is null | |
| 270 | + */ | |
| 271 | + public void dispatchEvent(AWTEvent event) { | |
| 272 | + // real implementation is in sun.awt.im.InputContext | |
| 273 | + } | |
| 274 | + | |
| 275 | + /** | |
| 276 | + * Notifies the input context that a client component has been | |
| 277 | + * removed from its containment hierarchy, or that input method | |
| 278 | + * support has been disabled for the component. This method is | |
| 279 | + * usually called from the client component's | |
| 280 | + * {@link java.awt.Component#removeNotify() Component.removeNotify} | |
| 281 | + * method. Potentially pending input from input methods | |
| 282 | + * for this component is discarded. | |
| 283 | + * If no input methods are available, then this method has no effect. | |
| 284 | + * | |
| 285 | + * @param client Client component | |
| 286 | + * @exception NullPointerException if <code>client</code> is null | |
| 287 | + */ | |
| 288 | + public void removeNotify(Component client) { | |
| 289 | + // real implementation is in sun.awt.im.InputContext | |
| 290 | + } | |
| 291 | + | |
| 292 | + /** | |
| 293 | + * Ends any input composition that may currently be going on in this | |
| 294 | + * context. Depending on the platform and possibly user preferences, | |
| 295 | + * this may commit or delete uncommitted text. Any changes to the text | |
| 296 | + * are communicated to the active component using an input method event. | |
| 297 | + * If no input methods are available, then this method has no effect. | |
| 298 | + * | |
| 299 | + * <p> | |
| 300 | + * A text editing component may call this in a variety of situations, | |
| 301 | + * for example, when the user moves the insertion point within the text | |
| 302 | + * (but outside the composed text), or when the component's text is | |
| 303 | + * saved to a file or copied to the clipboard. | |
| 304 | + * | |
| 305 | + */ | |
| 306 | + public void endComposition() { | |
| 307 | + // real implementation is in sun.awt.im.InputContext | |
| 308 | + } | |
| 309 | + | |
| 310 | + /** | |
| 311 | + * Releases the resources used by this input context. | |
| 312 | + * Called by AWT for the default input context of each Window. | |
| 313 | + * If no input methods are available, then this method | |
| 314 | + * has no effect. | |
| 315 | + */ | |
| 316 | + public void dispose() { | |
| 317 | + // real implementation is in sun.awt.im.InputContext | |
| 318 | + } | |
| 319 | + | |
| 320 | + /** | |
| 321 | + * Returns a control object from the current input method, or null. A | |
| 322 | + * control object provides methods that control the behavior of the | |
| 323 | + * input method or obtain information from the input method. The type | |
| 324 | + * of the object is an input method specific class. Clients have to | |
| 325 | + * compare the result against known input method control object | |
| 326 | + * classes and cast to the appropriate class to invoke the methods | |
| 327 | + * provided. | |
| 328 | + * <p> | |
| 329 | + * If no input methods are available or the current input method does | |
| 330 | + * not provide an input method control object, then null is returned. | |
| 331 | + * | |
| 332 | + * @return A control object from the current input method, or null. | |
| 333 | + */ | |
| 334 | + public Object getInputMethodControlObject() { | |
| 335 | + // real implementation is in sun.awt.im.InputContext | |
| 336 | + return null; | |
| 337 | + } | |
| 338 | + | |
| 339 | +} | |
Binary file not shown.
| @@ -0,0 +1,195 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package java.awt.im; | |
| 27 | + | |
| 28 | +import java.awt.font.TextAttribute; | |
| 29 | +import java.util.Map; | |
| 30 | + | |
| 31 | +/** | |
| 32 | +* An InputMethodHighlight is used to describe the highlight | |
| 33 | +* attributes of text being composed. | |
| 34 | +* The description can be at two levels: | |
| 35 | +* at the abstract level it specifies the conversion state and whether the | |
| 36 | +* text is selected; at the concrete level it specifies style attributes used | |
| 37 | +* to render the highlight. | |
| 38 | +* An InputMethodHighlight must provide the description at the | |
| 39 | +* abstract level; it may or may not provide the description at the concrete | |
| 40 | +* level. | |
| 41 | +* If no concrete style is provided, a renderer should use | |
| 42 | +* {@link java.awt.Toolkit#mapInputMethodHighlight} to map to a concrete style. | |
| 43 | +* <p> | |
| 44 | +* The abstract description consists of three fields: <code>selected</code>, | |
| 45 | +* <code>state</code>, and <code>variation</code>. | |
| 46 | +* <code>selected</code> indicates whether the text range is the one that the | |
| 47 | +* input method is currently working on, for example, the segment for which | |
| 48 | +* conversion candidates are currently shown in a menu. | |
| 49 | +* <code>state</code> represents the conversion state. State values are defined | |
| 50 | +* by the input method framework and should be distinguished in all | |
| 51 | +* mappings from abstract to concrete styles. Currently defined state values | |
| 52 | +* are raw (unconverted) and converted. | |
| 53 | +* These state values are recommended for use before and after the | |
| 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 | |
| 124 | + * @param state The conversion state for the text range - RAW_TEXT or CONVERTED_TEXT | |
| 125 | + * @param variation The style variation for the text range | |
| 126 | + * @see InputMethodHighlight#RAW_TEXT | |
| 127 | + * @see InputMethodHighlight#CONVERTED_TEXT | |
| 128 | + * @exception IllegalArgumentException if a state other than RAW_TEXT or CONVERTED_TEXT is given | |
| 129 | + */ | |
| 130 | + public InputMethodHighlight(boolean selected, int state, int variation) { | |
| 131 | + this(selected, state, variation, null); | |
| 132 | + } | |
| 133 | + | |
| 134 | + /** | |
| 135 | + * Constructs an input method highlight record. | |
| 136 | + * The style attributes map provided must be unmodifiable. | |
| 137 | + * @param selected whether the text range is selected | |
| 138 | + * @param state the conversion state for the text range - RAW_TEXT or CONVERTED_TEXT | |
| 139 | + * @param variation the variation for the text range | |
| 140 | + * @param style the rendering style attributes for the text range, or null | |
| 141 | + * @see InputMethodHighlight#RAW_TEXT | |
| 142 | + * @see InputMethodHighlight#CONVERTED_TEXT | |
| 143 | + * @exception IllegalArgumentException if a state other than RAW_TEXT or CONVERTED_TEXT is given | |
| 144 | + * @since 1.3 | |
| 145 | + */ | |
| 146 | + public InputMethodHighlight(boolean selected, int state, int variation, | |
| 147 | + Map<TextAttribute,?> style) | |
| 148 | + { | |
| 149 | + this.selected = selected; | |
| 150 | + if (!(state == RAW_TEXT || state == CONVERTED_TEXT)) { | |
| 151 | + throw new IllegalArgumentException("unknown input method highlight state"); | |
| 152 | + } | |
| 153 | + this.state = state; | |
| 154 | + this.variation = variation; | |
| 155 | + this.style = style; | |
| 156 | + } | |
| 157 | + | |
| 158 | + /** | |
| 159 | + * Returns whether the text range is selected. | |
| 160 | + */ | |
| 161 | + public boolean isSelected() { | |
| 162 | + return selected; | |
| 163 | + } | |
| 164 | + | |
| 165 | + /** | |
| 166 | + * Returns the conversion state of the text range. | |
| 167 | + * @return The conversion state for the text range - RAW_TEXT or CONVERTED_TEXT. | |
| 168 | + * @see InputMethodHighlight#RAW_TEXT | |
| 169 | + * @see InputMethodHighlight#CONVERTED_TEXT | |
| 170 | + */ | |
| 171 | + public int getState() { | |
| 172 | + return state; | |
| 173 | + } | |
| 174 | + | |
| 175 | + /** | |
| 176 | + * Returns the variation of the text range. | |
| 177 | + */ | |
| 178 | + public int getVariation() { | |
| 179 | + return variation; | |
| 180 | + } | |
| 181 | + | |
| 182 | + /** | |
| 183 | + * Returns the rendering style attributes for the text range, or null. | |
| 184 | + * @since 1.3 | |
| 185 | + */ | |
| 186 | + public Map<TextAttribute,?> getStyle() { | |
| 187 | + return style; | |
| 188 | + } | |
| 189 | + | |
| 190 | + private boolean selected; | |
| 191 | + private int state; | |
| 192 | + private int variation; | |
| 193 | + private Map style; | |
| 194 | + | |
| 195 | +}; | |
Binary file not shown.
| @@ -0,0 +1,208 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package java.awt.im; | |
| 27 | + | |
| 28 | +import java.awt.Rectangle; | |
| 29 | +import java.awt.font.TextHitInfo; | |
| 30 | +import java.text.AttributedCharacterIterator; | |
| 31 | +import java.text.AttributedCharacterIterator.Attribute; | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * InputMethodRequests defines the requests that a text editing component | |
| 35 | + * has to handle in order to work with input methods. The component | |
| 36 | + * can implement this interface itself or use a separate object that | |
| 37 | + * implements it. The object implementing this interface must be returned | |
| 38 | + * from the component's getInputMethodRequests method. | |
| 39 | + * | |
| 40 | + * <p> | |
| 41 | + * The text editing component also has to provide an input method event | |
| 42 | + * listener. | |
| 43 | + * | |
| 44 | + * <p> | |
| 45 | + * The interface is designed to support one of two input user interfaces: | |
| 46 | + * <ul> | |
| 47 | + * <li><em>on-the-spot</em> input, where the composed text is displayed as part | |
| 48 | + * of the text component's text body. | |
| 49 | + * <li><em>below-the-spot</em> input, where the composed text is displayed in | |
| 50 | + * a separate composition window just below the insertion point where | |
| 51 | + * the text will be inserted when it is committed. Note that, if text is | |
| 52 | + * selected within the component's text body, this text will be replaced by | |
| 53 | + * the committed text upon commitment; therefore it is not considered part | |
| 54 | + * of the context that the text is input into. | |
| 55 | + * </ul> | |
| 56 | + * | |
| 57 | + * @see java.awt.Component#getInputMethodRequests | |
| 58 | + * @see java.awt.event.InputMethodListener | |
| 59 | + * | |
| 60 | + * @author JavaSoft Asia/Pacific | |
| 61 | + * @since 1.2 | |
| 62 | + */ | |
| 63 | + | |
| 64 | +public interface InputMethodRequests { | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * Gets the location of a specified offset in the current composed text, | |
| 68 | + * or of the selection in committed text. | |
| 69 | + * This information is, for example, used to position the candidate window | |
| 70 | + * near the composed text, or a composition window near the location | |
| 71 | + * where committed text will be inserted. | |
| 72 | + * | |
| 73 | + * <p> | |
| 74 | + * If the component has composed text (because the most recent | |
| 75 | + * InputMethodEvent sent to it contained composed text), then the offset is | |
| 76 | + * relative to the composed text - offset 0 indicates the first character | |
| 77 | + * in the composed text. The location returned should be for this character. | |
| 78 | + * | |
| 79 | + * <p> | |
| 80 | + * If the component doesn't have composed text, the offset should be ignored, | |
| 81 | + * and the location returned should reflect the beginning (in line | |
| 82 | + * direction) of the highlight in the last line containing selected text. | |
| 83 | + * For example, for horizontal left-to-right text (such as English), the | |
| 84 | + * location to the left of the left-most character on the last line | |
| 85 | + * containing selected text is returned. For vertical top-to-bottom text, | |
| 86 | + * with lines proceding from right to left, the location to the top of the | |
| 87 | + * left-most line containing selected text is returned. | |
| 88 | + * | |
| 89 | + * <p> | |
| 90 | + * The location is represented as a 0-thickness caret, that is, it has 0 | |
| 91 | + * width if the text is drawn horizontally, and 0 height if the text is | |
| 92 | + * drawn vertically. Other text orientations need to be mapped to | |
| 93 | + * horizontal or vertical orientation. The rectangle uses absolute screen | |
| 94 | + * coordinates. | |
| 95 | + * | |
| 96 | + * @param offset the offset within the composed text, if there is composed | |
| 97 | + * text; null otherwise | |
| 98 | + * @return a rectangle representing the screen location of the offset | |
| 99 | + */ | |
| 100 | + Rectangle getTextLocation(TextHitInfo offset); | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * Gets the offset within the composed text for the specified absolute x | |
| 104 | + * and y coordinates on the screen. This information is used, for example | |
| 105 | + * to handle mouse clicks and the mouse cursor. The offset is relative to | |
| 106 | + * the composed text, so offset 0 indicates the beginning of the composed | |
| 107 | + * text. | |
| 108 | + * | |
| 109 | + * <p> | |
| 110 | + * Return null if the location is outside the area occupied by the composed | |
| 111 | + * text. | |
| 112 | + * | |
| 113 | + * @param x the absolute x coordinate on screen | |
| 114 | + * @param y the absolute y coordinate on screen | |
| 115 | + * @return a text hit info describing the offset in the composed text. | |
| 116 | + */ | |
| 117 | + TextHitInfo getLocationOffset(int x, int y); | |
| 118 | + | |
| 119 | + /** | |
| 120 | + * Gets the offset of the insert position in the committed text contained | |
| 121 | + * in the text editing component. This is the offset at which characters | |
| 122 | + * entered through an input method are inserted. This information is used | |
| 123 | + * by an input method, for example, to examine the text surrounding the | |
| 124 | + * insert position. | |
| 125 | + * | |
| 126 | + * @return the offset of the insert position | |
| 127 | + */ | |
| 128 | + int getInsertPositionOffset(); | |
| 129 | + | |
| 130 | + /** | |
| 131 | + * Gets an iterator providing access to the entire text and attributes | |
| 132 | + * contained in the text editing component except for uncommitted | |
| 133 | + * text. Uncommitted (composed) text should be ignored for index | |
| 134 | + * calculations and should not be made accessible through the iterator. | |
| 135 | + * | |
| 136 | + * <p> | |
| 137 | + * The input method may provide a list of attributes that it is | |
| 138 | + * interested in. In that case, information about other attributes that | |
| 139 | + * the implementor may have need not be made accessible through the | |
| 140 | + * iterator. If the list is null, all available attribute information | |
| 141 | + * should be made accessible. | |
| 142 | + * | |
| 143 | + * @param beginIndex the index of the first character | |
| 144 | + * @param endIndex the index of the character following the last character | |
| 145 | + * @param attributes a list of attributes that the input method is | |
| 146 | + * interested in | |
| 147 | + * @return an iterator providing access to the text and its attributes | |
| 148 | + */ | |
| 149 | + AttributedCharacterIterator getCommittedText(int beginIndex, int endIndex, | |
| 150 | + Attribute[] attributes); | |
| 151 | + | |
| 152 | + /** | |
| 153 | + * Gets the length of the entire text contained in the text | |
| 154 | + * editing component except for uncommitted (composed) text. | |
| 155 | + * | |
| 156 | + * @return the length of the text except for uncommitted text | |
| 157 | + */ | |
| 158 | + int getCommittedTextLength(); | |
| 159 | + | |
| 160 | + /** | |
| 161 | + * Gets the latest committed text from the text editing component and | |
| 162 | + * removes it from the component's text body. | |
| 163 | + * This is used for the "Undo Commit" feature in some input methods, where | |
| 164 | + * the committed text reverts to its previous composed state. The composed | |
| 165 | + * text will be sent to the component using an InputMethodEvent. | |
| 166 | + * | |
| 167 | + * <p> | |
| 168 | + * Generally, this feature should only be supported immediately after the | |
| 169 | + * text was committed, not after the user performed other operations on the | |
| 170 | + * text. When the feature is not supported, return null. | |
| 171 | + * | |
| 172 | + * <p> | |
| 173 | + * The input method may provide a list of attributes that it is | |
| 174 | + * interested in. In that case, information about other attributes that | |
| 175 | + * the implementor may have need not be made accessible through the | |
| 176 | + * iterator. If the list is null, all available attribute information | |
| 177 | + * should be made accessible. | |
| 178 | + * | |
| 179 | + * @param attributes a list of attributes that the input method is | |
| 180 | + * interested in | |
| 181 | + * @return the latest committed text, or null when the "Undo Commit" | |
| 182 | + * feature is not supported | |
| 183 | + */ | |
| 184 | + AttributedCharacterIterator cancelLatestCommittedText(Attribute[] attributes); | |
| 185 | + | |
| 186 | + /** | |
| 187 | + * Gets the currently selected text from the text editing component. | |
| 188 | + * This may be used for a variety of purposes. | |
| 189 | + * One of them is the "Reconvert" feature in some input methods. | |
| 190 | + * In this case, the input method will typically send an input method event | |
| 191 | + * to replace the selected text with composed text. Depending on the input | |
| 192 | + * method's capabilities, this may be the original composed text for the | |
| 193 | + * selected text, the latest composed text entered anywhere in the text, or | |
| 194 | + * a version of the text that's converted back from the selected text. | |
| 195 | + * | |
| 196 | + * <p> | |
| 197 | + * The input method may provide a list of attributes that it is | |
| 198 | + * interested in. In that case, information about other attributes that | |
| 199 | + * the implementor may have need not be made accessible through the | |
| 200 | + * iterator. If the list is null, all available attribute information | |
| 201 | + * should be made accessible. | |
| 202 | + * | |
| 203 | + * @param attributes a list of attributes that the input method is | |
| 204 | + * interested in | |
| 205 | + * @return the currently selected text | |
| 206 | + */ | |
| 207 | + AttributedCharacterIterator getSelectedText(Attribute[] attributes); | |
| 208 | +} | |
Binary file not shown.
| @@ -0,0 +1,114 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package java.awt.im; | |
| 27 | + | |
| 28 | + | |
| 29 | +/** | |
| 30 | + * Defines additional Unicode subsets for use by input methods. Unlike the | |
| 31 | + * UnicodeBlock subsets defined in the <code>{@link | |
| 32 | + * java.lang.Character.UnicodeBlock}</code> class, these constants do not | |
| 33 | + * directly correspond to Unicode code blocks. | |
| 34 | + * | |
| 35 | + * @since 1.2 | |
| 36 | + */ | |
| 37 | + | |
| 38 | +public final class InputSubset extends Character.Subset { | |
| 39 | + | |
| 40 | + private InputSubset(String name) { | |
| 41 | + super(name); | |
| 42 | + } | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * Constant for all Latin characters, including the characters | |
| 46 | + * in the BASIC_LATIN, LATIN_1_SUPPLEMENT, LATIN_EXTENDED_A, | |
| 47 | + * LATIN_EXTENDED_B Unicode character blocks. | |
| 48 | + */ | |
| 49 | + public static final InputSubset LATIN | |
| 50 | + = new InputSubset("LATIN"); | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * Constant for the digits included in the BASIC_LATIN Unicode character | |
| 54 | + * block. | |
| 55 | + */ | |
| 56 | + public static final InputSubset LATIN_DIGITS | |
| 57 | + = new InputSubset("LATIN_DIGITS"); | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * Constant for all Han characters used in writing Traditional Chinese, | |
| 61 | + * including a subset of the CJK unified ideographs as well as Traditional | |
| 62 | + * Chinese Han characters that may be defined as surrogate characters. | |
| 63 | + */ | |
| 64 | + public static final InputSubset TRADITIONAL_HANZI | |
| 65 | + = new InputSubset("TRADITIONAL_HANZI"); | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * Constant for all Han characters used in writing Simplified Chinese, | |
| 69 | + * including a subset of the CJK unified ideographs as well as Simplified | |
| 70 | + * Chinese Han characters that may be defined as surrogate characters. | |
| 71 | + */ | |
| 72 | + public static final InputSubset SIMPLIFIED_HANZI | |
| 73 | + = new InputSubset("SIMPLIFIED_HANZI"); | |
| 74 | + | |
| 75 | + /** | |
| 76 | + * Constant for all Han characters used in writing Japanese, including a | |
| 77 | + * subset of the CJK unified ideographs as well as Japanese Han characters | |
| 78 | + * that may be defined as surrogate characters. | |
| 79 | + */ | |
| 80 | + public static final InputSubset KANJI | |
| 81 | + = new InputSubset("KANJI"); | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * Constant for all Han characters used in writing Korean, including a | |
| 85 | + * subset of the CJK unified ideographs as well as Korean Han characters | |
| 86 | + * that may be defined as surrogate characters. | |
| 87 | + */ | |
| 88 | + public static final InputSubset HANJA | |
| 89 | + = new InputSubset("HANJA"); | |
| 90 | + | |
| 91 | + /** | |
| 92 | + * Constant for the halfwidth katakana subset of the Unicode halfwidth and | |
| 93 | + * fullwidth forms character block. | |
| 94 | + */ | |
| 95 | + public static final InputSubset HALFWIDTH_KATAKANA | |
| 96 | + = new InputSubset("HALFWIDTH_KATAKANA"); | |
| 97 | + | |
| 98 | + /** | |
| 99 | + * Constant for the fullwidth ASCII variants subset of the Unicode halfwidth and | |
| 100 | + * fullwidth forms character block. | |
| 101 | + * @since 1.3 | |
| 102 | + */ | |
| 103 | + public static final InputSubset FULLWIDTH_LATIN | |
| 104 | + = new InputSubset("FULLWIDTH_LATIN"); | |
| 105 | + | |
| 106 | + /** | |
| 107 | + * Constant for the fullwidth digits included in the Unicode halfwidth and | |
| 108 | + * fullwidth forms character block. | |
| 109 | + * @since 1.3 | |
| 110 | + */ | |
| 111 | + public static final InputSubset FULLWIDTH_DIGITS | |
| 112 | + = new InputSubset("FULLWIDTH_DIGITS"); | |
| 113 | + | |
| 114 | +} | |
| @@ -0,0 +1,15 @@ | ||
| 1 | +<../../../../../mkconfig | |
| 2 | + | |
| 3 | +DIRS=\ | |
| 4 | + spi\ | |
| 5 | + | |
| 6 | +TARG=\ | |
| 7 | + InputContext.dis\ | |
| 8 | + InputMethodHighlight.dis\ | |
| 9 | + InputMethodRequests.dis\ | |
| 10 | + InputSubset.dis\ | |
| 11 | + | |
| 12 | +DISBIN=$ROOT/java/dis/java/java/java/awt/im | |
| 13 | + | |
| 14 | +<$ROOT/mkfiles/mkjava | |
| 15 | +<$ROOT/mkfiles/mksubdirs | |
| @@ -0,0 +1,69 @@ | ||
| 1 | +<!-- | |
| 2 | + Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + | |
| 5 | + This code is free software; you can redistribute it and/or modify it | |
| 6 | + under the terms of the GNU General Public License version 2 only, as | |
| 7 | + published by the Free Software Foundation. Oracle designates this | |
| 8 | + particular file as subject to the "Classpath" exception as provided | |
| 9 | + by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + | |
| 11 | + This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + accompanied this code). | |
| 16 | + | |
| 17 | + You should have received a copy of the GNU General Public License version | |
| 18 | + 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + | |
| 21 | + Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + or visit www.oracle.com if you need additional information or have any | |
| 23 | + questions. | |
| 24 | +--> | |
| 25 | + | |
| 26 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> | |
| 27 | +<HTML> | |
| 28 | +<HEAD> | |
| 29 | + <META NAME=GENERATOR CONTENT="Claris Home Page 2.0"> | |
| 30 | + <X-SAS-WINDOW TOP=42 BOTTOM=589 LEFT=4 RIGHT=534> | |
| 31 | +</HEAD> | |
| 32 | +<BODY BGCOLOR="#FFFFFF"> | |
| 33 | + | |
| 34 | +<P>Provides classes and interfaces for the input method framework. | |
| 35 | +This package enables text editing components to receive text input | |
| 36 | +through input methods. Input methods are software components that let | |
| 37 | +the user enter text in ways other than simple typing on a keyboard. | |
| 38 | +They are commonly used to enter Japanese, Chinese, or Korean - | |
| 39 | +languages using thousands of different characters - on keyboards with | |
| 40 | +far fewer keys. However, the framework also supports input methods | |
| 41 | +for other languages and the use of entirely different input | |
| 42 | +mechanisms, such as handwriting or speech recognition.</P> | |
| 43 | + | |
| 44 | +<H2>Package Specification</H2> | |
| 45 | + | |
| 46 | +<UL> | |
| 47 | + <LI><B><A HREF="{@docRoot}/../technotes/guides/imf/spec.html">Input Method | |
| 48 | + Framework Specification</A></B> | |
| 49 | + | |
| 50 | + <LI><B><A HREF="{@docRoot}/../technotes/guides/imf/api-reference.html">Input | |
| 51 | + Method Client API Reference</A></B> | |
| 52 | +</UL> | |
| 53 | + | |
| 54 | +<H2>Related Documentation</H2> | |
| 55 | + | |
| 56 | +<P>For overviews, tutorials, examples, guides, and tool | |
| 57 | +documentation, please see:</P> | |
| 58 | + | |
| 59 | +<UL> | |
| 60 | + <LI><B><A HREF="{@docRoot}/../technotes/guides/imf/overview.html">Input Method | |
| 61 | + Framework Overview</A></B> | |
| 62 | + | |
| 63 | + <LI><B><A HREF="{@docRoot}/../technotes/guides/imf/api-tutorial.html">Input | |
| 64 | + Method Client API Tutorial</A></B> | |
| 65 | +</UL> | |
| 66 | + | |
| 67 | +@since 1.2 | |
| 68 | +</BODY> | |
| 69 | +</HTML> | |
Binary file not shown.
| @@ -0,0 +1,382 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package java.awt.im.spi; | |
| 27 | + | |
| 28 | +import java.util.Locale; | |
| 29 | +import java.awt.AWTEvent; | |
| 30 | +import java.awt.Rectangle; | |
| 31 | +import java.lang.Character.Subset; | |
| 32 | + | |
| 33 | + | |
| 34 | +/** | |
| 35 | + * Defines the interface for an input method that supports complex text input. | |
| 36 | + * Input methods traditionally support text input for languages that have | |
| 37 | + * more characters than can be represented on a standard-size keyboard, | |
| 38 | + * such as Chinese, Japanese, and Korean. However, they may also be used to | |
| 39 | + * support phonetic text input for English or character reordering for Thai. | |
| 40 | + * <p> | |
| 41 | + * Subclasses of InputMethod can be loaded by the input method framework; they | |
| 42 | + * can then be selected either through the API | |
| 43 | + * ({@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod}) | |
| 44 | + * or the user interface (the input method selection menu). | |
| 45 | + * | |
| 46 | + * @since 1.3 | |
| 47 | + * | |
| 48 | + * @author JavaSoft International | |
| 49 | + */ | |
| 50 | + | |
| 51 | +public interface InputMethod { | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * Sets the input method context, which is used to dispatch input method | |
| 55 | + * events to the client component and to request information from | |
| 56 | + * the client component. | |
| 57 | + * <p> | |
| 58 | + * This method is called once immediately after instantiating this input | |
| 59 | + * method. | |
| 60 | + * | |
| 61 | + * @param context the input method context for this input method | |
| 62 | + * @exception NullPointerException if <code>context</code> is null | |
| 63 | + */ | |
| 64 | + public void setInputMethodContext(InputMethodContext context); | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * Attempts to set the input locale. If the input method supports the | |
| 68 | + * desired locale, it changes its behavior to support input for the locale | |
| 69 | + * and returns true. | |
| 70 | + * Otherwise, it returns false and does not change its behavior. | |
| 71 | + * <p> | |
| 72 | + * This method is called | |
| 73 | + * <ul> | |
| 74 | + * <li>by {@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod}, | |
| 75 | + * <li>when switching to this input method through the user interface if the user | |
| 76 | + * specified a locale or if the previously selected input method's | |
| 77 | + * {@link java.awt.im.spi.InputMethod#getLocale getLocale} method | |
| 78 | + * returns a non-null value. | |
| 79 | + * </ul> | |
| 80 | + * | |
| 81 | + * @param locale locale to input | |
| 82 | + * @return whether the specified locale is supported | |
| 83 | + * @exception NullPointerException if <code>locale</code> is null | |
| 84 | + */ | |
| 85 | + public boolean setLocale(Locale locale); | |
| 86 | + | |
| 87 | + /** | |
| 88 | + * Returns the current input locale. Might return null in exceptional cases. | |
| 89 | + * <p> | |
| 90 | + * This method is called | |
| 91 | + * <ul> | |
| 92 | + * <li>by {@link java.awt.im.InputContext#getLocale InputContext.getLocale} and | |
| 93 | + * <li>when switching from this input method to a different one through the | |
| 94 | + * user interface. | |
| 95 | + * </ul> | |
| 96 | + * | |
| 97 | + * @return the current input locale, or null | |
| 98 | + */ | |
| 99 | + public Locale getLocale(); | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * Sets the subsets of the Unicode character set that this input method | |
| 103 | + * is allowed to input. Null may be passed in to indicate that all | |
| 104 | + * characters are allowed. | |
| 105 | + * <p> | |
| 106 | + * This method is called | |
| 107 | + * <ul> | |
| 108 | + * <li>immediately after instantiating this input method, | |
| 109 | + * <li>when switching to this input method from a different one, and | |
| 110 | + * <li>by {@link java.awt.im.InputContext#setCharacterSubsets InputContext.setCharacterSubsets}. | |
| 111 | + * </ul> | |
| 112 | + * | |
| 113 | + * @param subsets the subsets of the Unicode character set from which | |
| 114 | + * characters may be input | |
| 115 | + */ | |
| 116 | + public void setCharacterSubsets(Subset[] subsets); | |
| 117 | + | |
| 118 | + /** | |
| 119 | + * Enables or disables this input method for composition, | |
| 120 | + * depending on the value of the parameter <code>enable</code>. | |
| 121 | + * <p> | |
| 122 | + * An input method that is enabled for composition interprets incoming | |
| 123 | + * events for both composition and control purposes, while a | |
| 124 | + * disabled input method does not interpret events for composition. | |
| 125 | + * Note however that events are passed on to the input method regardless | |
| 126 | + * whether it is enabled or not, and that an input method that is disabled | |
| 127 | + * for composition may still interpret events for control purposes, | |
| 128 | + * including to enable or disable itself for composition. | |
| 129 | + * <p> | |
| 130 | + * For input methods provided by host operating systems, it is not always possible to | |
| 131 | + * determine whether this operation is supported. For example, an input method may enable | |
| 132 | + * composition only for some locales, and do nothing for other locales. For such input | |
| 133 | + * methods, it is possible that this method does not throw | |
| 134 | + * {@link java.lang.UnsupportedOperationException UnsupportedOperationException}, | |
| 135 | + * but also does not affect whether composition is enabled. | |
| 136 | + * <p> | |
| 137 | + * This method is called | |
| 138 | + * <ul> | |
| 139 | + * <li>by {@link java.awt.im.InputContext#setCompositionEnabled InputContext.setCompositionEnabled}, | |
| 140 | + * <li>when switching to this input method from a different one using the | |
| 141 | + * user interface or | |
| 142 | + * {@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod}, | |
| 143 | + * if the previously selected input method's | |
| 144 | + * {@link java.awt.im.spi.InputMethod#isCompositionEnabled isCompositionEnabled} | |
| 145 | + * method returns without throwing an exception. | |
| 146 | + * </ul> | |
| 147 | + * | |
| 148 | + * @param enable whether to enable the input method for composition | |
| 149 | + * @throws UnsupportedOperationException if this input method does not | |
| 150 | + * support the enabling/disabling operation | |
| 151 | + * @see #isCompositionEnabled | |
| 152 | + */ | |
| 153 | + public void setCompositionEnabled(boolean enable); | |
| 154 | + | |
| 155 | + /** | |
| 156 | + * Determines whether this input method is enabled. | |
| 157 | + * An input method that is enabled for composition interprets incoming | |
| 158 | + * events for both composition and control purposes, while a | |
| 159 | + * disabled input method does not interpret events for composition. | |
| 160 | + * <p> | |
| 161 | + * This method is called | |
| 162 | + * <ul> | |
| 163 | + * <li>by {@link java.awt.im.InputContext#isCompositionEnabled InputContext.isCompositionEnabled} and | |
| 164 | + * <li>when switching from this input method to a different one using the | |
| 165 | + * user interface or | |
| 166 | + * {@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod}. | |
| 167 | + * </ul> | |
| 168 | + * | |
| 169 | + * @return <code>true</code> if this input method is enabled for | |
| 170 | + * composition; <code>false</code> otherwise. | |
| 171 | + * @throws UnsupportedOperationException if this input method does not | |
| 172 | + * support checking whether it is enabled for composition | |
| 173 | + * @see #setCompositionEnabled | |
| 174 | + */ | |
| 175 | + public boolean isCompositionEnabled(); | |
| 176 | + | |
| 177 | + /** | |
| 178 | + * Starts the reconversion operation. The input method obtains the | |
| 179 | + * text to be reconverted from the current client component using the | |
| 180 | + * {@link java.awt.im.InputMethodRequests#getSelectedText InputMethodRequests.getSelectedText} | |
| 181 | + * method. It can use other <code>InputMethodRequests</code> | |
| 182 | + * methods to request additional information required for the | |
| 183 | + * reconversion operation. The composed and committed text | |
| 184 | + * produced by the operation is sent to the client component as a | |
| 185 | + * sequence of <code>InputMethodEvent</code>s. If the given text | |
| 186 | + * cannot be reconverted, the same text should be sent to the | |
| 187 | + * client component as committed text. | |
| 188 | + * <p> | |
| 189 | + * This method is called by | |
| 190 | + * {@link java.awt.im.InputContext#reconvert() InputContext.reconvert}. | |
| 191 | + * | |
| 192 | + * @throws UnsupportedOperationException if the input method does not | |
| 193 | + * support the reconversion operation. | |
| 194 | + */ | |
| 195 | + public void reconvert(); | |
| 196 | + | |
| 197 | + /** | |
| 198 | + * Dispatches the event to the input method. If input method support is | |
| 199 | + * enabled for the focussed component, incoming events of certain types | |
| 200 | + * are dispatched to the current input method for this component before | |
| 201 | + * they are dispatched to the component's methods or event listeners. | |
| 202 | + * The input method decides whether it needs to handle the event. If it | |
| 203 | + * does, it also calls the event's <code>consume</code> method; this | |
| 204 | + * causes the event to not get dispatched to the component's event | |
| 205 | + * processing methods or event listeners. | |
| 206 | + * <p> | |
| 207 | + * Events are dispatched if they are instances of InputEvent or its | |
| 208 | + * subclasses. | |
| 209 | + * This includes instances of the AWT classes KeyEvent and MouseEvent. | |
| 210 | + * <p> | |
| 211 | + * This method is called by {@link java.awt.im.InputContext#dispatchEvent InputContext.dispatchEvent}. | |
| 212 | + * | |
| 213 | + * @param event the event being dispatched to the input method | |
| 214 | + * @exception NullPointerException if <code>event</code> is null | |
| 215 | + */ | |
| 216 | + public void dispatchEvent(AWTEvent event); | |
| 217 | + | |
| 218 | + /** | |
| 219 | + * Notifies this input method of changes in the client window | |
| 220 | + * location or state. This method is called while this input | |
| 221 | + * method is the current input method of its input context and | |
| 222 | + * notifications for it are enabled (see {@link | |
| 223 | + * InputMethodContext#enableClientWindowNotification | |
| 224 | + * InputMethodContext.enableClientWindowNotification}). Calls | |
| 225 | + * to this method are temporarily suspended if the input context's | |
| 226 | + * {@link java.awt.im.InputContext#removeNotify removeNotify} | |
| 227 | + * method is called, and resume when the input method is activated | |
| 228 | + * for a new client component. It is called in the following | |
| 229 | + * situations: | |
| 230 | + * <ul> | |
| 231 | + * <li> | |
| 232 | + * when the window containing the current client component changes | |
| 233 | + * in location, size, visibility, iconification state, or when the | |
| 234 | + * window is closed.</li> | |
| 235 | + * <li> | |
| 236 | + * from <code> enableClientWindowNotification(inputMethod, | |
| 237 | + * true)</code> if the current client component exists,</li> | |
| 238 | + * <li> | |
| 239 | + * when activating the input method for the first time after it | |
| 240 | + * called | |
| 241 | + * <code>enableClientWindowNotification(inputMethod, | |
| 242 | + * true)</code> if during the call no current client component was | |
| 243 | + * available,</li> | |
| 244 | + * <li> | |
| 245 | + * when activating the input method for a new client component | |
| 246 | + * after the input context's removeNotify method has been | |
| 247 | + * called.</li> | |
| 248 | + * </ul> | |
| 249 | + * @param bounds client window's {@link | |
| 250 | + * java.awt.Component#getBounds bounds} on the screen; or null if | |
| 251 | + * the client window is iconified or invisible | |
| 252 | + */ | |
| 253 | + public void notifyClientWindowChange(Rectangle bounds); | |
| 254 | + | |
| 255 | + /** | |
| 256 | + * Activates the input method for immediate input processing. | |
| 257 | + * <p> | |
| 258 | + * If an input method provides its own windows, it should make sure | |
| 259 | + * at this point that all necessary windows are open and visible. | |
| 260 | + * <p> | |
| 261 | + * This method is called | |
| 262 | + * <ul> | |
| 263 | + * <li>by {@link java.awt.im.InputContext#dispatchEvent InputContext.dispatchEvent} | |
| 264 | + * when a client component receives a FOCUS_GAINED event, | |
| 265 | + * <li>when switching to this input method from a different one using the | |
| 266 | + * user interface or | |
| 267 | + * {@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod}. | |
| 268 | + * </ul> | |
| 269 | + * The method is only called when the input method is inactive. | |
| 270 | + * A newly instantiated input method is assumed to be inactive. | |
| 271 | + */ | |
| 272 | + public void activate(); | |
| 273 | + | |
| 274 | + /** | |
| 275 | + * Deactivates the input method. | |
| 276 | + * The isTemporary argument has the same meaning as in | |
| 277 | + * {@link java.awt.event.FocusEvent#isTemporary FocusEvent.isTemporary}. | |
| 278 | + * <p> | |
| 279 | + * If an input method provides its own windows, only windows that relate | |
| 280 | + * to the current composition (such as a lookup choice window) should be | |
| 281 | + * closed at this point. | |
| 282 | + * It is possible that the input method will be immediately activated again | |
| 283 | + * for a different client component, and closing and reopening more | |
| 284 | + * persistent windows (such as a control panel) would create unnecessary | |
| 285 | + * screen flicker. | |
| 286 | + * Before an instance of a different input method class is activated, | |
| 287 | + * {@link #hideWindows} is called on the current input method. | |
| 288 | + * <p> | |
| 289 | + * This method is called | |
| 290 | + * <ul> | |
| 291 | + * <li>by {@link java.awt.im.InputContext#dispatchEvent InputContext.dispatchEvent} | |
| 292 | + * when a client component receives a FOCUS_LOST event, | |
| 293 | + * <li>when switching from this input method to a different one using the | |
| 294 | + * user interface or | |
| 295 | + * {@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod}, | |
| 296 | + * <li>before {@link #removeNotify removeNotify} if the current client component is | |
| 297 | + * removed. | |
| 298 | + * </ul> | |
| 299 | + * The method is only called when the input method is active. | |
| 300 | + * | |
| 301 | + * @param isTemporary whether the focus change is temporary | |
| 302 | + */ | |
| 303 | + public void deactivate(boolean isTemporary); | |
| 304 | + | |
| 305 | + /** | |
| 306 | + * Closes or hides all windows opened by this input method instance or | |
| 307 | + * its class. | |
| 308 | + * <p> | |
| 309 | + * This method is called | |
| 310 | + * <ul> | |
| 311 | + * <li>before calling {@link #activate activate} on an instance of a different input | |
| 312 | + * method class, | |
| 313 | + * <li>before calling {@link #dispose dispose} on this input method. | |
| 314 | + * </ul> | |
| 315 | + * The method is only called when the input method is inactive. | |
| 316 | + */ | |
| 317 | + public void hideWindows(); | |
| 318 | + | |
| 319 | + /** | |
| 320 | + * Notifies the input method that a client component has been | |
| 321 | + * removed from its containment hierarchy, or that input method | |
| 322 | + * support has been disabled for the component. | |
| 323 | + * <p> | |
| 324 | + * This method is called by {@link java.awt.im.InputContext#removeNotify InputContext.removeNotify}. | |
| 325 | + * <p> | |
| 326 | + * The method is only called when the input method is inactive. | |
| 327 | + */ | |
| 328 | + public void removeNotify(); | |
| 329 | + | |
| 330 | + /** | |
| 331 | + * Ends any input composition that may currently be going on in this | |
| 332 | + * context. Depending on the platform and possibly user preferences, | |
| 333 | + * this may commit or delete uncommitted text. Any changes to the text | |
| 334 | + * are communicated to the active component using an input method event. | |
| 335 | + * | |
| 336 | + * <p> | |
| 337 | + * A text editing component may call this in a variety of situations, | |
| 338 | + * for example, when the user moves the insertion point within the text | |
| 339 | + * (but outside the composed text), or when the component's text is | |
| 340 | + * saved to a file or copied to the clipboard. | |
| 341 | + * <p> | |
| 342 | + * This method is called | |
| 343 | + * <ul> | |
| 344 | + * <li>by {@link java.awt.im.InputContext#endComposition InputContext.endComposition}, | |
| 345 | + * <li>by {@link java.awt.im.InputContext#dispatchEvent InputContext.dispatchEvent} | |
| 346 | + * when switching to a different client component | |
| 347 | + * <li>when switching from this input method to a different one using the | |
| 348 | + * user interface or | |
| 349 | + * {@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod}. | |
| 350 | + * </ul> | |
| 351 | + */ | |
| 352 | + public void endComposition(); | |
| 353 | + | |
| 354 | + /** | |
| 355 | + * Releases the resources used by this input method. | |
| 356 | + * In particular, the input method should dispose windows and close files that are no | |
| 357 | + * longer needed. | |
| 358 | + * <p> | |
| 359 | + * This method is called by {@link java.awt.im.InputContext#dispose InputContext.dispose}. | |
| 360 | + * <p> | |
| 361 | + * The method is only called when the input method is inactive. | |
| 362 | + * No method of this interface is called on this instance after dispose. | |
| 363 | + */ | |
| 364 | + public void dispose(); | |
| 365 | + | |
| 366 | + /** | |
| 367 | + * Returns a control object from this input method, or null. A | |
| 368 | + * control object provides methods that control the behavior of the | |
| 369 | + * input method or obtain information from the input method. The type | |
| 370 | + * of the object is an input method specific class. Clients have to | |
| 371 | + * compare the result against known input method control object | |
| 372 | + * classes and cast to the appropriate class to invoke the methods | |
| 373 | + * provided. | |
| 374 | + * <p> | |
| 375 | + * This method is called by | |
| 376 | + * {@link java.awt.im.InputContext#getInputMethodControlObject InputContext.getInputMethodControlObject}. | |
| 377 | + * | |
| 378 | + * @return a control object from this input method, or null | |
| 379 | + */ | |
| 380 | + public Object getControlObject(); | |
| 381 | + | |
| 382 | +} | |
Binary file not shown.
| @@ -0,0 +1,140 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package java.awt.im.spi; | |
| 27 | + | |
| 28 | +import java.awt.HeadlessException; | |
| 29 | +import java.awt.Window; | |
| 30 | +import java.awt.font.TextHitInfo; | |
| 31 | +import java.awt.im.InputMethodRequests; | |
| 32 | +import java.text.AttributedCharacterIterator; | |
| 33 | +import javax.swing.JFrame; | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * Provides methods that input methods | |
| 37 | + * can use to communicate with their client components or to request | |
| 38 | + * other services. This interface is implemented by the input method | |
| 39 | + * framework, and input methods call its methods on the instance they | |
| 40 | + * receive through | |
| 41 | + * {@link java.awt.im.spi.InputMethod#setInputMethodContext}. | |
| 42 | + * There should be no other implementors or callers. | |
| 43 | + * | |
| 44 | + * @since 1.3 | |
| 45 | + * | |
| 46 | + * @author JavaSoft International | |
| 47 | + */ | |
| 48 | + | |
| 49 | +public interface InputMethodContext extends InputMethodRequests { | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * Creates an input method event from the arguments given | |
| 53 | + * and dispatches it to the client component. For arguments, | |
| 54 | + * see {@link java.awt.event.InputMethodEvent#InputMethodEvent}. | |
| 55 | + */ | |
| 56 | + public void dispatchInputMethodEvent(int id, | |
| 57 | + AttributedCharacterIterator text, int committedCharacterCount, | |
| 58 | + TextHitInfo caret, TextHitInfo visiblePosition); | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Creates a top-level window for use by the input method. | |
| 62 | + * The intended behavior of this window is: | |
| 63 | + * <ul> | |
| 64 | + * <li>it floats above all document windows and dialogs | |
| 65 | + * <li>it and all components that it contains do not receive the focus | |
| 66 | + * <li>it has lightweight decorations, such as a reduced drag region without title | |
| 67 | + * </ul> | |
| 68 | + * However, the actual behavior with respect to these three items is platform dependent. | |
| 69 | + * <p> | |
| 70 | + * The title may or may not be displayed, depending on the actual type of window created. | |
| 71 | + * <p> | |
| 72 | + * If attachToInputContext is true, the new window will share the input context that | |
| 73 | + * corresponds to this input method context, so that events for components in the window | |
| 74 | + * are automatically dispatched to the input method. | |
| 75 | + * Also, when the window is opened using setVisible(true), the input context will prevent | |
| 76 | + * deactivate and activate calls to the input method that might otherwise be caused. | |
| 77 | + * <p> | |
| 78 | + * Input methods must call {@link java.awt.Window#dispose() Window.dispose} on the | |
| 79 | + * returned input method window when it is no longer needed. | |
| 80 | + * <p> | |
| 81 | + * @param title the title to be displayed in the window's title bar, | |
| 82 | + * if there is such a title bar. | |
| 83 | + * A <code>null</code> value is treated as an empty string, "". | |
| 84 | + * @param attachToInputContext whether this window should share the input context | |
| 85 | + * that corresponds to this input method context | |
| 86 | + * @return a window with special characteristics for use by input methods | |
| 87 | + * @exception HeadlessException if <code>GraphicsEnvironment.isHeadless | |
| 88 | + * </code> returns <code>true</code> | |
| 89 | + */ | |
| 90 | + public Window createInputMethodWindow(String title, boolean attachToInputContext); | |
| 91 | + | |
| 92 | + /** | |
| 93 | + * Creates a top-level Swing JFrame for use by the input method. | |
| 94 | + * The intended behavior of this window is: | |
| 95 | + * <ul> | |
| 96 | + * <li>it floats above all document windows and dialogs | |
| 97 | + * <li>it and all components that it contains do not receive the focus | |
| 98 | + * <li>it has lightweight decorations, such as a reduced drag region without title | |
| 99 | + * </ul> | |
| 100 | + * However, the actual behavior with respect to these three items is platform dependent. | |
| 101 | + * <p> | |
| 102 | + * The title may or may not be displayed, depending on the actual type of window created. | |
| 103 | + * <p> | |
| 104 | + * If attachToInputContext is true, the new window will share the input context that | |
| 105 | + * corresponds to this input method context, so that events for components in the window | |
| 106 | + * are automatically dispatched to the input method. | |
| 107 | + * Also, when the window is opened using setVisible(true), the input context will prevent | |
| 108 | + * deactivate and activate calls to the input method that might otherwise be caused. | |
| 109 | + * <p> | |
| 110 | + * Input methods must call {@link java.awt.Window#dispose() Window.dispose} on the | |
| 111 | + * returned input method window when it is no longer needed. | |
| 112 | + * <p> | |
| 113 | + * @param title the title to be displayed in the window's title bar, | |
| 114 | + * if there is such a title bar. | |
| 115 | + * A <code>null</code> value is treated as an empty string, "". | |
| 116 | + * @param attachToInputContext whether this window should share the input context | |
| 117 | + * that corresponds to this input method context | |
| 118 | + * @return a JFrame with special characteristics for use by input methods | |
| 119 | + * @exception HeadlessException if <code>GraphicsEnvironment.isHeadless | |
| 120 | + * </code> returns <code>true</code> | |
| 121 | + * | |
| 122 | + * @since 1.4 | |
| 123 | + */ | |
| 124 | + public JFrame createInputMethodJFrame(String title, boolean attachToInputContext); | |
| 125 | + | |
| 126 | + /** | |
| 127 | + * Enables or disables notification of the current client window's | |
| 128 | + * location and state for the specified input method. When | |
| 129 | + * notification is enabled, the input method's {@link | |
| 130 | + * java.awt.im.spi.InputMethod#notifyClientWindowChange | |
| 131 | + * notifyClientWindowChange} method is called as described in that | |
| 132 | + * method's specification. Notification is automatically disabled | |
| 133 | + * when the input method is disposed. | |
| 134 | + * | |
| 135 | + * @param inputMethod the input method for which notifications are | |
| 136 | + * enabled or disabled | |
| 137 | + * @param enable true to enable, false to disable | |
| 138 | + */ | |
| 139 | + public void enableClientWindowNotification(InputMethod inputMethod, boolean enable); | |
| 140 | +} | |
Binary file not shown.
| @@ -0,0 +1,124 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | + | |
| 27 | +package java.awt.im.spi; | |
| 28 | + | |
| 29 | +import java.awt.AWTException; | |
| 30 | +import java.awt.Image; | |
| 31 | +import java.util.Locale; | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * Defines methods that provide sufficient information about an input method | |
| 35 | + * to enable selection and loading of that input method. | |
| 36 | + * The input method itself is only loaded when it is actually used. | |
| 37 | + * | |
| 38 | + * @since 1.3 | |
| 39 | + */ | |
| 40 | + | |
| 41 | +public interface InputMethodDescriptor { | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * Returns the locales supported by the corresponding input method. | |
| 45 | + * The locale may describe just the language, or may also include | |
| 46 | + * country and variant information if needed. | |
| 47 | + * The information is used to select input methods by locale | |
| 48 | + * ({@link java.awt.im.InputContext#selectInputMethod(Locale)}). It may also | |
| 49 | + * be used to sort input methods by locale in a user-visible | |
| 50 | + * list of input methods. | |
| 51 | + * <p> | |
| 52 | + * Only the input method's primary locales should be returned. | |
| 53 | + * For example, if a Japanese input method also has a pass-through | |
| 54 | + * mode for Roman characters, typically still only Japanese would | |
| 55 | + * be returned. Thus, the list of locales returned is typically | |
| 56 | + * a subset of the locales for which the corresponding input method's | |
| 57 | + * implementation of {@link java.awt.im.spi.InputMethod#setLocale} returns true. | |
| 58 | + * <p> | |
| 59 | + * If {@link #hasDynamicLocaleList} returns true, this method is | |
| 60 | + * called each time the information is needed. This | |
| 61 | + * gives input methods that depend on network resources the chance | |
| 62 | + * to add or remove locales as resources become available or | |
| 63 | + * unavailable. | |
| 64 | + * | |
| 65 | + * @return the locales supported by the input method | |
| 66 | + * @exception AWTException if it can be determined that the input method | |
| 67 | + * is inoperable, for example, because of incomplete installation. | |
| 68 | + */ | |
| 69 | + Locale[] getAvailableLocales() throws AWTException; | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * Returns whether the list of available locales can change | |
| 73 | + * at runtime. This may be the case, for example, for adapters | |
| 74 | + * that access real input methods over the network. | |
| 75 | + */ | |
| 76 | + boolean hasDynamicLocaleList(); | |
| 77 | + | |
| 78 | + /** | |
| 79 | + * Returns the user-visible name of the corresponding | |
| 80 | + * input method for the given input locale in the language in which | |
| 81 | + * the name will be displayed. | |
| 82 | + * <p> | |
| 83 | + * The inputLocale parameter specifies the locale for which text | |
| 84 | + * is input. | |
| 85 | + * This parameter can only take values obtained from this descriptor's | |
| 86 | + * {@link #getAvailableLocales} method or null. If it is null, an | |
| 87 | + * input locale independent name for the input method should be | |
| 88 | + * returned. | |
| 89 | + * <p> | |
| 90 | + * If a name for the desired display language is not available, the | |
| 91 | + * method may fall back to some other language. | |
| 92 | + * | |
| 93 | + * @param inputLocale the locale for which text input is supported, or null | |
| 94 | + * @param displayLanguage the language in which the name will be displayed | |
| 95 | + */ | |
| 96 | + String getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage); | |
| 97 | + | |
| 98 | + /** | |
| 99 | + * Returns an icon for the corresponding input method. | |
| 100 | + * The icon may be used by a user interface for selecting input methods. | |
| 101 | + * <p> | |
| 102 | + * The inputLocale parameter specifies the locale for which text | |
| 103 | + * is input. | |
| 104 | + * This parameter can only take values obtained from this descriptor's | |
| 105 | + * {@link #getAvailableLocales} method or null. If it is null, an | |
| 106 | + * input locale independent icon for the input method should be | |
| 107 | + * returned. | |
| 108 | + * <p> | |
| 109 | + * The icon's size should be 16×16 pixels. | |
| 110 | + * | |
| 111 | + * @param inputLocale the locale for which text input is supported, or null | |
| 112 | + * @return an icon for the corresponding input method, or null | |
| 113 | + */ | |
| 114 | + Image getInputMethodIcon(Locale inputLocale); | |
| 115 | + | |
| 116 | + /** | |
| 117 | + * Creates a new instance of the corresponding input method. | |
| 118 | + * | |
| 119 | + * @return a new instance of the corresponding input method | |
| 120 | + * @exception Exception any exception that may occur while creating the | |
| 121 | + * input method instance | |
| 122 | + */ | |
| 123 | + InputMethod createInputMethod() throws Exception; | |
| 124 | +} | |
| @@ -0,0 +1,10 @@ | ||
| 1 | +<../../../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 4 | + InputMethod.dis\ | |
| 5 | + InputMethodContext.dis\ | |
| 6 | + InputMethodDescriptor.dis\ | |
| 7 | + | |
| 8 | +DISBIN=$ROOT/java/dis/java/java/java/awt/im/spi | |
| 9 | + | |
| 10 | +<$ROOT/mkfiles/mkjava | |
| @@ -0,0 +1,126 @@ | ||
| 1 | +<!-- | |
| 2 | + Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + | |
| 5 | + This code is free software; you can redistribute it and/or modify it | |
| 6 | + under the terms of the GNU General Public License version 2 only, as | |
| 7 | + published by the Free Software Foundation. Oracle designates this | |
| 8 | + particular file as subject to the "Classpath" exception as provided | |
| 9 | + by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + | |
| 11 | + This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + accompanied this code). | |
| 16 | + | |
| 17 | + You should have received a copy of the GNU General Public License version | |
| 18 | + 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + | |
| 21 | + Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + or visit www.oracle.com if you need additional information or have any | |
| 23 | + questions. | |
| 24 | +--> | |
| 25 | + | |
| 26 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> | |
| 27 | +<!--This file created 7/22/1999 11:47 by Claris Home Page version 2.0--> | |
| 28 | +<HTML> | |
| 29 | +<HEAD> | |
| 30 | + <TITLE>Package java.awt.im.spi Description</TITLE> | |
| 31 | + <META NAME=GENERATOR CONTENT="Claris Home Page 2.0"> | |
| 32 | + <X-SAS-WINDOW TOP=51 BOTTOM=592 LEFT=171 RIGHT=701> | |
| 33 | +</HEAD> | |
| 34 | +<BODY BGCOLOR="#FFFFFF"> | |
| 35 | + | |
| 36 | +<P>Provides interfaces that enable the development of input methods | |
| 37 | +that can be used with any Java runtime environment. Input methods are | |
| 38 | +software components that let the user enter text in ways other than | |
| 39 | +simple typing on a keyboard. They are commonly used to enter | |
| 40 | +Japanese, Chinese, or Korean - languages using thousands of different | |
| 41 | +characters - on keyboards with far fewer keys. However, this package | |
| 42 | +also allows the development of input methods for other languages and | |
| 43 | +the use of entirely different input mechanisms, such as handwriting | |
| 44 | +recognition.</P> | |
| 45 | + | |
| 46 | +<H2><A NAME="package_specification"></A>Package Specification</H2> | |
| 47 | + | |
| 48 | +<UL> | |
| 49 | + <LI><B><A HREF="../../../../../technotes/guides/imf/spec.html">Input Method | |
| 50 | + Framework Specification</A></B> | |
| 51 | + | |
| 52 | + <LI><B><A HREF="../../../../../technotes/guides/imf/spi-reference.html">Input | |
| 53 | + Method Engine SPI Reference</A></B> | |
| 54 | +</UL> | |
| 55 | + | |
| 56 | +<H4><A NAME="Packaging"></A>Packaging Input Methods</H4> | |
| 57 | + | |
| 58 | +<P>Input methods are packaged as installed extensions, as specified | |
| 59 | +by the <A HREF="../../../../../technotes/guides/extensions/index.html">Extension | |
| 60 | +Mechanism</A>. The main JAR file of an input method must contain the | |
| 61 | +file:</P> | |
| 62 | + | |
| 63 | +<PRE> META-INF/services/java.awt.im.spi.InputMethodDescriptor</PRE> | |
| 64 | + | |
| 65 | +<P>The file should contain a list of fully-qualified class names, one | |
| 66 | +per line, of classes implementing the | |
| 67 | +<CODE>java.awt.im.spi.InputMethodDescriptor</CODE> interface. Space | |
| 68 | +and tab characters surrounding each name, as well as blank lines, are | |
| 69 | +ignored. The comment character is <CODE>'#'</CODE> | |
| 70 | +(<CODE>\u0023</CODE>); on each line all characters following the | |
| 71 | +first comment character are ignored. The file must be encoded in | |
| 72 | +UTF-8.</P> | |
| 73 | + | |
| 74 | +<P>For example, if the fully-qualified name of the class that | |
| 75 | +implements <CODE>java.awt.im.spi.InputMethodDesciptor</CODE> for the | |
| 76 | +<EM>Foo</EM> input method is | |
| 77 | +<CODE>com.sun.ime.FooInputMethodDescriptor</CODE>, the file | |
| 78 | +<CODE>META-INF/services/java.awt.im.spi.InputMethodDescriptor</CODE> | |
| 79 | +contains a line:</P> | |
| 80 | + | |
| 81 | +<PRE> com.sun.ime.FooInputMethodDescriptor</PRE> | |
| 82 | + | |
| 83 | +<P>The input method must also provide at least two classes: one class | |
| 84 | +implementing the <CODE>java.awt.im.spi.InputMethodDescriptor</CODE> | |
| 85 | +interface, one class implementing the | |
| 86 | +<CODE>java.awt.im.spi.InputMethod</CODE> interface. The input method | |
| 87 | +should separate the implementations for these interfaces, so that | |
| 88 | +loading of the class implementing <CODE>InputMethod</CODE> can be | |
| 89 | +deferred until actually needed.</P> | |
| 90 | + | |
| 91 | +<H4><A NAME="Loading"></A>Loading Input Methods</H4> | |
| 92 | + | |
| 93 | +<P>The input method framework will usually defer loading of input | |
| 94 | +method classes until they are absolutely needed. It loads only the | |
| 95 | +<CODE>InputMethodDescriptor</CODE> implementations during AWT | |
| 96 | +initialization. It loads an <CODE>InputMethod</CODE> implementation | |
| 97 | +when the input method has been selected.</P> | |
| 98 | + | |
| 99 | +<H4><A NAME="PeeredComponents"></A>Java Input Methods and Peered Text | |
| 100 | +Components</H4> | |
| 101 | + | |
| 102 | +<P>The Java input method framework intends to support all | |
| 103 | +combinations of input methods (host input methods and Java input | |
| 104 | +methods) and components (peered and lightweight). However, because of | |
| 105 | +limitations in the underlying platform, it may not always be possible | |
| 106 | +to enable the communication between Java input methods and peered AWT | |
| 107 | +components. Support for this specific combination is therefore | |
| 108 | +platform dependent. In Sun's Java SE Runtime Environments, this | |
| 109 | +combination is supported on Windows, but not on Solaris.</P> | |
| 110 | + | |
| 111 | +<H2>Related Documentation</H2> | |
| 112 | + | |
| 113 | +<P>For overviews, tutorials, examples, guides, and tool | |
| 114 | +documentation, please see:</P> | |
| 115 | + | |
| 116 | +<UL> | |
| 117 | + <LI><B><A HREF="../../../../../technotes/guides/imf/overview.html">Input | |
| 118 | + Method Framework Overview</A></B> | |
| 119 | + | |
| 120 | + <LI><B><A HREF="../../../../../technotes/guides/imf/spi-tutorial.html">Input | |
| 121 | + Method Engine SPI Tutorial</A></B> | |
| 122 | +</UL> | |
| 123 | + | |
| 124 | +@since JDK1.3 | |
| 125 | +</BODY> | |
| 126 | +</HTML> | |