feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
337
jdkSrc/jdk8/java/awt/im/InputContext.java
Normal file
337
jdkSrc/jdk8/java/awt/im/InputContext.java
Normal file
@@ -0,0 +1,337 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.awt.im;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.util.Locale;
|
||||
import java.awt.AWTEvent;
|
||||
import java.beans.Transient;
|
||||
import java.lang.Character.Subset;
|
||||
import sun.awt.im.InputMethodContext;
|
||||
|
||||
/**
|
||||
* Provides methods to control text input facilities such as input
|
||||
* methods and keyboard layouts.
|
||||
* Two methods handle both input methods and keyboard layouts: selectInputMethod
|
||||
* lets a client component select an input method or keyboard layout by locale,
|
||||
* getLocale lets a client component obtain the locale of the current input method
|
||||
* or keyboard layout.
|
||||
* The other methods more specifically support interaction with input methods:
|
||||
* They let client components control the behavior of input methods, and
|
||||
* dispatch events from the client component to the input method.
|
||||
*
|
||||
* <p>
|
||||
* By default, one InputContext instance is created per Window instance,
|
||||
* and this input context is shared by all components within the window's
|
||||
* container hierarchy. However, this means that only one text input
|
||||
* operation is possible at any one time within a window, and that the
|
||||
* text needs to be committed when moving the focus from one text component
|
||||
* to another. If this is not desired, text components can create their
|
||||
* own input context instances.
|
||||
*
|
||||
* <p>
|
||||
* The Java Platform supports input methods that have been developed in the Java
|
||||
* programming language, using the interfaces in the {@link java.awt.im.spi} package,
|
||||
* and installed into a Java SE Runtime Environment as extensions. Implementations
|
||||
* may also support using the native input methods of the platforms they run on;
|
||||
* however, not all platforms and locales provide input methods. Keyboard layouts
|
||||
* are provided by the host platform.
|
||||
*
|
||||
* <p>
|
||||
* Input methods are <em>unavailable</em> if (a) no input method written
|
||||
* in the Java programming language has been installed and (b) the Java Platform implementation
|
||||
* or the underlying platform does not support native input methods. In this case,
|
||||
* input contexts can still be created and used; their behavior is specified with
|
||||
* the individual methods below.
|
||||
*
|
||||
* @see java.awt.Component#getInputContext
|
||||
* @see java.awt.Component#enableInputMethods
|
||||
* @author JavaSoft Asia/Pacific
|
||||
* @since 1.2
|
||||
*/
|
||||
|
||||
public class InputContext {
|
||||
|
||||
/**
|
||||
* Constructs an InputContext.
|
||||
* This method is protected so clients cannot instantiate
|
||||
* InputContext directly. Input contexts are obtained by
|
||||
* calling {@link #getInstance}.
|
||||
*/
|
||||
protected InputContext() {
|
||||
// real implementation is in sun.awt.im.InputContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new InputContext instance.
|
||||
*/
|
||||
public static InputContext getInstance() {
|
||||
return new sun.awt.im.InputMethodContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to select an input method or keyboard layout that
|
||||
* supports the given locale, and returns a value indicating whether such
|
||||
* an input method or keyboard layout has been successfully selected. The
|
||||
* following steps are taken until an input method has been selected:
|
||||
*
|
||||
* <ul>
|
||||
* <li>
|
||||
* If the currently selected input method or keyboard layout supports the
|
||||
* requested locale, it remains selected.</li>
|
||||
*
|
||||
* <li>
|
||||
* If there is no input method or keyboard layout available that supports
|
||||
* the requested locale, the current input method or keyboard layout remains
|
||||
* selected.</li>
|
||||
*
|
||||
* <li>
|
||||
* If the user has previously selected an input method or keyboard layout
|
||||
* for the requested locale from the user interface, then the most recently
|
||||
* selected such input method or keyboard layout is reselected.</li>
|
||||
*
|
||||
* <li>
|
||||
* Otherwise, an input method or keyboard layout that supports the requested
|
||||
* locale is selected in an implementation dependent way.</li>
|
||||
*
|
||||
* </ul>
|
||||
* Before switching away from an input method, any currently uncommitted text
|
||||
* is committed. If no input method or keyboard layout supporting the requested
|
||||
* locale is available, then false is returned.
|
||||
*
|
||||
* <p>
|
||||
* Not all host operating systems provide API to determine the locale of
|
||||
* the currently selected native input method or keyboard layout, and to
|
||||
* select a native input method or keyboard layout by locale.
|
||||
* For host operating systems that don't provide such API,
|
||||
* <code>selectInputMethod</code> assumes that native input methods or
|
||||
* keyboard layouts provided by the host operating system support only the
|
||||
* system's default locale.
|
||||
*
|
||||
* <p>
|
||||
* A text editing component may call this method, for example, when
|
||||
* the user changes the insertion point, so that the user can
|
||||
* immediately continue typing in the language of the surrounding text.
|
||||
*
|
||||
* @param locale The desired new locale.
|
||||
* @return true if the input method or keyboard layout that's active after
|
||||
* this call supports the desired locale.
|
||||
* @exception NullPointerException if <code>locale</code> is null
|
||||
*/
|
||||
public boolean selectInputMethod(Locale locale) {
|
||||
// real implementation is in sun.awt.im.InputContext
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current locale of the current input method or keyboard
|
||||
* layout.
|
||||
* Returns null if the input context does not have a current input method
|
||||
* or keyboard layout or if the current input method's
|
||||
* {@link java.awt.im.spi.InputMethod#getLocale()} method returns null.
|
||||
*
|
||||
* <p>
|
||||
* Not all host operating systems provide API to determine the locale of
|
||||
* the currently selected native input method or keyboard layout.
|
||||
* For host operating systems that don't provide such API,
|
||||
* <code>getLocale</code> assumes that the current locale of all native
|
||||
* input methods or keyboard layouts provided by the host operating system
|
||||
* is the system's default locale.
|
||||
*
|
||||
* @return the current locale of the current input method or keyboard layout
|
||||
* @since 1.3
|
||||
*/
|
||||
public Locale getLocale() {
|
||||
// real implementation is in sun.awt.im.InputContext
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the subsets of the Unicode character set that input methods of this input
|
||||
* context should be allowed to input. Null may be passed in to
|
||||
* indicate that all characters are allowed. The initial value
|
||||
* is null. The setting applies to the current input method as well
|
||||
* as input methods selected after this call is made. However,
|
||||
* applications cannot rely on this call having the desired effect,
|
||||
* since this setting cannot be passed on to all host input methods -
|
||||
* applications still need to apply their own character validation.
|
||||
* If no input methods are available, then this method has no effect.
|
||||
*
|
||||
* @param subsets The subsets of the Unicode character set from which characters may be input
|
||||
*/
|
||||
public void setCharacterSubsets(Subset[] subsets) {
|
||||
// real implementation is in sun.awt.im.InputContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables the current input method for composition,
|
||||
* depending on the value of the parameter <code>enable</code>.
|
||||
* <p>
|
||||
* An input method that is enabled for composition interprets incoming
|
||||
* events for both composition and control purposes, while a
|
||||
* disabled input method does not interpret events for composition.
|
||||
* Note however that events are passed on to the input method regardless
|
||||
* whether it is enabled or not, and that an input method that is disabled
|
||||
* for composition may still interpret events for control purposes,
|
||||
* including to enable or disable itself for composition.
|
||||
* <p>
|
||||
* For input methods provided by host operating systems, it is not always possible to
|
||||
* determine whether this operation is supported. For example, an input method may enable
|
||||
* composition only for some locales, and do nothing for other locales. For such input
|
||||
* methods, it is possible that this method does not throw
|
||||
* {@link java.lang.UnsupportedOperationException UnsupportedOperationException},
|
||||
* but also does not affect whether composition is enabled.
|
||||
*
|
||||
* @param enable whether to enable the current input method for composition
|
||||
* @throws UnsupportedOperationException if there is no current input
|
||||
* method available or the current input method does not support
|
||||
* the enabling/disabling operation
|
||||
* @see #isCompositionEnabled
|
||||
* @since 1.3
|
||||
*/
|
||||
public void setCompositionEnabled(boolean enable) {
|
||||
// real implementation is in sun.awt.im.InputContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the current input method is enabled for composition.
|
||||
* An input method that is enabled for composition interprets incoming
|
||||
* events for both composition and control purposes, while a
|
||||
* disabled input method does not interpret events for composition.
|
||||
*
|
||||
* @return <code>true</code> if the current input method is enabled for
|
||||
* composition; <code>false</code> otherwise
|
||||
* @throws UnsupportedOperationException if there is no current input
|
||||
* method available or the current input method does not support
|
||||
* checking whether it is enabled for composition
|
||||
* @see #setCompositionEnabled
|
||||
* @since 1.3
|
||||
*/
|
||||
@Transient
|
||||
public boolean isCompositionEnabled() {
|
||||
// real implementation is in sun.awt.im.InputContext
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks the current input method to reconvert text from the
|
||||
* current client component. The input method obtains the text to
|
||||
* be reconverted from the client component using the
|
||||
* {@link InputMethodRequests#getSelectedText InputMethodRequests.getSelectedText}
|
||||
* method. The other <code>InputMethodRequests</code> methods
|
||||
* must be prepared to deal with further information requests by
|
||||
* the input method. The composed and/or committed text will be
|
||||
* sent to the client component as a sequence of
|
||||
* <code>InputMethodEvent</code>s. If the input method cannot
|
||||
* reconvert the given text, the text is returned as committed
|
||||
* text in an <code>InputMethodEvent</code>.
|
||||
*
|
||||
* @throws UnsupportedOperationException if there is no current input
|
||||
* method available or the current input method does not support
|
||||
* the reconversion operation.
|
||||
*
|
||||
* @since 1.3
|
||||
*/
|
||||
public void reconvert() {
|
||||
// real implementation is in sun.awt.im.InputContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an event to the active input method. Called by AWT.
|
||||
* If no input method is available, then the event will never be consumed.
|
||||
*
|
||||
* @param event The event
|
||||
* @exception NullPointerException if <code>event</code> is null
|
||||
*/
|
||||
public void dispatchEvent(AWTEvent event) {
|
||||
// real implementation is in sun.awt.im.InputContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the input context that a client component has been
|
||||
* removed from its containment hierarchy, or that input method
|
||||
* support has been disabled for the component. This method is
|
||||
* usually called from the client component's
|
||||
* {@link java.awt.Component#removeNotify() Component.removeNotify}
|
||||
* method. Potentially pending input from input methods
|
||||
* for this component is discarded.
|
||||
* If no input methods are available, then this method has no effect.
|
||||
*
|
||||
* @param client Client component
|
||||
* @exception NullPointerException if <code>client</code> is null
|
||||
*/
|
||||
public void removeNotify(Component client) {
|
||||
// real implementation is in sun.awt.im.InputContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends any input composition that may currently be going on in this
|
||||
* context. Depending on the platform and possibly user preferences,
|
||||
* this may commit or delete uncommitted text. Any changes to the text
|
||||
* are communicated to the active component using an input method event.
|
||||
* If no input methods are available, then this method has no effect.
|
||||
*
|
||||
* <p>
|
||||
* A text editing component may call this in a variety of situations,
|
||||
* for example, when the user moves the insertion point within the text
|
||||
* (but outside the composed text), or when the component's text is
|
||||
* saved to a file or copied to the clipboard.
|
||||
*
|
||||
*/
|
||||
public void endComposition() {
|
||||
// real implementation is in sun.awt.im.InputContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases the resources used by this input context.
|
||||
* Called by AWT for the default input context of each Window.
|
||||
* If no input methods are available, then this method
|
||||
* has no effect.
|
||||
*/
|
||||
public void dispose() {
|
||||
// real implementation is in sun.awt.im.InputContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a control object from the current input method, or null. A
|
||||
* control object provides methods that control the behavior of the
|
||||
* input method or obtain information from the input method. The type
|
||||
* of the object is an input method specific class. Clients have to
|
||||
* compare the result against known input method control object
|
||||
* classes and cast to the appropriate class to invoke the methods
|
||||
* provided.
|
||||
* <p>
|
||||
* If no input methods are available or the current input method does
|
||||
* not provide an input method control object, then null is returned.
|
||||
*
|
||||
* @return A control object from the current input method, or null.
|
||||
*/
|
||||
public Object getInputMethodControlObject() {
|
||||
// real implementation is in sun.awt.im.InputContext
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
195
jdkSrc/jdk8/java/awt/im/InputMethodHighlight.java
Normal file
195
jdkSrc/jdk8/java/awt/im/InputMethodHighlight.java
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.awt.im;
|
||||
|
||||
import java.awt.font.TextAttribute;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An InputMethodHighlight is used to describe the highlight
|
||||
* attributes of text being composed.
|
||||
* The description can be at two levels:
|
||||
* at the abstract level it specifies the conversion state and whether the
|
||||
* text is selected; at the concrete level it specifies style attributes used
|
||||
* to render the highlight.
|
||||
* An InputMethodHighlight must provide the description at the
|
||||
* abstract level; it may or may not provide the description at the concrete
|
||||
* level.
|
||||
* If no concrete style is provided, a renderer should use
|
||||
* {@link java.awt.Toolkit#mapInputMethodHighlight} to map to a concrete style.
|
||||
* <p>
|
||||
* The abstract description consists of three fields: <code>selected</code>,
|
||||
* <code>state</code>, and <code>variation</code>.
|
||||
* <code>selected</code> indicates whether the text range is the one that the
|
||||
* input method is currently working on, for example, the segment for which
|
||||
* conversion candidates are currently shown in a menu.
|
||||
* <code>state</code> represents the conversion state. State values are defined
|
||||
* by the input method framework and should be distinguished in all
|
||||
* mappings from abstract to concrete styles. Currently defined state values
|
||||
* are raw (unconverted) and converted.
|
||||
* These state values are recommended for use before and after the
|
||||
* main conversion step of text composition, say, before and after kana->kanji
|
||||
* or pinyin->hanzi conversion.
|
||||
* The <code>variation</code> field allows input methods to express additional
|
||||
* information about the conversion results.
|
||||
* <p>
|
||||
*
|
||||
* InputMethodHighlight instances are typically used as attribute values
|
||||
* returned from AttributedCharacterIterator for the INPUT_METHOD_HIGHLIGHT
|
||||
* attribute. They may be wrapped into {@link java.text.Annotation Annotation}
|
||||
* instances to indicate separate text segments.
|
||||
*
|
||||
* @see java.text.AttributedCharacterIterator
|
||||
* @since 1.2
|
||||
*/
|
||||
|
||||
public class InputMethodHighlight {
|
||||
|
||||
/**
|
||||
* Constant for the raw text state.
|
||||
*/
|
||||
public final static int RAW_TEXT = 0;
|
||||
|
||||
/**
|
||||
* Constant for the converted text state.
|
||||
*/
|
||||
public final static int CONVERTED_TEXT = 1;
|
||||
|
||||
|
||||
/**
|
||||
* Constant for the default highlight for unselected raw text.
|
||||
*/
|
||||
public final static InputMethodHighlight UNSELECTED_RAW_TEXT_HIGHLIGHT =
|
||||
new InputMethodHighlight(false, RAW_TEXT);
|
||||
|
||||
/**
|
||||
* Constant for the default highlight for selected raw text.
|
||||
*/
|
||||
public final static InputMethodHighlight SELECTED_RAW_TEXT_HIGHLIGHT =
|
||||
new InputMethodHighlight(true, RAW_TEXT);
|
||||
|
||||
/**
|
||||
* Constant for the default highlight for unselected converted text.
|
||||
*/
|
||||
public final static InputMethodHighlight UNSELECTED_CONVERTED_TEXT_HIGHLIGHT =
|
||||
new InputMethodHighlight(false, CONVERTED_TEXT);
|
||||
|
||||
/**
|
||||
* Constant for the default highlight for selected converted text.
|
||||
*/
|
||||
public final static InputMethodHighlight SELECTED_CONVERTED_TEXT_HIGHLIGHT =
|
||||
new InputMethodHighlight(true, CONVERTED_TEXT);
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an input method highlight record.
|
||||
* The variation is set to 0, the style to null.
|
||||
* @param selected Whether the text range is selected
|
||||
* @param state The conversion state for the text range - RAW_TEXT or CONVERTED_TEXT
|
||||
* @see InputMethodHighlight#RAW_TEXT
|
||||
* @see InputMethodHighlight#CONVERTED_TEXT
|
||||
* @exception IllegalArgumentException if a state other than RAW_TEXT or CONVERTED_TEXT is given
|
||||
*/
|
||||
public InputMethodHighlight(boolean selected, int state) {
|
||||
this(selected, state, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an input method highlight record.
|
||||
* The style is set to null.
|
||||
* @param selected Whether the text range is selected
|
||||
* @param state The conversion state for the text range - RAW_TEXT or CONVERTED_TEXT
|
||||
* @param variation The style variation for the text range
|
||||
* @see InputMethodHighlight#RAW_TEXT
|
||||
* @see InputMethodHighlight#CONVERTED_TEXT
|
||||
* @exception IllegalArgumentException if a state other than RAW_TEXT or CONVERTED_TEXT is given
|
||||
*/
|
||||
public InputMethodHighlight(boolean selected, int state, int variation) {
|
||||
this(selected, state, variation, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an input method highlight record.
|
||||
* The style attributes map provided must be unmodifiable.
|
||||
* @param selected whether the text range is selected
|
||||
* @param state the conversion state for the text range - RAW_TEXT or CONVERTED_TEXT
|
||||
* @param variation the variation for the text range
|
||||
* @param style the rendering style attributes for the text range, or null
|
||||
* @see InputMethodHighlight#RAW_TEXT
|
||||
* @see InputMethodHighlight#CONVERTED_TEXT
|
||||
* @exception IllegalArgumentException if a state other than RAW_TEXT or CONVERTED_TEXT is given
|
||||
* @since 1.3
|
||||
*/
|
||||
public InputMethodHighlight(boolean selected, int state, int variation,
|
||||
Map<TextAttribute,?> style)
|
||||
{
|
||||
this.selected = selected;
|
||||
if (!(state == RAW_TEXT || state == CONVERTED_TEXT)) {
|
||||
throw new IllegalArgumentException("unknown input method highlight state");
|
||||
}
|
||||
this.state = state;
|
||||
this.variation = variation;
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the text range is selected.
|
||||
*/
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the conversion state of the text range.
|
||||
* @return The conversion state for the text range - RAW_TEXT or CONVERTED_TEXT.
|
||||
* @see InputMethodHighlight#RAW_TEXT
|
||||
* @see InputMethodHighlight#CONVERTED_TEXT
|
||||
*/
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the variation of the text range.
|
||||
*/
|
||||
public int getVariation() {
|
||||
return variation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rendering style attributes for the text range, or null.
|
||||
* @since 1.3
|
||||
*/
|
||||
public Map<TextAttribute,?> getStyle() {
|
||||
return style;
|
||||
}
|
||||
|
||||
private boolean selected;
|
||||
private int state;
|
||||
private int variation;
|
||||
private Map<TextAttribute, ?> style;
|
||||
|
||||
};
|
||||
208
jdkSrc/jdk8/java/awt/im/InputMethodRequests.java
Normal file
208
jdkSrc/jdk8/java/awt/im/InputMethodRequests.java
Normal file
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.awt.im;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.font.TextHitInfo;
|
||||
import java.text.AttributedCharacterIterator;
|
||||
import java.text.AttributedCharacterIterator.Attribute;
|
||||
|
||||
/**
|
||||
* InputMethodRequests defines the requests that a text editing component
|
||||
* has to handle in order to work with input methods. The component
|
||||
* can implement this interface itself or use a separate object that
|
||||
* implements it. The object implementing this interface must be returned
|
||||
* from the component's getInputMethodRequests method.
|
||||
*
|
||||
* <p>
|
||||
* The text editing component also has to provide an input method event
|
||||
* listener.
|
||||
*
|
||||
* <p>
|
||||
* The interface is designed to support one of two input user interfaces:
|
||||
* <ul>
|
||||
* <li><em>on-the-spot</em> input, where the composed text is displayed as part
|
||||
* of the text component's text body.
|
||||
* <li><em>below-the-spot</em> input, where the composed text is displayed in
|
||||
* a separate composition window just below the insertion point where
|
||||
* the text will be inserted when it is committed. Note that, if text is
|
||||
* selected within the component's text body, this text will be replaced by
|
||||
* the committed text upon commitment; therefore it is not considered part
|
||||
* of the context that the text is input into.
|
||||
* </ul>
|
||||
*
|
||||
* @see java.awt.Component#getInputMethodRequests
|
||||
* @see java.awt.event.InputMethodListener
|
||||
*
|
||||
* @author JavaSoft Asia/Pacific
|
||||
* @since 1.2
|
||||
*/
|
||||
|
||||
public interface InputMethodRequests {
|
||||
|
||||
/**
|
||||
* Gets the location of a specified offset in the current composed text,
|
||||
* or of the selection in committed text.
|
||||
* This information is, for example, used to position the candidate window
|
||||
* near the composed text, or a composition window near the location
|
||||
* where committed text will be inserted.
|
||||
*
|
||||
* <p>
|
||||
* If the component has composed text (because the most recent
|
||||
* InputMethodEvent sent to it contained composed text), then the offset is
|
||||
* relative to the composed text - offset 0 indicates the first character
|
||||
* in the composed text. The location returned should be for this character.
|
||||
*
|
||||
* <p>
|
||||
* If the component doesn't have composed text, the offset should be ignored,
|
||||
* and the location returned should reflect the beginning (in line
|
||||
* direction) of the highlight in the last line containing selected text.
|
||||
* For example, for horizontal left-to-right text (such as English), the
|
||||
* location to the left of the left-most character on the last line
|
||||
* containing selected text is returned. For vertical top-to-bottom text,
|
||||
* with lines proceeding from right to left, the location to the top of the
|
||||
* left-most line containing selected text is returned.
|
||||
*
|
||||
* <p>
|
||||
* The location is represented as a 0-thickness caret, that is, it has 0
|
||||
* width if the text is drawn horizontally, and 0 height if the text is
|
||||
* drawn vertically. Other text orientations need to be mapped to
|
||||
* horizontal or vertical orientation. The rectangle uses absolute screen
|
||||
* coordinates.
|
||||
*
|
||||
* @param offset the offset within the composed text, if there is composed
|
||||
* text; null otherwise
|
||||
* @return a rectangle representing the screen location of the offset
|
||||
*/
|
||||
Rectangle getTextLocation(TextHitInfo offset);
|
||||
|
||||
/**
|
||||
* Gets the offset within the composed text for the specified absolute x
|
||||
* and y coordinates on the screen. This information is used, for example
|
||||
* to handle mouse clicks and the mouse cursor. The offset is relative to
|
||||
* the composed text, so offset 0 indicates the beginning of the composed
|
||||
* text.
|
||||
*
|
||||
* <p>
|
||||
* Return null if the location is outside the area occupied by the composed
|
||||
* text.
|
||||
*
|
||||
* @param x the absolute x coordinate on screen
|
||||
* @param y the absolute y coordinate on screen
|
||||
* @return a text hit info describing the offset in the composed text.
|
||||
*/
|
||||
TextHitInfo getLocationOffset(int x, int y);
|
||||
|
||||
/**
|
||||
* Gets the offset of the insert position in the committed text contained
|
||||
* in the text editing component. This is the offset at which characters
|
||||
* entered through an input method are inserted. This information is used
|
||||
* by an input method, for example, to examine the text surrounding the
|
||||
* insert position.
|
||||
*
|
||||
* @return the offset of the insert position
|
||||
*/
|
||||
int getInsertPositionOffset();
|
||||
|
||||
/**
|
||||
* Gets an iterator providing access to the entire text and attributes
|
||||
* contained in the text editing component except for uncommitted
|
||||
* text. Uncommitted (composed) text should be ignored for index
|
||||
* calculations and should not be made accessible through the iterator.
|
||||
*
|
||||
* <p>
|
||||
* The input method may provide a list of attributes that it is
|
||||
* interested in. In that case, information about other attributes that
|
||||
* the implementor may have need not be made accessible through the
|
||||
* iterator. If the list is null, all available attribute information
|
||||
* should be made accessible.
|
||||
*
|
||||
* @param beginIndex the index of the first character
|
||||
* @param endIndex the index of the character following the last character
|
||||
* @param attributes a list of attributes that the input method is
|
||||
* interested in
|
||||
* @return an iterator providing access to the text and its attributes
|
||||
*/
|
||||
AttributedCharacterIterator getCommittedText(int beginIndex, int endIndex,
|
||||
Attribute[] attributes);
|
||||
|
||||
/**
|
||||
* Gets the length of the entire text contained in the text
|
||||
* editing component except for uncommitted (composed) text.
|
||||
*
|
||||
* @return the length of the text except for uncommitted text
|
||||
*/
|
||||
int getCommittedTextLength();
|
||||
|
||||
/**
|
||||
* Gets the latest committed text from the text editing component and
|
||||
* removes it from the component's text body.
|
||||
* This is used for the "Undo Commit" feature in some input methods, where
|
||||
* the committed text reverts to its previous composed state. The composed
|
||||
* text will be sent to the component using an InputMethodEvent.
|
||||
*
|
||||
* <p>
|
||||
* Generally, this feature should only be supported immediately after the
|
||||
* text was committed, not after the user performed other operations on the
|
||||
* text. When the feature is not supported, return null.
|
||||
*
|
||||
* <p>
|
||||
* The input method may provide a list of attributes that it is
|
||||
* interested in. In that case, information about other attributes that
|
||||
* the implementor may have need not be made accessible through the
|
||||
* iterator. If the list is null, all available attribute information
|
||||
* should be made accessible.
|
||||
*
|
||||
* @param attributes a list of attributes that the input method is
|
||||
* interested in
|
||||
* @return the latest committed text, or null when the "Undo Commit"
|
||||
* feature is not supported
|
||||
*/
|
||||
AttributedCharacterIterator cancelLatestCommittedText(Attribute[] attributes);
|
||||
|
||||
/**
|
||||
* Gets the currently selected text from the text editing component.
|
||||
* This may be used for a variety of purposes.
|
||||
* One of them is the "Reconvert" feature in some input methods.
|
||||
* In this case, the input method will typically send an input method event
|
||||
* to replace the selected text with composed text. Depending on the input
|
||||
* method's capabilities, this may be the original composed text for the
|
||||
* selected text, the latest composed text entered anywhere in the text, or
|
||||
* a version of the text that's converted back from the selected text.
|
||||
*
|
||||
* <p>
|
||||
* The input method may provide a list of attributes that it is
|
||||
* interested in. In that case, information about other attributes that
|
||||
* the implementor may have need not be made accessible through the
|
||||
* iterator. If the list is null, all available attribute information
|
||||
* should be made accessible.
|
||||
*
|
||||
* @param attributes a list of attributes that the input method is
|
||||
* interested in
|
||||
* @return the currently selected text
|
||||
*/
|
||||
AttributedCharacterIterator getSelectedText(Attribute[] attributes);
|
||||
}
|
||||
114
jdkSrc/jdk8/java/awt/im/InputSubset.java
Normal file
114
jdkSrc/jdk8/java/awt/im/InputSubset.java
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.awt.im;
|
||||
|
||||
|
||||
/**
|
||||
* Defines additional Unicode subsets for use by input methods. Unlike the
|
||||
* UnicodeBlock subsets defined in the <code>{@link
|
||||
* java.lang.Character.UnicodeBlock}</code> class, these constants do not
|
||||
* directly correspond to Unicode code blocks.
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
|
||||
public final class InputSubset extends Character.Subset {
|
||||
|
||||
private InputSubset(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constant for all Latin characters, including the characters
|
||||
* in the BASIC_LATIN, LATIN_1_SUPPLEMENT, LATIN_EXTENDED_A,
|
||||
* LATIN_EXTENDED_B Unicode character blocks.
|
||||
*/
|
||||
public static final InputSubset LATIN
|
||||
= new InputSubset("LATIN");
|
||||
|
||||
/**
|
||||
* Constant for the digits included in the BASIC_LATIN Unicode character
|
||||
* block.
|
||||
*/
|
||||
public static final InputSubset LATIN_DIGITS
|
||||
= new InputSubset("LATIN_DIGITS");
|
||||
|
||||
/**
|
||||
* Constant for all Han characters used in writing Traditional Chinese,
|
||||
* including a subset of the CJK unified ideographs as well as Traditional
|
||||
* Chinese Han characters that may be defined as surrogate characters.
|
||||
*/
|
||||
public static final InputSubset TRADITIONAL_HANZI
|
||||
= new InputSubset("TRADITIONAL_HANZI");
|
||||
|
||||
/**
|
||||
* Constant for all Han characters used in writing Simplified Chinese,
|
||||
* including a subset of the CJK unified ideographs as well as Simplified
|
||||
* Chinese Han characters that may be defined as surrogate characters.
|
||||
*/
|
||||
public static final InputSubset SIMPLIFIED_HANZI
|
||||
= new InputSubset("SIMPLIFIED_HANZI");
|
||||
|
||||
/**
|
||||
* Constant for all Han characters used in writing Japanese, including a
|
||||
* subset of the CJK unified ideographs as well as Japanese Han characters
|
||||
* that may be defined as surrogate characters.
|
||||
*/
|
||||
public static final InputSubset KANJI
|
||||
= new InputSubset("KANJI");
|
||||
|
||||
/**
|
||||
* Constant for all Han characters used in writing Korean, including a
|
||||
* subset of the CJK unified ideographs as well as Korean Han characters
|
||||
* that may be defined as surrogate characters.
|
||||
*/
|
||||
public static final InputSubset HANJA
|
||||
= new InputSubset("HANJA");
|
||||
|
||||
/**
|
||||
* Constant for the halfwidth katakana subset of the Unicode halfwidth and
|
||||
* fullwidth forms character block.
|
||||
*/
|
||||
public static final InputSubset HALFWIDTH_KATAKANA
|
||||
= new InputSubset("HALFWIDTH_KATAKANA");
|
||||
|
||||
/**
|
||||
* Constant for the fullwidth ASCII variants subset of the Unicode halfwidth and
|
||||
* fullwidth forms character block.
|
||||
* @since 1.3
|
||||
*/
|
||||
public static final InputSubset FULLWIDTH_LATIN
|
||||
= new InputSubset("FULLWIDTH_LATIN");
|
||||
|
||||
/**
|
||||
* Constant for the fullwidth digits included in the Unicode halfwidth and
|
||||
* fullwidth forms character block.
|
||||
* @since 1.3
|
||||
*/
|
||||
public static final InputSubset FULLWIDTH_DIGITS
|
||||
= new InputSubset("FULLWIDTH_DIGITS");
|
||||
|
||||
}
|
||||
382
jdkSrc/jdk8/java/awt/im/spi/InputMethod.java
Normal file
382
jdkSrc/jdk8/java/awt/im/spi/InputMethod.java
Normal file
@@ -0,0 +1,382 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.awt.im.spi;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Rectangle;
|
||||
import java.lang.Character.Subset;
|
||||
|
||||
|
||||
/**
|
||||
* Defines the interface for an input method that supports complex text input.
|
||||
* Input methods traditionally support text input for languages that have
|
||||
* more characters than can be represented on a standard-size keyboard,
|
||||
* such as Chinese, Japanese, and Korean. However, they may also be used to
|
||||
* support phonetic text input for English or character reordering for Thai.
|
||||
* <p>
|
||||
* Subclasses of InputMethod can be loaded by the input method framework; they
|
||||
* can then be selected either through the API
|
||||
* ({@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod})
|
||||
* or the user interface (the input method selection menu).
|
||||
*
|
||||
* @since 1.3
|
||||
*
|
||||
* @author JavaSoft International
|
||||
*/
|
||||
|
||||
public interface InputMethod {
|
||||
|
||||
/**
|
||||
* Sets the input method context, which is used to dispatch input method
|
||||
* events to the client component and to request information from
|
||||
* the client component.
|
||||
* <p>
|
||||
* This method is called once immediately after instantiating this input
|
||||
* method.
|
||||
*
|
||||
* @param context the input method context for this input method
|
||||
* @exception NullPointerException if <code>context</code> is null
|
||||
*/
|
||||
public void setInputMethodContext(InputMethodContext context);
|
||||
|
||||
/**
|
||||
* Attempts to set the input locale. If the input method supports the
|
||||
* desired locale, it changes its behavior to support input for the locale
|
||||
* and returns true.
|
||||
* Otherwise, it returns false and does not change its behavior.
|
||||
* <p>
|
||||
* This method is called
|
||||
* <ul>
|
||||
* <li>by {@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod},
|
||||
* <li>when switching to this input method through the user interface if the user
|
||||
* specified a locale or if the previously selected input method's
|
||||
* {@link java.awt.im.spi.InputMethod#getLocale getLocale} method
|
||||
* returns a non-null value.
|
||||
* </ul>
|
||||
*
|
||||
* @param locale locale to input
|
||||
* @return whether the specified locale is supported
|
||||
* @exception NullPointerException if <code>locale</code> is null
|
||||
*/
|
||||
public boolean setLocale(Locale locale);
|
||||
|
||||
/**
|
||||
* Returns the current input locale. Might return null in exceptional cases.
|
||||
* <p>
|
||||
* This method is called
|
||||
* <ul>
|
||||
* <li>by {@link java.awt.im.InputContext#getLocale InputContext.getLocale} and
|
||||
* <li>when switching from this input method to a different one through the
|
||||
* user interface.
|
||||
* </ul>
|
||||
*
|
||||
* @return the current input locale, or null
|
||||
*/
|
||||
public Locale getLocale();
|
||||
|
||||
/**
|
||||
* Sets the subsets of the Unicode character set that this input method
|
||||
* is allowed to input. Null may be passed in to indicate that all
|
||||
* characters are allowed.
|
||||
* <p>
|
||||
* This method is called
|
||||
* <ul>
|
||||
* <li>immediately after instantiating this input method,
|
||||
* <li>when switching to this input method from a different one, and
|
||||
* <li>by {@link java.awt.im.InputContext#setCharacterSubsets InputContext.setCharacterSubsets}.
|
||||
* </ul>
|
||||
*
|
||||
* @param subsets the subsets of the Unicode character set from which
|
||||
* characters may be input
|
||||
*/
|
||||
public void setCharacterSubsets(Subset[] subsets);
|
||||
|
||||
/**
|
||||
* Enables or disables this input method for composition,
|
||||
* depending on the value of the parameter <code>enable</code>.
|
||||
* <p>
|
||||
* An input method that is enabled for composition interprets incoming
|
||||
* events for both composition and control purposes, while a
|
||||
* disabled input method does not interpret events for composition.
|
||||
* Note however that events are passed on to the input method regardless
|
||||
* whether it is enabled or not, and that an input method that is disabled
|
||||
* for composition may still interpret events for control purposes,
|
||||
* including to enable or disable itself for composition.
|
||||
* <p>
|
||||
* For input methods provided by host operating systems, it is not always possible to
|
||||
* determine whether this operation is supported. For example, an input method may enable
|
||||
* composition only for some locales, and do nothing for other locales. For such input
|
||||
* methods, it is possible that this method does not throw
|
||||
* {@link java.lang.UnsupportedOperationException UnsupportedOperationException},
|
||||
* but also does not affect whether composition is enabled.
|
||||
* <p>
|
||||
* This method is called
|
||||
* <ul>
|
||||
* <li>by {@link java.awt.im.InputContext#setCompositionEnabled InputContext.setCompositionEnabled},
|
||||
* <li>when switching to this input method from a different one using the
|
||||
* user interface or
|
||||
* {@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod},
|
||||
* if the previously selected input method's
|
||||
* {@link java.awt.im.spi.InputMethod#isCompositionEnabled isCompositionEnabled}
|
||||
* method returns without throwing an exception.
|
||||
* </ul>
|
||||
*
|
||||
* @param enable whether to enable the input method for composition
|
||||
* @throws UnsupportedOperationException if this input method does not
|
||||
* support the enabling/disabling operation
|
||||
* @see #isCompositionEnabled
|
||||
*/
|
||||
public void setCompositionEnabled(boolean enable);
|
||||
|
||||
/**
|
||||
* Determines whether this input method is enabled.
|
||||
* An input method that is enabled for composition interprets incoming
|
||||
* events for both composition and control purposes, while a
|
||||
* disabled input method does not interpret events for composition.
|
||||
* <p>
|
||||
* This method is called
|
||||
* <ul>
|
||||
* <li>by {@link java.awt.im.InputContext#isCompositionEnabled InputContext.isCompositionEnabled} and
|
||||
* <li>when switching from this input method to a different one using the
|
||||
* user interface or
|
||||
* {@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod}.
|
||||
* </ul>
|
||||
*
|
||||
* @return <code>true</code> if this input method is enabled for
|
||||
* composition; <code>false</code> otherwise.
|
||||
* @throws UnsupportedOperationException if this input method does not
|
||||
* support checking whether it is enabled for composition
|
||||
* @see #setCompositionEnabled
|
||||
*/
|
||||
public boolean isCompositionEnabled();
|
||||
|
||||
/**
|
||||
* Starts the reconversion operation. The input method obtains the
|
||||
* text to be reconverted from the current client component using the
|
||||
* {@link java.awt.im.InputMethodRequests#getSelectedText InputMethodRequests.getSelectedText}
|
||||
* method. It can use other <code>InputMethodRequests</code>
|
||||
* methods to request additional information required for the
|
||||
* reconversion operation. The composed and committed text
|
||||
* produced by the operation is sent to the client component as a
|
||||
* sequence of <code>InputMethodEvent</code>s. If the given text
|
||||
* cannot be reconverted, the same text should be sent to the
|
||||
* client component as committed text.
|
||||
* <p>
|
||||
* This method is called by
|
||||
* {@link java.awt.im.InputContext#reconvert() InputContext.reconvert}.
|
||||
*
|
||||
* @throws UnsupportedOperationException if the input method does not
|
||||
* support the reconversion operation.
|
||||
*/
|
||||
public void reconvert();
|
||||
|
||||
/**
|
||||
* Dispatches the event to the input method. If input method support is
|
||||
* enabled for the focussed component, incoming events of certain types
|
||||
* are dispatched to the current input method for this component before
|
||||
* they are dispatched to the component's methods or event listeners.
|
||||
* The input method decides whether it needs to handle the event. If it
|
||||
* does, it also calls the event's <code>consume</code> method; this
|
||||
* causes the event to not get dispatched to the component's event
|
||||
* processing methods or event listeners.
|
||||
* <p>
|
||||
* Events are dispatched if they are instances of InputEvent or its
|
||||
* subclasses.
|
||||
* This includes instances of the AWT classes KeyEvent and MouseEvent.
|
||||
* <p>
|
||||
* This method is called by {@link java.awt.im.InputContext#dispatchEvent InputContext.dispatchEvent}.
|
||||
*
|
||||
* @param event the event being dispatched to the input method
|
||||
* @exception NullPointerException if <code>event</code> is null
|
||||
*/
|
||||
public void dispatchEvent(AWTEvent event);
|
||||
|
||||
/**
|
||||
* Notifies this input method of changes in the client window
|
||||
* location or state. This method is called while this input
|
||||
* method is the current input method of its input context and
|
||||
* notifications for it are enabled (see {@link
|
||||
* InputMethodContext#enableClientWindowNotification
|
||||
* InputMethodContext.enableClientWindowNotification}). Calls
|
||||
* to this method are temporarily suspended if the input context's
|
||||
* {@link java.awt.im.InputContext#removeNotify removeNotify}
|
||||
* method is called, and resume when the input method is activated
|
||||
* for a new client component. It is called in the following
|
||||
* situations:
|
||||
* <ul>
|
||||
* <li>
|
||||
* when the window containing the current client component changes
|
||||
* in location, size, visibility, iconification state, or when the
|
||||
* window is closed.</li>
|
||||
* <li>
|
||||
* from <code> enableClientWindowNotification(inputMethod,
|
||||
* true)</code> if the current client component exists,</li>
|
||||
* <li>
|
||||
* when activating the input method for the first time after it
|
||||
* called
|
||||
* <code>enableClientWindowNotification(inputMethod,
|
||||
* true)</code> if during the call no current client component was
|
||||
* available,</li>
|
||||
* <li>
|
||||
* when activating the input method for a new client component
|
||||
* after the input context's removeNotify method has been
|
||||
* called.</li>
|
||||
* </ul>
|
||||
* @param bounds client window's {@link
|
||||
* java.awt.Component#getBounds bounds} on the screen; or null if
|
||||
* the client window is iconified or invisible
|
||||
*/
|
||||
public void notifyClientWindowChange(Rectangle bounds);
|
||||
|
||||
/**
|
||||
* Activates the input method for immediate input processing.
|
||||
* <p>
|
||||
* If an input method provides its own windows, it should make sure
|
||||
* at this point that all necessary windows are open and visible.
|
||||
* <p>
|
||||
* This method is called
|
||||
* <ul>
|
||||
* <li>by {@link java.awt.im.InputContext#dispatchEvent InputContext.dispatchEvent}
|
||||
* when a client component receives a FOCUS_GAINED event,
|
||||
* <li>when switching to this input method from a different one using the
|
||||
* user interface or
|
||||
* {@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod}.
|
||||
* </ul>
|
||||
* The method is only called when the input method is inactive.
|
||||
* A newly instantiated input method is assumed to be inactive.
|
||||
*/
|
||||
public void activate();
|
||||
|
||||
/**
|
||||
* Deactivates the input method.
|
||||
* The isTemporary argument has the same meaning as in
|
||||
* {@link java.awt.event.FocusEvent#isTemporary FocusEvent.isTemporary}.
|
||||
* <p>
|
||||
* If an input method provides its own windows, only windows that relate
|
||||
* to the current composition (such as a lookup choice window) should be
|
||||
* closed at this point.
|
||||
* It is possible that the input method will be immediately activated again
|
||||
* for a different client component, and closing and reopening more
|
||||
* persistent windows (such as a control panel) would create unnecessary
|
||||
* screen flicker.
|
||||
* Before an instance of a different input method class is activated,
|
||||
* {@link #hideWindows} is called on the current input method.
|
||||
* <p>
|
||||
* This method is called
|
||||
* <ul>
|
||||
* <li>by {@link java.awt.im.InputContext#dispatchEvent InputContext.dispatchEvent}
|
||||
* when a client component receives a FOCUS_LOST event,
|
||||
* <li>when switching from this input method to a different one using the
|
||||
* user interface or
|
||||
* {@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod},
|
||||
* <li>before {@link #removeNotify removeNotify} if the current client component is
|
||||
* removed.
|
||||
* </ul>
|
||||
* The method is only called when the input method is active.
|
||||
*
|
||||
* @param isTemporary whether the focus change is temporary
|
||||
*/
|
||||
public void deactivate(boolean isTemporary);
|
||||
|
||||
/**
|
||||
* Closes or hides all windows opened by this input method instance or
|
||||
* its class.
|
||||
* <p>
|
||||
* This method is called
|
||||
* <ul>
|
||||
* <li>before calling {@link #activate activate} on an instance of a different input
|
||||
* method class,
|
||||
* <li>before calling {@link #dispose dispose} on this input method.
|
||||
* </ul>
|
||||
* The method is only called when the input method is inactive.
|
||||
*/
|
||||
public void hideWindows();
|
||||
|
||||
/**
|
||||
* Notifies the input method that a client component has been
|
||||
* removed from its containment hierarchy, or that input method
|
||||
* support has been disabled for the component.
|
||||
* <p>
|
||||
* This method is called by {@link java.awt.im.InputContext#removeNotify InputContext.removeNotify}.
|
||||
* <p>
|
||||
* The method is only called when the input method is inactive.
|
||||
*/
|
||||
public void removeNotify();
|
||||
|
||||
/**
|
||||
* Ends any input composition that may currently be going on in this
|
||||
* context. Depending on the platform and possibly user preferences,
|
||||
* this may commit or delete uncommitted text. Any changes to the text
|
||||
* are communicated to the active component using an input method event.
|
||||
*
|
||||
* <p>
|
||||
* A text editing component may call this in a variety of situations,
|
||||
* for example, when the user moves the insertion point within the text
|
||||
* (but outside the composed text), or when the component's text is
|
||||
* saved to a file or copied to the clipboard.
|
||||
* <p>
|
||||
* This method is called
|
||||
* <ul>
|
||||
* <li>by {@link java.awt.im.InputContext#endComposition InputContext.endComposition},
|
||||
* <li>by {@link java.awt.im.InputContext#dispatchEvent InputContext.dispatchEvent}
|
||||
* when switching to a different client component
|
||||
* <li>when switching from this input method to a different one using the
|
||||
* user interface or
|
||||
* {@link java.awt.im.InputContext#selectInputMethod InputContext.selectInputMethod}.
|
||||
* </ul>
|
||||
*/
|
||||
public void endComposition();
|
||||
|
||||
/**
|
||||
* Releases the resources used by this input method.
|
||||
* In particular, the input method should dispose windows and close files that are no
|
||||
* longer needed.
|
||||
* <p>
|
||||
* This method is called by {@link java.awt.im.InputContext#dispose InputContext.dispose}.
|
||||
* <p>
|
||||
* The method is only called when the input method is inactive.
|
||||
* No method of this interface is called on this instance after dispose.
|
||||
*/
|
||||
public void dispose();
|
||||
|
||||
/**
|
||||
* Returns a control object from this input method, or null. A
|
||||
* control object provides methods that control the behavior of the
|
||||
* input method or obtain information from the input method. The type
|
||||
* of the object is an input method specific class. Clients have to
|
||||
* compare the result against known input method control object
|
||||
* classes and cast to the appropriate class to invoke the methods
|
||||
* provided.
|
||||
* <p>
|
||||
* This method is called by
|
||||
* {@link java.awt.im.InputContext#getInputMethodControlObject InputContext.getInputMethodControlObject}.
|
||||
*
|
||||
* @return a control object from this input method, or null
|
||||
*/
|
||||
public Object getControlObject();
|
||||
|
||||
}
|
||||
140
jdkSrc/jdk8/java/awt/im/spi/InputMethodContext.java
Normal file
140
jdkSrc/jdk8/java/awt/im/spi/InputMethodContext.java
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.awt.im.spi;
|
||||
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.Window;
|
||||
import java.awt.font.TextHitInfo;
|
||||
import java.awt.im.InputMethodRequests;
|
||||
import java.text.AttributedCharacterIterator;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
/**
|
||||
* Provides methods that input methods
|
||||
* can use to communicate with their client components or to request
|
||||
* other services. This interface is implemented by the input method
|
||||
* framework, and input methods call its methods on the instance they
|
||||
* receive through
|
||||
* {@link java.awt.im.spi.InputMethod#setInputMethodContext}.
|
||||
* There should be no other implementors or callers.
|
||||
*
|
||||
* @since 1.3
|
||||
*
|
||||
* @author JavaSoft International
|
||||
*/
|
||||
|
||||
public interface InputMethodContext extends InputMethodRequests {
|
||||
|
||||
/**
|
||||
* Creates an input method event from the arguments given
|
||||
* and dispatches it to the client component. For arguments,
|
||||
* see {@link java.awt.event.InputMethodEvent#InputMethodEvent}.
|
||||
*/
|
||||
public void dispatchInputMethodEvent(int id,
|
||||
AttributedCharacterIterator text, int committedCharacterCount,
|
||||
TextHitInfo caret, TextHitInfo visiblePosition);
|
||||
|
||||
/**
|
||||
* Creates a top-level window for use by the input method.
|
||||
* The intended behavior of this window is:
|
||||
* <ul>
|
||||
* <li>it floats above all document windows and dialogs
|
||||
* <li>it and all components that it contains do not receive the focus
|
||||
* <li>it has lightweight decorations, such as a reduced drag region without title
|
||||
* </ul>
|
||||
* However, the actual behavior with respect to these three items is platform dependent.
|
||||
* <p>
|
||||
* The title may or may not be displayed, depending on the actual type of window created.
|
||||
* <p>
|
||||
* If attachToInputContext is true, the new window will share the input context that
|
||||
* corresponds to this input method context, so that events for components in the window
|
||||
* are automatically dispatched to the input method.
|
||||
* Also, when the window is opened using setVisible(true), the input context will prevent
|
||||
* deactivate and activate calls to the input method that might otherwise be caused.
|
||||
* <p>
|
||||
* Input methods must call {@link java.awt.Window#dispose() Window.dispose} on the
|
||||
* returned input method window when it is no longer needed.
|
||||
* <p>
|
||||
* @param title the title to be displayed in the window's title bar,
|
||||
* if there is such a title bar.
|
||||
* A <code>null</code> value is treated as an empty string, "".
|
||||
* @param attachToInputContext whether this window should share the input context
|
||||
* that corresponds to this input method context
|
||||
* @return a window with special characteristics for use by input methods
|
||||
* @exception HeadlessException if <code>GraphicsEnvironment.isHeadless
|
||||
* </code> returns <code>true</code>
|
||||
*/
|
||||
public Window createInputMethodWindow(String title, boolean attachToInputContext);
|
||||
|
||||
/**
|
||||
* Creates a top-level Swing JFrame for use by the input method.
|
||||
* The intended behavior of this window is:
|
||||
* <ul>
|
||||
* <li>it floats above all document windows and dialogs
|
||||
* <li>it and all components that it contains do not receive the focus
|
||||
* <li>it has lightweight decorations, such as a reduced drag region without title
|
||||
* </ul>
|
||||
* However, the actual behavior with respect to these three items is platform dependent.
|
||||
* <p>
|
||||
* The title may or may not be displayed, depending on the actual type of window created.
|
||||
* <p>
|
||||
* If attachToInputContext is true, the new window will share the input context that
|
||||
* corresponds to this input method context, so that events for components in the window
|
||||
* are automatically dispatched to the input method.
|
||||
* Also, when the window is opened using setVisible(true), the input context will prevent
|
||||
* deactivate and activate calls to the input method that might otherwise be caused.
|
||||
* <p>
|
||||
* Input methods must call {@link java.awt.Window#dispose() Window.dispose} on the
|
||||
* returned input method window when it is no longer needed.
|
||||
* <p>
|
||||
* @param title the title to be displayed in the window's title bar,
|
||||
* if there is such a title bar.
|
||||
* A <code>null</code> value is treated as an empty string, "".
|
||||
* @param attachToInputContext whether this window should share the input context
|
||||
* that corresponds to this input method context
|
||||
* @return a JFrame with special characteristics for use by input methods
|
||||
* @exception HeadlessException if <code>GraphicsEnvironment.isHeadless
|
||||
* </code> returns <code>true</code>
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
public JFrame createInputMethodJFrame(String title, boolean attachToInputContext);
|
||||
|
||||
/**
|
||||
* Enables or disables notification of the current client window's
|
||||
* location and state for the specified input method. When
|
||||
* notification is enabled, the input method's {@link
|
||||
* java.awt.im.spi.InputMethod#notifyClientWindowChange
|
||||
* notifyClientWindowChange} method is called as described in that
|
||||
* method's specification. Notification is automatically disabled
|
||||
* when the input method is disposed.
|
||||
*
|
||||
* @param inputMethod the input method for which notifications are
|
||||
* enabled or disabled
|
||||
* @param enable true to enable, false to disable
|
||||
*/
|
||||
public void enableClientWindowNotification(InputMethod inputMethod, boolean enable);
|
||||
}
|
||||
124
jdkSrc/jdk8/java/awt/im/spi/InputMethodDescriptor.java
Normal file
124
jdkSrc/jdk8/java/awt/im/spi/InputMethodDescriptor.java
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package java.awt.im.spi;
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Image;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Defines methods that provide sufficient information about an input method
|
||||
* to enable selection and loading of that input method.
|
||||
* The input method itself is only loaded when it is actually used.
|
||||
*
|
||||
* @since 1.3
|
||||
*/
|
||||
|
||||
public interface InputMethodDescriptor {
|
||||
|
||||
/**
|
||||
* Returns the locales supported by the corresponding input method.
|
||||
* The locale may describe just the language, or may also include
|
||||
* country and variant information if needed.
|
||||
* The information is used to select input methods by locale
|
||||
* ({@link java.awt.im.InputContext#selectInputMethod(Locale)}). It may also
|
||||
* be used to sort input methods by locale in a user-visible
|
||||
* list of input methods.
|
||||
* <p>
|
||||
* Only the input method's primary locales should be returned.
|
||||
* For example, if a Japanese input method also has a pass-through
|
||||
* mode for Roman characters, typically still only Japanese would
|
||||
* be returned. Thus, the list of locales returned is typically
|
||||
* a subset of the locales for which the corresponding input method's
|
||||
* implementation of {@link java.awt.im.spi.InputMethod#setLocale} returns true.
|
||||
* <p>
|
||||
* If {@link #hasDynamicLocaleList} returns true, this method is
|
||||
* called each time the information is needed. This
|
||||
* gives input methods that depend on network resources the chance
|
||||
* to add or remove locales as resources become available or
|
||||
* unavailable.
|
||||
*
|
||||
* @return the locales supported by the input method
|
||||
* @exception AWTException if it can be determined that the input method
|
||||
* is inoperable, for example, because of incomplete installation.
|
||||
*/
|
||||
Locale[] getAvailableLocales() throws AWTException;
|
||||
|
||||
/**
|
||||
* Returns whether the list of available locales can change
|
||||
* at runtime. This may be the case, for example, for adapters
|
||||
* that access real input methods over the network.
|
||||
*/
|
||||
boolean hasDynamicLocaleList();
|
||||
|
||||
/**
|
||||
* Returns the user-visible name of the corresponding
|
||||
* input method for the given input locale in the language in which
|
||||
* the name will be displayed.
|
||||
* <p>
|
||||
* The inputLocale parameter specifies the locale for which text
|
||||
* is input.
|
||||
* This parameter can only take values obtained from this descriptor's
|
||||
* {@link #getAvailableLocales} method or null. If it is null, an
|
||||
* input locale independent name for the input method should be
|
||||
* returned.
|
||||
* <p>
|
||||
* If a name for the desired display language is not available, the
|
||||
* method may fall back to some other language.
|
||||
*
|
||||
* @param inputLocale the locale for which text input is supported, or null
|
||||
* @param displayLanguage the language in which the name will be displayed
|
||||
*/
|
||||
String getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage);
|
||||
|
||||
/**
|
||||
* Returns an icon for the corresponding input method.
|
||||
* The icon may be used by a user interface for selecting input methods.
|
||||
* <p>
|
||||
* The inputLocale parameter specifies the locale for which text
|
||||
* is input.
|
||||
* This parameter can only take values obtained from this descriptor's
|
||||
* {@link #getAvailableLocales} method or null. If it is null, an
|
||||
* input locale independent icon for the input method should be
|
||||
* returned.
|
||||
* <p>
|
||||
* The icon's size should be 16×16 pixels.
|
||||
*
|
||||
* @param inputLocale the locale for which text input is supported, or null
|
||||
* @return an icon for the corresponding input method, or null
|
||||
*/
|
||||
Image getInputMethodIcon(Locale inputLocale);
|
||||
|
||||
/**
|
||||
* Creates a new instance of the corresponding input method.
|
||||
*
|
||||
* @return a new instance of the corresponding input method
|
||||
* @exception Exception any exception that may occur while creating the
|
||||
* input method instance
|
||||
*/
|
||||
InputMethod createInputMethod() throws Exception;
|
||||
}
|
||||
Reference in New Issue
Block a user