blob: 4868ab85e8f7bd0dae7225ffc63e6bf03a5bd84f [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
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
26package javax.accessibility;
27
28
29import java.util.*;
30import java.awt.*;
31import 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 * @see AccessibleText.AccessibleTextChunk
49 *
50 * @author Peter Korn
51 * @author Lynn Monsanto
52 * @since 1.5
53 */
54public interface AccessibleExtendedText {
55
56 /**
57 * Constant used to indicate that the part of the text that should be
58 * retrieved is a line of text.
59 *
60 * @see AccessibleText#getAtIndex
61 * @see AccessibleText#getAfterIndex
62 * @see AccessibleText#getBeforeIndex
63 */
64 public static final int LINE = 4; // BugID: 4849720
65
66 /**
67 * Constant used to indicate that the part of the text that should be
68 * retrieved is contiguous text with the same text attributes.
69 *
70 * @see AccessibleText#getAtIndex
71 * @see AccessibleText#getAfterIndex
72 * @see AccessibleText#getBeforeIndex
73 */
74 public static final int ATTRIBUTE_RUN = 5; // BugID: 4849720
75
76 /**
77 * Returns the text between two indices
78 *
79 * @param startIndex the start index in the text
80 * @param endIndex the end index in the text
81 * @return the text string if the indices are valid.
82 * Otherwise, null is returned.
83 */
84 public String getTextRange(int startIndex, int endIndex);
85
86 /**
87 * Returns the <code>AccessibleTextSequence</code> at a given index.
88 *
89 * @param part the <code>CHARACTER</code>, <code>WORD</code>,
90 * <code>SENTENCE</code>, <code>LINE</code> or <code>ATTRIBUTE_RUN</code>
91 * to retrieve
92 * @param index an index within the text
93 * @return an <code>AccessibleTextSequence</code> specifying the text
94 * if part and index are valid. Otherwise, null is returned.
95 *
96 * @see AccessibleText#CHARACTER
97 * @see AccessibleText#WORD
98 * @see AccessibleText#SENTENCE
99 */
100 public AccessibleTextSequence getTextSequenceAt(int part, int index);
101
102 /**
103 * Returns the <code>AccessibleTextSequence</code> after a given index.
104 *
105 * @param part the <code>CHARACTER</code>, <code>WORD</code>,
106 * <code>SENTENCE</code>, <code>LINE</code> or <code>ATTRIBUTE_RUN</code>
107 * to retrieve
108 * @param index an index within the text
109 * @return an <code>AccessibleTextSequence</code> specifying the text
110 * if part and index are valid. Otherwise, null is returned.
111 *
112 * @see AccessibleText#CHARACTER
113 * @see AccessibleText#WORD
114 * @see AccessibleText#SENTENCE
115 */
116 public AccessibleTextSequence getTextSequenceAfter(int part, int index);
117
118 /**
119 * Returns the <code>AccessibleTextSequence</code> before a given index.
120 *
121 * @param part the <code>CHARACTER</code>, <code>WORD</code>,
122 * <code>SENTENCE</code>, <code>LINE</code> or <code>ATTRIBUTE_RUN</code>
123 * to retrieve
124 * @param index an index within the text
125 * @return an <code>AccessibleTextSequence</code> specifying the text
126 * if part and index are valid. Otherwise, null is returned.
127 *
128 * @see AccessibleText#CHARACTER
129 * @see AccessibleText#WORD
130 * @see AccessibleText#SENTENCE
131 */
132 public AccessibleTextSequence getTextSequenceBefore(int part, int index);
133
134 /**
135 * Returns the bounding rectangle of the text between two indices.
136 *
137 * @param startIndex the start index in the text
138 * @param endIndex the end index in the text
139 * @return the bounding rectangle of the text if the indices are valid.
140 * Otherwise, null is returned.
141 */
142 public Rectangle getTextBounds(int startIndex, int endIndex);
143}