1 | /* AccessibleText.java -- aids in accessibly manipulating text
|
---|
2 | Copyright (C) 2000, 2002 Free Software Foundation, Inc.
|
---|
3 |
|
---|
4 | This file is part of GNU Classpath.
|
---|
5 |
|
---|
6 | GNU Classpath is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 2, or (at your option)
|
---|
9 | any later version.
|
---|
10 |
|
---|
11 | GNU Classpath is distributed in the hope that it will be useful, but
|
---|
12 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
14 | General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License
|
---|
17 | along with GNU Classpath; see the file COPYING. If not, write to the
|
---|
18 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
---|
19 | 02111-1307 USA.
|
---|
20 |
|
---|
21 | Linking this library statically or dynamically with other modules is
|
---|
22 | making a combined work based on this library. Thus, the terms and
|
---|
23 | conditions of the GNU General Public License cover the whole
|
---|
24 | combination.
|
---|
25 |
|
---|
26 | As a special exception, the copyright holders of this library give you
|
---|
27 | permission to link this library with independent modules to produce an
|
---|
28 | executable, regardless of the license terms of these independent
|
---|
29 | modules, and to copy and distribute the resulting executable under
|
---|
30 | terms of your choice, provided that you also meet, for each linked
|
---|
31 | independent module, the terms and conditions of the license of that
|
---|
32 | module. An independent module is a module which is not derived from
|
---|
33 | or based on this library. If you modify this library, you may extend
|
---|
34 | this exception to your version of the library, but you are not
|
---|
35 | obligated to do so. If you do not wish to do so, delete this
|
---|
36 | exception statement from your version. */
|
---|
37 |
|
---|
38 |
|
---|
39 | package javax.accessibility;
|
---|
40 |
|
---|
41 | import java.awt.Rectangle;
|
---|
42 | import java.awt.Point;
|
---|
43 | import javax.swing.text.AttributeSet;
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Objects which present textual information on the display should implement
|
---|
47 | * this interface. Accessibility software can use the implementations of
|
---|
48 | * this interface to change the attributes and spacial location of the text.
|
---|
49 | *
|
---|
50 | * <p>The <code>AccessibleContext.getAccessibleText()</code> method
|
---|
51 | * should return <code>null</code> if an object does not implement this
|
---|
52 | * interface.
|
---|
53 | *
|
---|
54 | * @author Eric Blake <ebb9@email.byu.edu>
|
---|
55 | * @see Accessible
|
---|
56 | * @see AccessibleContext
|
---|
57 | * @see AccessibleContext#getAccessibleText()
|
---|
58 | * @since 1.2
|
---|
59 | * @status updated to 1.4
|
---|
60 | */
|
---|
61 | public interface AccessibleText
|
---|
62 | {
|
---|
63 | /**
|
---|
64 | * Constant designating that the next selection should be a character.
|
---|
65 | *
|
---|
66 | * @see #getAtIndex(int, int)
|
---|
67 | * @see #getAfterIndex(int, int)
|
---|
68 | * @see #getBeforeIndex(int, int)
|
---|
69 | */
|
---|
70 | int CHARACTER = 1;
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * Constant designating that the next selection should be a word.
|
---|
74 | *
|
---|
75 | * @see #getAtIndex(int, int)
|
---|
76 | * @see #getAfterIndex(int, int)
|
---|
77 | * @see #getBeforeIndex(int, int)
|
---|
78 | */
|
---|
79 | int WORD = 2;
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * Constant designating that the next selection should be a sentence.
|
---|
83 | *
|
---|
84 | * @see #getAtIndex(int, int)
|
---|
85 | * @see #getAfterIndex(int, int)
|
---|
86 | * @see #getBeforeIndex(int, int)
|
---|
87 | */
|
---|
88 | int SENTENCE = 3;
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * Given a point in the coordinate system of this object, return the
|
---|
92 | * 0-based index of the character at that point, or -1 if there is none.
|
---|
93 | *
|
---|
94 | * @param p the point to look at
|
---|
95 | * @return the character index, or -1
|
---|
96 | */
|
---|
97 | int getIndexAtPoint(Point point);
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * Determines the bounding box of the indexed character. Returns an empty
|
---|
101 | * rectangle if the index is out of bounds.
|
---|
102 | *
|
---|
103 | * @param index the 0-based character index
|
---|
104 | * @return the bounding box, may be empty
|
---|
105 | */
|
---|
106 | Rectangle getCharacterBounds(int index);
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * Return the number of characters.
|
---|
110 | *
|
---|
111 | * @return the character count
|
---|
112 | */
|
---|
113 | int getCharCount();
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * Return the offset of the character. The offset matches the index of the
|
---|
117 | * character to the right, since the carat lies between characters.
|
---|
118 | *
|
---|
119 | * @return the 0-based caret position
|
---|
120 | */
|
---|
121 | int getCaretPosition();
|
---|
122 |
|
---|
123 | /**
|
---|
124 | * Returns the section of text at the index, or null if the index or part
|
---|
125 | * is invalid.
|
---|
126 | *
|
---|
127 | * @param part {@link CHARACTER}, {@link WORD}, or {@link SENTENCE}
|
---|
128 | * @param index the 0-based character index
|
---|
129 | * @return the selection of text at that index, or null
|
---|
130 | */
|
---|
131 | String getAtIndex(int part, int index);
|
---|
132 |
|
---|
133 | /**
|
---|
134 | * Returns the section of text after the index, or null if the index or part
|
---|
135 | * is invalid.
|
---|
136 | *
|
---|
137 | * @param part {@link CHARACTER}, {@link WORD}, or {@link SENTENCE}
|
---|
138 | * @param index the 0-based character index
|
---|
139 | * @return the selection of text after that index, or null
|
---|
140 | */
|
---|
141 | String getAfterIndex(int part, int index);
|
---|
142 |
|
---|
143 | /**
|
---|
144 | * Returns the section of text before the index, or null if the index or part
|
---|
145 | * is invalid.
|
---|
146 | *
|
---|
147 | * @param part {@link CHARACTER}, {@link WORD}, or {@link SENTENCE}
|
---|
148 | * @param index the 0-based character index
|
---|
149 | * @return the selection of text before that index, or null
|
---|
150 | */
|
---|
151 | String getBeforeIndex(int part, int index);
|
---|
152 |
|
---|
153 | /**
|
---|
154 | * Returns the attributes of a character at an index, or null if the index
|
---|
155 | * is out of bounds.
|
---|
156 | *
|
---|
157 | * @param index the 0-based character index
|
---|
158 | * @return the character's attributes
|
---|
159 | */
|
---|
160 | AttributeSet getCharacterAttribute(int index);
|
---|
161 |
|
---|
162 | /**
|
---|
163 | * Returns the start index of the selection. If there is no selection, this
|
---|
164 | * is the same as the caret location.
|
---|
165 | *
|
---|
166 | * @return the 0-based character index of the selection start
|
---|
167 | */
|
---|
168 | int getSelectionStart();
|
---|
169 |
|
---|
170 | /**
|
---|
171 | * Returns the end index of the selection. If there is no selection, this
|
---|
172 | * is the same as the caret location.
|
---|
173 | *
|
---|
174 | * @return the 0-based character index of the selection end
|
---|
175 | */
|
---|
176 | int getSelectionEnd();
|
---|
177 |
|
---|
178 | /**
|
---|
179 | * Returns the selected text. This may be null or "" if no text is selected.
|
---|
180 | *
|
---|
181 | * @return the selected text
|
---|
182 | */
|
---|
183 | String getSelectedText();
|
---|
184 | } // interface AccessibleText
|
---|