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

  1. /*
  2.  * @(#)AccessibleText.java    1.13 98/01/20
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package java.awt.accessibility;
  22.  
  23.  
  24. import java.lang.*;
  25. import java.util.*;
  26. import java.awt.*;
  27. import java.awt.swing.text.*;
  28.  
  29.  
  30. /**
  31.  * <P>The AccessibleText interface should be implemented by all 
  32.  * classes that present textual information on the display.  This interface
  33.  * provides the standard mechanism for an assistive technology to access 
  34.  * that text via its content, attributes, and spatial location.  
  35.  * Applications can determine if an object supports the AccessibleText 
  36.  * interface by first obtaining its AccessibleContext (see
  37.  * <a href="java.awt.accessibility.Accessible.html">Accessible</a>) and
  38.  * then calling the
  39.  * <a href="java.awt.accessibility.AccessibleContext.html#getAccessibleText">
  40.  * getAccessibleText</a> method of AccessibleContext.  If the return 
  41.  * value is not null, the object supports this interface.
  42.  *
  43.  * @see Accessible
  44.  * @see Accessible#getAccessibleContext
  45.  * @see AccessibleContext
  46.  * @see AccessibleContext#getAccessibleText
  47.  *
  48.  * @version    1.13 01/20/98 07:53:43
  49.  * @author    Peter Korn
  50.  */
  51. public interface AccessibleText {
  52.  
  53.     /**
  54.      * Constant used to indicate that the part of text that should be
  55.      * retrieved is a character.
  56.      * 
  57.      * @see #getAtIndex
  58.      * @see #getAfterIndex
  59.      * @see #getBeforeIndex
  60.      */
  61.     public static final int CHARACTER = 1;
  62.  
  63.     /**
  64.      * Constant used to indicate that the part of text that should be 
  65.      * retrieved is a word.
  66.      * 
  67.      * @see #getAtIndex
  68.      * @see #getAfterIndex
  69.      * @see #getBeforeIndex
  70.      */
  71.     public static final int WORD = 2;
  72.  
  73.     /**
  74.      * Constant used to indicate that the part of text that should be 
  75.      * retrieved is a sentence.
  76.      * 
  77.      * @see #getAtIndex
  78.      * @see #getAfterIndex
  79.      * @see #getBeforeIndex
  80.      */
  81.     public static final int SENTENCE = 3;
  82.  
  83.     /**
  84.      * Given a point in local coordinates, return the zero-based index
  85.      * of the character under that Point.  If the point is invalid,
  86.      * this method returns -1.
  87.      *
  88.      * @param p the Point in local coordinates
  89.      * @return the zero-based index of the character under Point p; if 
  90.      * Point is invalid returns -1.
  91.      */
  92.     public int getIndexAtPoint(Point p);
  93.  
  94.     /**
  95.      * Determine the bounding box of the character at the given 
  96.      * index into the string.  The bounds are returned in local
  97.      * coordinates.  If the index is invalid an empty rectangle is returned.
  98.      *
  99.      * @param i the index into the String
  100.      * @return the screen coordinates of the character's the bounding box,
  101.      * if index is invalid returns an empty rectangle.
  102.      */
  103.     public Rectangle getCharacterBounds(int i);
  104.  
  105.     /**
  106.      * Return the number of characters (valid indicies) 
  107.      *
  108.      * @return the number of characters
  109.      */
  110.     public int getCharCount();
  111.  
  112.     /**
  113.      * Return the zero-based offset of the caret.
  114.      *
  115.      * Note: That to the right of the caret will have the same index
  116.      * value as the offset (the caret is between two characters).
  117.      * @return the zero-based offset of the caret.
  118.      */
  119.     public int getCaretPosition();
  120.  
  121.     /**
  122.      * Return the String at a given index. 
  123.      *
  124.      * @param part the CHARACTER, WORD, or SENTENCE to retrieve
  125.      * @param index an index within the text
  126.      * @return the letter, word, or sentence
  127.      */
  128.     public String getAtIndex(int part, int index);
  129.  
  130.     /**
  131.      * Return the String after a given index.
  132.      *
  133.      * @param part the CHARACTER, WORD, or SENTENCE to retrieve
  134.      * @param index an index within the text
  135.      * @return the letter, word, or sentence
  136.      */
  137.     public String getAfterIndex(int part, int index);
  138.  
  139.     /**
  140.      * Return the String before a given index.
  141.      *
  142.      * @param part the CHARACTER, WORD, or SENTENCE to retrieve
  143.      * @param index an index within the text
  144.      * @return the letter, word, or sentence
  145.      */
  146.     public String getBeforeIndex(int part, int index);
  147.  
  148.     /**
  149.      * Return the AttributeSet for a given character at a given index
  150.      *
  151.      * @param i the zero-based index into the text 
  152.      * @return the AttributeSet of the character
  153.      */
  154.     public AttributeSet getCharacterAttribute(int i);
  155.  
  156.     /**
  157.      * Returns the start offset within the selected text.
  158.      * If there is no selection, but there is
  159.      * a caret, the start and end offsets will be the same.
  160.      *
  161.      * @return the index into the text of the start of the selection
  162.      */
  163.     public int getSelectionStart();
  164.  
  165.     /**
  166.      * Returns the end offset within the selected text.
  167.      * If there is no selection, but there is
  168.      * a caret, the start and end offsets will be the same.
  169.      *
  170.      * @return the index into teh text of the end of the selection
  171.      */
  172.     public int getSelectionEnd();
  173.  
  174.     /**
  175.      * Returns the portion of the text that is selected. 
  176.      *
  177.      * @return the String portion of the text that is selected
  178.      */
  179.     public String getSelectedText();
  180. }
  181.