2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / javax / accessibility / AccessibleText.java
blob14c324c77082616d2d110ee8254c2c1f0510c03d
1 /* AccessibleText.java -- aids in accessibly manipulating text
2 Copyright (C) 2000, 2002 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
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.
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.
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.
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.
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. */
39 package javax.accessibility;
41 import java.awt.Rectangle;
42 import java.awt.Point;
43 import javax.swing.text.AttributeSet;
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.
50 * <p>The <code>AccessibleContext.getAccessibleText()</code> method
51 * should return <code>null</code> if an object does not implement this
52 * interface.
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
61 public interface AccessibleText
63 /**
64 * Constant designating that the next selection should be a character.
66 * @see #getAtIndex(int, int)
67 * @see #getAfterIndex(int, int)
68 * @see #getBeforeIndex(int, int)
70 int CHARACTER = 1;
72 /**
73 * Constant designating that the next selection should be a word.
75 * @see #getAtIndex(int, int)
76 * @see #getAfterIndex(int, int)
77 * @see #getBeforeIndex(int, int)
79 int WORD = 2;
81 /**
82 * Constant designating that the next selection should be a sentence.
84 * @see #getAtIndex(int, int)
85 * @see #getAfterIndex(int, int)
86 * @see #getBeforeIndex(int, int)
88 int SENTENCE = 3;
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.
94 * @param p the point to look at
95 * @return the character index, or -1
97 int getIndexAtPoint(Point point);
99 /**
100 * Determines the bounding box of the indexed character. Returns an empty
101 * rectangle if the index is out of bounds.
103 * @param index the 0-based character index
104 * @return the bounding box, may be empty
106 Rectangle getCharacterBounds(int index);
109 * Return the number of characters.
111 * @return the character count
113 int getCharCount();
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.
119 * @return the 0-based caret position
121 int getCaretPosition();
124 * Returns the section of text at the index, or null if the index or part
125 * is invalid.
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
131 String getAtIndex(int part, int index);
134 * Returns the section of text after the index, or null if the index or part
135 * is invalid.
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
141 String getAfterIndex(int part, int index);
144 * Returns the section of text before the index, or null if the index or part
145 * is invalid.
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
151 String getBeforeIndex(int part, int index);
154 * Returns the attributes of a character at an index, or null if the index
155 * is out of bounds.
157 * @param index the 0-based character index
158 * @return the character's attributes
160 AttributeSet getCharacterAttribute(int index);
163 * Returns the start index of the selection. If there is no selection, this
164 * is the same as the caret location.
166 * @return the 0-based character index of the selection start
168 int getSelectionStart();
171 * Returns the end index of the selection. If there is no selection, this
172 * is the same as the caret location.
174 * @return the 0-based character index of the selection end
176 int getSelectionEnd();
179 * Returns the selected text. This may be null or "" if no text is selected.
181 * @return the selected text
183 String getSelectedText();
184 } // interface AccessibleText