Showing the changes to java/pkg/javax/accessibility/AccessibleText.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,188 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package javax.accessibility; | |
| 27 | + | |
| 28 | + | |
| 29 | +import java.util.*; | |
| 30 | +import java.awt.*; | |
| 31 | +import javax.swing.text.*; | |
| 32 | + | |
| 33 | + | |
| 34 | +/** | |
| 35 | + * <P>The AccessibleText interface should be implemented by all | |
| 36 | + * classes that present textual information on the display. This interface | |
| 37 | + * provides the standard mechanism for an assistive technology to access | |
| 38 | + * that text via its content, attributes, and spatial location. | |
| 39 | + * Applications can determine if an object supports the AccessibleText | |
| 40 | + * interface by first obtaining its AccessibleContext (see {@link Accessible}) | |
| 41 | + * and then calling the {@link AccessibleContext#getAccessibleText} method of | |
| 42 | + * AccessibleContext. If the return value is not null, the object supports this | |
| 43 | + * interface. | |
| 44 | + * | |
| 45 | + * @see Accessible | |
| 46 | + * @see Accessible#getAccessibleContext | |
| 47 | + * @see AccessibleContext | |
| 48 | + * @see AccessibleContext#getAccessibleText | |
| 49 | + * | |
| 50 | + * @author Peter Korn | |
| 51 | + */ | |
| 52 | +public interface AccessibleText { | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * Constant used to indicate that the part of the text that should be | |
| 56 | + * retrieved is a character. | |
| 57 | + * | |
| 58 | + * @see #getAtIndex | |
| 59 | + * @see #getAfterIndex | |
| 60 | + * @see #getBeforeIndex | |
| 61 | + */ | |
| 62 | + public static final int CHARACTER = 1; | |
| 63 | + | |
| 64 | + /** | |
| 65 | + * Constant used to indicate that the part of the text that should be | |
| 66 | + * retrieved is a word. | |
| 67 | + * | |
| 68 | + * @see #getAtIndex | |
| 69 | + * @see #getAfterIndex | |
| 70 | + * @see #getBeforeIndex | |
| 71 | + */ | |
| 72 | + public static final int WORD = 2; | |
| 73 | + | |
| 74 | + /** | |
| 75 | + * Constant used to indicate that the part of the text that should be | |
| 76 | + * retrieved is a sentence. | |
| 77 | + * | |
| 78 | + * A sentence is a string of words which expresses an assertion, | |
| 79 | + * a question, a command, a wish, an exclamation, or the performance | |
| 80 | + * of an action. In English locales, the string usually begins with | |
| 81 | + * a capital letter and concludes with appropriate end punctuation; | |
| 82 | + * such as a period, question or exclamation mark. Other locales may | |
| 83 | + * use different capitalization and/or punctuation. | |
| 84 | + * | |
| 85 | + * @see #getAtIndex | |
| 86 | + * @see #getAfterIndex | |
| 87 | + * @see #getBeforeIndex | |
| 88 | + */ | |
| 89 | + public static final int SENTENCE = 3; | |
| 90 | + | |
| 91 | + /** | |
| 92 | + * Given a point in local coordinates, return the zero-based index | |
| 93 | + * of the character under that Point. If the point is invalid, | |
| 94 | + * this method returns -1. | |
| 95 | + * | |
| 96 | + * @param p the Point in local coordinates | |
| 97 | + * @return the zero-based index of the character under Point p; if | |
| 98 | + * Point is invalid return -1. | |
| 99 | + */ | |
| 100 | + public int getIndexAtPoint(Point p); | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * Determines the bounding box of the character at the given | |
| 104 | + * index into the string. The bounds are returned in local | |
| 105 | + * coordinates. If the index is invalid an empty rectangle is returned. | |
| 106 | + * | |
| 107 | + * @param i the index into the String | |
| 108 | + * @return the screen coordinates of the character's bounding box, | |
| 109 | + * if index is invalid return an empty rectangle. | |
| 110 | + */ | |
| 111 | + public Rectangle getCharacterBounds(int i); | |
| 112 | + | |
| 113 | + /** | |
| 114 | + * Returns the number of characters (valid indicies) | |
| 115 | + * | |
| 116 | + * @return the number of characters | |
| 117 | + */ | |
| 118 | + public int getCharCount(); | |
| 119 | + | |
| 120 | + /** | |
| 121 | + * Returns the zero-based offset of the caret. | |
| 122 | + * | |
| 123 | + * Note: That to the right of the caret will have the same index | |
| 124 | + * value as the offset (the caret is between two characters). | |
| 125 | + * @return the zero-based offset of the caret. | |
| 126 | + */ | |
| 127 | + public int getCaretPosition(); | |
| 128 | + | |
| 129 | + /** | |
| 130 | + * Returns the String at a given index. | |
| 131 | + * | |
| 132 | + * @param part the CHARACTER, WORD, or SENTENCE to retrieve | |
| 133 | + * @param index an index within the text | |
| 134 | + * @return the letter, word, or sentence | |
| 135 | + */ | |
| 136 | + public String getAtIndex(int part, int index); | |
| 137 | + | |
| 138 | + /** | |
| 139 | + * Returns the String after a given index. | |
| 140 | + * | |
| 141 | + * @param part the CHARACTER, WORD, or SENTENCE to retrieve | |
| 142 | + * @param index an index within the text | |
| 143 | + * @return the letter, word, or sentence | |
| 144 | + */ | |
| 145 | + public String getAfterIndex(int part, int index); | |
| 146 | + | |
| 147 | + /** | |
| 148 | + * Returns the String before a given index. | |
| 149 | + * | |
| 150 | + * @param part the CHARACTER, WORD, or SENTENCE to retrieve | |
| 151 | + * @param index an index within the text | |
| 152 | + * @return the letter, word, or sentence | |
| 153 | + */ | |
| 154 | + public String getBeforeIndex(int part, int index); | |
| 155 | + | |
| 156 | + /** | |
| 157 | + * Returns the AttributeSet for a given character at a given index | |
| 158 | + * | |
| 159 | + * @param i the zero-based index into the text | |
| 160 | + * @return the AttributeSet of the character | |
| 161 | + */ | |
| 162 | + public AttributeSet getCharacterAttribute(int i); | |
| 163 | + | |
| 164 | + /** | |
| 165 | + * Returns the start offset within the selected text. | |
| 166 | + * If there is no selection, but there is | |
| 167 | + * a caret, the start and end offsets will be the same. | |
| 168 | + * | |
| 169 | + * @return the index into the text of the start of the selection | |
| 170 | + */ | |
| 171 | + public int getSelectionStart(); | |
| 172 | + | |
| 173 | + /** | |
| 174 | + * Returns the end offset within the selected text. | |
| 175 | + * If there is no selection, but there is | |
| 176 | + * a caret, the start and end offsets will be the same. | |
| 177 | + * | |
| 178 | + * @return the index into teh text of the end of the selection | |
| 179 | + */ | |
| 180 | + public int getSelectionEnd(); | |
| 181 | + | |
| 182 | + /** | |
| 183 | + * Returns the portion of the text that is selected. | |
| 184 | + * | |
| 185 | + * @return the String portion of the text that is selected | |
| 186 | + */ | |
| 187 | + public String getSelectedText(); | |
| 188 | +} | |