KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > accessibility > AccessibleText


1 /*
2  * @(#)AccessibleText.java 1.28 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.accessibility;
9
10
11 import java.util.*;
12 import java.awt.*;
13 import javax.swing.text.*;
14
15
16 /**
17  * <P>The AccessibleText interface should be implemented by all
18  * classes that present textual information on the display. This interface
19  * provides the standard mechanism for an assistive technology to access
20  * that text via its content, attributes, and spatial location.
21  * Applications can determine if an object supports the AccessibleText
22  * interface by first obtaining its AccessibleContext (see {@link Accessible})
23  * and then calling the {@link AccessibleContext#getAccessibleText} method of
24  * AccessibleContext. If the return value is not null, the object supports this
25  * interface.
26  *
27  * @see Accessible
28  * @see Accessible#getAccessibleContext
29  * @see AccessibleContext
30  * @see AccessibleContext#getAccessibleText
31  *
32  * @version 1.13 01/20/98 07:53:43
33  * @author Peter Korn
34  */

35 public interface AccessibleText {
36
37     /**
38      * Constant used to indicate that the part of the text that should be
39      * retrieved is a character.
40      *
41      * @see #getAtIndex
42      * @see #getAfterIndex
43      * @see #getBeforeIndex
44      */

45     public static final int CHARACTER = 1;
46
47     /**
48      * Constant used to indicate that the part of the text that should be
49      * retrieved is a word.
50      *
51      * @see #getAtIndex
52      * @see #getAfterIndex
53      * @see #getBeforeIndex
54      */

55     public static final int WORD = 2;
56
57     /**
58      * Constant used to indicate that the part of the text that should be
59      * retrieved is a sentence.
60      *
61      * @see #getAtIndex
62      * @see #getAfterIndex
63      * @see #getBeforeIndex
64      */

65     public static final int SENTENCE = 3;
66
67     /**
68      * Given a point in local coordinates, return the zero-based index
69      * of the character under that Point. If the point is invalid,
70      * this method returns -1.
71      *
72      * @param p the Point in local coordinates
73      * @return the zero-based index of the character under Point p; if
74      * Point is invalid return -1.
75      */

76     public int getIndexAtPoint(Point p);
77
78     /**
79      * Determines the bounding box of the character at the given
80      * index into the string. The bounds are returned in local
81      * coordinates. If the index is invalid an empty rectangle is returned.
82      *
83      * @param i the index into the String
84      * @return the screen coordinates of the character's bounding box,
85      * if index is invalid return an empty rectangle.
86      */

87     public Rectangle getCharacterBounds(int i);
88
89     /**
90      * Returns the number of characters (valid indicies)
91      *
92      * @return the number of characters
93      */

94     public int getCharCount();
95
96     /**
97      * Returns the zero-based offset of the caret.
98      *
99      * Note: That to the right of the caret will have the same index
100      * value as the offset (the caret is between two characters).
101      * @return the zero-based offset of the caret.
102      */

103     public int getCaretPosition();
104
105     /**
106      * Returns the String at a given index.
107      *
108      * @param part the CHARACTER, WORD, or SENTENCE to retrieve
109      * @param index an index within the text
110      * @return the letter, word, or sentence
111      */

112     public String JavaDoc getAtIndex(int part, int index);
113
114     /**
115      * Returns the String after a given index.
116      *
117      * @param part the CHARACTER, WORD, or SENTENCE to retrieve
118      * @param index an index within the text
119      * @return the letter, word, or sentence
120      */

121     public String JavaDoc getAfterIndex(int part, int index);
122
123     /**
124      * Returns the String before a given index.
125      *
126      * @param part the CHARACTER, WORD, or SENTENCE to retrieve
127      * @param index an index within the text
128      * @return the letter, word, or sentence
129      */

130     public String JavaDoc getBeforeIndex(int part, int index);
131
132     /**
133      * Returns the AttributeSet for a given character at a given index
134      *
135      * @param i the zero-based index into the text
136      * @return the AttributeSet of the character
137      */

138     public AttributeSet getCharacterAttribute(int i);
139
140     /**
141      * Returns the start offset within the selected text.
142      * If there is no selection, but there is
143      * a caret, the start and end offsets will be the same.
144      *
145      * @return the index into the text of the start of the selection
146      */

147     public int getSelectionStart();
148
149     /**
150      * Returns the end offset within the selected text.
151      * If there is no selection, but there is
152      * a caret, the start and end offsets will be the same.
153      *
154      * @return the index into teh text of the end of the selection
155      */

156     public int getSelectionEnd();
157
158     /**
159      * Returns the portion of the text that is selected.
160      *
161      * @return the String portion of the text that is selected
162      */

163     public String JavaDoc getSelectedText();
164 }
165
Popular Tags