home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / awt / im / InputMethodRequests.java < prev   
Encoding:
Java Source  |  1998-03-20  |  5.9 KB  |  137 lines

  1. /*
  2.  * @(#)InputMethodRequests.java    1.8 98/03/18
  3.  *
  4.  * Copyright 1997 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.awt.im;
  16.  
  17. import java.awt.Rectangle;
  18. import java.awt.font.TextHitInfo;
  19. import java.text.AttributedCharacterIterator;
  20.  
  21. /**
  22.  * InputMethodRequests defines the requests that a text editing component
  23.  * has to handle in order to work with input methods. The component
  24.  * can implement this interface itself or use a separate object that
  25.  * implements it. The object implementing this interface must be returned
  26.  * from the component's getInputMethodRequests method.
  27.  *
  28.  * <p>
  29.  * The text editing component also has to provide an input method event
  30.  * listener.
  31.  *
  32.  * @see java.awt.Component#getInputMethodRequests
  33.  * @see java.awt.event.InputMethodListener
  34.  *
  35.  * @version 1.2 05/16/97
  36.  * @author JavaSoft Asia/Pacific
  37.  */
  38.  
  39. public interface InputMethodRequests {
  40.  
  41.     /**
  42.      * Gets the location of a specified offset in the current composed text.
  43.      * This information is, for example, used to position the candidate window near the
  44.      * composed text. The offset is relative to the composed text, so offset 0
  45.      * indicates the beginning of the composed text.
  46.      * The location is represented as a 0-thickness caret, that is, it has 0 width if the
  47.      * text is drawn horizontally, and 0 height if the text is drawn vertically. Other
  48.      * text orientations need to be mapped to horizontal or vertical orientation. The
  49.      * rectangle uses absolute screen coordinates.
  50.      *
  51.      * @param offset The offset within the composed text.
  52.      * @return A rectangle representing the screen location of the offset.
  53.      */
  54.     Rectangle getOffsetLocation(TextHitInfo offset);
  55.  
  56.     /**
  57.      * Gets the offset within the composed text for the specified absolute x and y
  58.      * coordinates on the screen. This information is used, for example to handle mouse
  59.      * clicks and the mouse cursor. The offset is relative to the composed text, so offset 0
  60.      * indicates the beginning of the composed text.
  61.      *
  62.      * <p>
  63.      * Return null if the location is outside the area occupied by the composed text.
  64.      *
  65.      * @param x The absolute x coordinate on screen.
  66.      * @param y The absolute y coordinate on screen.
  67.      * @return Text hit info about the offset in the composed text.
  68.      */
  69.     TextHitInfo getLocationOffset(int x, int y);
  70.  
  71.     /**
  72.      * Gets the offset of the insert position in the committed text contained in the text
  73.      * editing component. This is the offset at which characters entered through an input
  74.      * method are inserted. This information is used by an input method, for example, to examine
  75.      * the text surrounding the insert position.
  76.      * 
  77.      * @return The offset of the insert position.
  78.      */
  79.     int getInsertPositionOffset();
  80.  
  81.     /**
  82.      * Gets an iterator providing access to the entire text and attributes contained in the
  83.      * text editing component except for uncommitted text. Uncommitted (composed) text should be ignored
  84.      * for index calculations and should not be made accessible through the iterator.
  85.      * The input method may provide a list of names of attributes that it is interested in.
  86.      * In that case, information about other attributes that the implementor may have need
  87.      * not be made accessible through the iterator. If the list is null, all available
  88.      * attribute information should be made accessible.
  89.      *
  90.      * @param beginIndex the index of the first character
  91.      * @param endIndex the index of the character following the last character
  92.      * @param attributeNames a list of attributes that the input method is interested in
  93.      * @return an iterator providing access to the text and its attributes
  94.      */
  95.     AttributedCharacterIterator getCommittedText(int beginIndex, int endIndex, String[] attributeNames);
  96.  
  97.     /**
  98.      * Gets the length of the entire text contained in the text
  99.      * editing component except for uncommitted (composed) text.
  100.      *
  101.      * @return length of text
  102.      */
  103.     int getCommittedTextLength();
  104.  
  105.     /**
  106.      * Gets the latest committed text from the text editing component and removes
  107.      * it from the component's text body.
  108.      * This is used for the "Undo Commit" feature in some input methods, where the
  109.      * committed text reverts to its previous composed state. The composed text will
  110.      * be sent to the component using an InputMethodEvent.
  111.      *
  112.      * <p>
  113.      * Generally, this feature should only be supported immediately after the text was
  114.      * committed, not after the user performed other operations on the text. When the
  115.      * feature is not supported, return null.
  116.      *
  117.      * @return The latest committed text, or null when the "Undo Commit" feature is not supported.
  118.      */
  119.     AttributedCharacterIterator cancelLatestCommittedText(String[] attributeNames);
  120.  
  121.     /**
  122.      * Gets the currently selected text from the text editing component.
  123.      * This is used for the "Reconvert" feature in some input methods. Typically,
  124.      * the input method will send an input method event to replace the selected text
  125.      * with composed text. Depending on the input method's capabilities, this may be
  126.      * the original composed text for the selected text, the latest composed text
  127.      * entered anywhere in the text, or a version of the text that's converted back
  128.      * from the selected text.
  129.      *
  130.      * <p>
  131.      * If a text component doesn't support this feature, return null.
  132.      *
  133.      * @return The currently selected text, or null when the "Reconvert" feature is not supported.
  134.      */
  135.     AttributedCharacterIterator getSelectedText(String[] attributeNames);
  136. }
  137.