1 /* 2 * Copyright 2003-2006 Sun Microsystems, Inc. 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. Sun designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 22 * CA 95054 USA or visit www.sun.com if you need additional information or 23 * have any 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 AccessibleExtendedText interface contains additional methods 36 * not provided by the AccessibleText interface 37 * 38 * Applications can determine if an object supports the AccessibleExtendedText 39 * interface by first obtaining its AccessibleContext (see {@link Accessible}) 40 * and then calling the {@link AccessibleContext#getAccessibleText} method of 41 * AccessibleContext. If the return value is an instance of 42 * AccessibleExtendedText, the object supports this interface. 43 * 44 * @see Accessible 45 * @see Accessible#getAccessibleContext 46 * @see AccessibleContext 47 * @see AccessibleContext#getAccessibleText 48 * 49 * @author Peter Korn 50 * @author Lynn Monsanto 51 * @since 1.5 52 */ 53 public interface AccessibleExtendedText { 54 55 /** 56 * Constant used to indicate that the part of the text that should be 57 * retrieved is a line of text. 58 * 59 * @see AccessibleText#getAtIndex 60 * @see AccessibleText#getAfterIndex 61 * @see AccessibleText#getBeforeIndex 62 */ 63 public static final int LINE = 4; // BugID: 4849720 64 65 /** 66 * Constant used to indicate that the part of the text that should be 67 * retrieved is contiguous text with the same text attributes. 68 * 69 * @see AccessibleText#getAtIndex 70 * @see AccessibleText#getAfterIndex 71 * @see AccessibleText#getBeforeIndex 72 */ 73 public static final int ATTRIBUTE_RUN = 5; // BugID: 4849720 74 75 /** 76 * Returns the text between two indices 77 * 78 * @param startIndex the start index in the text 79 * @param endIndex the end index in the text 80 * @return the text string if the indices are valid. 81 * Otherwise, null is returned. 82 */ 83 public String getTextRange(int startIndex, int endIndex); 84 85 /** 86 * Returns the <code>AccessibleTextSequence</code> at a given index. 87 * 88 * @param part the <code>CHARACTER</code>, <code>WORD</code>, 89 * <code>SENTENCE</code>, <code>LINE</code> or <code>ATTRIBUTE_RUN</code> 90 * to retrieve 91 * @param index an index within the text 92 * @return an <code>AccessibleTextSequence</code> specifying the text 93 * if part and index are valid. Otherwise, null is returned. 94 * 95 * @see AccessibleText#CHARACTER 96 * @see AccessibleText#WORD 97 * @see AccessibleText#SENTENCE 98 */ 99 public AccessibleTextSequence getTextSequenceAt(int part, int index); 100 101 /** 102 * Returns the <code>AccessibleTextSequence</code> after a given index. 103 * 104 * @param part the <code>CHARACTER</code>, <code>WORD</code>, 105 * <code>SENTENCE</code>, <code>LINE</code> or <code>ATTRIBUTE_RUN</code> 106 * to retrieve 107 * @param index an index within the text 108 * @return an <code>AccessibleTextSequence</code> specifying the text 109 * if part and index are valid. Otherwise, null is returned. 110 * 111 * @see AccessibleText#CHARACTER 112 * @see AccessibleText#WORD 113 * @see AccessibleText#SENTENCE 114 */ 115 public AccessibleTextSequence getTextSequenceAfter(int part, int index); 116 117 /** 118 * Returns the <code>AccessibleTextSequence</code> before a given index. 119 * 120 * @param part the <code>CHARACTER</code>, <code>WORD</code>, 121 * <code>SENTENCE</code>, <code>LINE</code> or <code>ATTRIBUTE_RUN</code> 122 * to retrieve 123 * @param index an index within the text 124 * @return an <code>AccessibleTextSequence</code> specifying the text 125 * if part and index are valid. Otherwise, null is returned. 126 * 127 * @see AccessibleText#CHARACTER 128 * @see AccessibleText#WORD 129 * @see AccessibleText#SENTENCE 130 */ 131 public AccessibleTextSequence getTextSequenceBefore(int part, int index); 132 133 /** 134 * Returns the bounding rectangle of the text between two indices. 135 * 136 * @param startIndex the start index in the text 137 * @param endIndex the end index in the text 138 * @return the bounding rectangle of the text if the indices are valid. 139 * Otherwise, null is returned. 140 */ 141 public Rectangle getTextBounds(int startIndex, int endIndex); 142 }