001 /*
002 * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package java.awt.im.spi;
027
028 import java.awt.AWTException;
029 import java.awt.Image;
030 import java.util.Locale;
031
032 /**
033 * Defines methods that provide sufficient information about an input method
034 * to enable selection and loading of that input method.
035 * The input method itself is only loaded when it is actually used.
036 *
037 * @since 1.3
038 */
039
040 public interface InputMethodDescriptor {
041
042 /**
043 * Returns the locales supported by the corresponding input method.
044 * The locale may describe just the language, or may also include
045 * country and variant information if needed.
046 * The information is used to select input methods by locale
047 * ({@link java.awt.im.InputContext#selectInputMethod(Locale)}). It may also
048 * be used to sort input methods by locale in a user-visible
049 * list of input methods.
050 * <p>
051 * Only the input method's primary locales should be returned.
052 * For example, if a Japanese input method also has a pass-through
053 * mode for Roman characters, typically still only Japanese would
054 * be returned. Thus, the list of locales returned is typically
055 * a subset of the locales for which the corresponding input method's
056 * implementation of {@link java.awt.im.spi.InputMethod#setLocale} returns true.
057 * <p>
058 * If {@link #hasDynamicLocaleList} returns true, this method is
059 * called each time the information is needed. This
060 * gives input methods that depend on network resources the chance
061 * to add or remove locales as resources become available or
062 * unavailable.
063 *
064 * @return the locales supported by the input method
065 * @exception AWTException if it can be determined that the input method
066 * is inoperable, for example, because of incomplete installation.
067 */
068 Locale[] getAvailableLocales() throws AWTException;
069
070 /**
071 * Returns whether the list of available locales can change
072 * at runtime. This may be the case, for example, for adapters
073 * that access real input methods over the network.
074 */
075 boolean hasDynamicLocaleList();
076
077 /**
078 * Returns the user-visible name of the corresponding
079 * input method for the given input locale in the language in which
080 * the name will be displayed.
081 * <p>
082 * The inputLocale parameter specifies the locale for which text
083 * is input.
084 * This parameter can only take values obtained from this descriptor's
085 * {@link #getAvailableLocales} method or null. If it is null, an
086 * input locale independent name for the input method should be
087 * returned.
088 * <p>
089 * If a name for the desired display language is not available, the
090 * method may fall back to some other language.
091 *
092 * @param inputLocale the locale for which text input is supported, or null
093 * @param displayLanguage the language in which the name will be displayed
094 */
095 String getInputMethodDisplayName(Locale inputLocale,
096 Locale displayLanguage);
097
098 /**
099 * 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 }
|