Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / libjava / javax / accessibility / AccessibleText.java
blobcffabe4545dbf5ecdc14d6b36a71549e993458e5
1 /* AccessibleText.java -- aids in accessibly manipulating text
2 Copyright (C) 2000, 2002, 2004, 2005 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.Point;
42 import java.awt.Rectangle;
44 import javax.swing.text.AttributeSet;
46 /**
47 * Objects which present textual information on the display should implement
48 * this interface. Accessibility software can use the implementations of
49 * this interface to change the attributes and spacial location of the text.
51 * <p>The <code>AccessibleContext.getAccessibleText()</code> method
52 * should return <code>null</code> if an object does not implement this
53 * interface.
55 * @author Eric Blake (ebb9@email.byu.edu)
56 * @see Accessible
57 * @see AccessibleContext
58 * @see AccessibleContext#getAccessibleText()
59 * @since 1.2
60 * @status updated to 1.4
62 public interface AccessibleText
64 /**
65 * Constant designating that the next selection should be a character.
67 * @see #getAtIndex(int, int)
68 * @see #getAfterIndex(int, int)
69 * @see #getBeforeIndex(int, int)
71 int CHARACTER = 1;
73 /**
74 * Constant designating that the next selection should be a word.
76 * @see #getAtIndex(int, int)
77 * @see #getAfterIndex(int, int)
78 * @see #getBeforeIndex(int, int)
80 int WORD = 2;
82 /**
83 * Constant designating that the next selection should be a sentence.
85 * @see #getAtIndex(int, int)
86 * @see #getAfterIndex(int, int)
87 * @see #getBeforeIndex(int, int)
89 int SENTENCE = 3;
91 /**
92 * Given a point in the coordinate system of this object, return the
93 * 0-based index of the character at that point, or -1 if there is none.
95 * @param p the point to look at
96 * @return the character index, or -1
98 int getIndexAtPoint(Point point);
101 * Determines the bounding box of the indexed character. Returns an empty
102 * rectangle if the index is out of bounds.
104 * @param index the 0-based character index
105 * @return the bounding box, may be empty
107 Rectangle getCharacterBounds(int index);
110 * Return the number of characters.
112 * @return the character count
114 int getCharCount();
117 * Return the offset of the character. The offset matches the index of the
118 * character to the right, since the carat lies between characters.
120 * @return the 0-based caret position
122 int getCaretPosition();
125 * Returns the section of text at the index, or null if the index or part
126 * is invalid.
128 * @param part {@link CHARACTER}, {@link WORD}, or {@link SENTENCE}
129 * @param index the 0-based character index
130 * @return the selection of text at that index, or null
132 String getAtIndex(int part, int index);
135 * Returns the section of text after the index, or null if the index or part
136 * is invalid.
138 * @param part {@link CHARACTER}, {@link WORD}, or {@link SENTENCE}
139 * @param index the 0-based character index
140 * @return the selection of text after that index, or null
142 String getAfterIndex(int part, int index);
145 * Returns the section of text before the index, or null if the index or part
146 * is invalid.
148 * @param part {@link CHARACTER}, {@link WORD}, or {@link SENTENCE}
149 * @param index the 0-based character index
150 * @return the selection of text before that index, or null
152 String getBeforeIndex(int part, int index);
155 * Returns the attributes of a character at an index, or null if the index
156 * is out of bounds.
158 * @param index the 0-based character index
159 * @return the character's attributes
161 AttributeSet getCharacterAttribute(int index);
164 * Returns the start index of the selection. If there is no selection, this
165 * is the same as the caret location.
167 * @return the 0-based character index of the selection start
169 int getSelectionStart();
172 * Returns the end index of the selection. If there is no selection, this
173 * is the same as the caret location.
175 * @return the 0-based character index of the selection end
177 int getSelectionEnd();
180 * Returns the selected text. This may be null or "" if no text is selected.
182 * @return the selected text
184 String getSelectedText();
185 } // interface AccessibleText