430N/A/*
2362N/A * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
430N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
430N/A *
430N/A * This code is free software; you can redistribute it and/or modify it
430N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
430N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
430N/A *
430N/A * This code is distributed in the hope that it will be useful, but WITHOUT
430N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
430N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
430N/A * version 2 for more details (a copy is included in the LICENSE file that
430N/A * accompanied this code).
430N/A *
430N/A * You should have received a copy of the GNU General Public License version
430N/A * 2 along with this work; if not, write to the Free Software Foundation,
430N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
430N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
430N/A */
430N/A
430N/Apackage javax.accessibility;
430N/A
430N/A
430N/Aimport java.util.*;
430N/Aimport java.awt.*;
430N/Aimport javax.swing.text.*;
430N/A
430N/A
430N/A/**
430N/A * <P>The AccessibleText interface should be implemented by all
430N/A * classes that present textual information on the display. This interface
430N/A * provides the standard mechanism for an assistive technology to access
430N/A * that text via its content, attributes, and spatial location.
430N/A * Applications can determine if an object supports the AccessibleText
430N/A * interface by first obtaining its AccessibleContext (see {@link Accessible})
430N/A * and then calling the {@link AccessibleContext#getAccessibleText} method of
430N/A * AccessibleContext. If the return value is not null, the object supports this
430N/A * interface.
430N/A *
430N/A * @see Accessible
430N/A * @see Accessible#getAccessibleContext
430N/A * @see AccessibleContext
430N/A * @see AccessibleContext#getAccessibleText
430N/A *
430N/A * @author Peter Korn
430N/A */
430N/Apublic interface AccessibleText {
430N/A
430N/A /**
430N/A * Constant used to indicate that the part of the text that should be
430N/A * retrieved is a character.
430N/A *
430N/A * @see #getAtIndex
430N/A * @see #getAfterIndex
430N/A * @see #getBeforeIndex
430N/A */
430N/A public static final int CHARACTER = 1;
430N/A
430N/A /**
430N/A * Constant used to indicate that the part of the text that should be
430N/A * retrieved is a word.
430N/A *
430N/A * @see #getAtIndex
430N/A * @see #getAfterIndex
430N/A * @see #getBeforeIndex
430N/A */
430N/A public static final int WORD = 2;
430N/A
430N/A /**
430N/A * Constant used to indicate that the part of the text that should be
430N/A * retrieved is a sentence.
430N/A *
430N/A * A sentence is a string of words which expresses an assertion,
430N/A * a question, a command, a wish, an exclamation, or the performance
430N/A * of an action. In English locales, the string usually begins with
430N/A * a capital letter and concludes with appropriate end punctuation;
430N/A * such as a period, question or exclamation mark. Other locales may
430N/A * use different capitalization and/or punctuation.
430N/A *
430N/A * @see #getAtIndex
430N/A * @see #getAfterIndex
430N/A * @see #getBeforeIndex
430N/A */
430N/A public static final int SENTENCE = 3;
430N/A
430N/A /**
430N/A * Given a point in local coordinates, return the zero-based index
430N/A * of the character under that Point. If the point is invalid,
430N/A * this method returns -1.
430N/A *
430N/A * @param p the Point in local coordinates
430N/A * @return the zero-based index of the character under Point p; if
430N/A * Point is invalid return -1.
430N/A */
430N/A public int getIndexAtPoint(Point p);
430N/A
430N/A /**
430N/A * Determines the bounding box of the character at the given
430N/A * index into the string. The bounds are returned in local
430N/A * coordinates. If the index is invalid an empty rectangle is returned.
430N/A *
430N/A * @param i the index into the String
430N/A * @return the screen coordinates of the character's bounding box,
430N/A * if index is invalid return an empty rectangle.
430N/A */
430N/A public Rectangle getCharacterBounds(int i);
430N/A
430N/A /**
430N/A * Returns the number of characters (valid indicies)
430N/A *
430N/A * @return the number of characters
430N/A */
430N/A public int getCharCount();
430N/A
430N/A /**
430N/A * Returns the zero-based offset of the caret.
430N/A *
430N/A * Note: That to the right of the caret will have the same index
430N/A * value as the offset (the caret is between two characters).
430N/A * @return the zero-based offset of the caret.
430N/A */
430N/A public int getCaretPosition();
430N/A
430N/A /**
430N/A * Returns the String at a given index.
430N/A *
430N/A * @param part the CHARACTER, WORD, or SENTENCE to retrieve
430N/A * @param index an index within the text
430N/A * @return the letter, word, or sentence
430N/A */
430N/A public String getAtIndex(int part, int index);
430N/A
430N/A /**
430N/A * Returns the String after a given index.
430N/A *
430N/A * @param part the CHARACTER, WORD, or SENTENCE to retrieve
430N/A * @param index an index within the text
430N/A * @return the letter, word, or sentence
430N/A */
430N/A public String getAfterIndex(int part, int index);
430N/A
430N/A /**
430N/A * Returns the String before a given index.
430N/A *
430N/A * @param part the CHARACTER, WORD, or SENTENCE to retrieve
430N/A * @param index an index within the text
430N/A * @return the letter, word, or sentence
430N/A */
430N/A public String getBeforeIndex(int part, int index);
430N/A
430N/A /**
430N/A * Returns the AttributeSet for a given character at a given index
430N/A *
430N/A * @param i the zero-based index into the text
430N/A * @return the AttributeSet of the character
430N/A */
430N/A public AttributeSet getCharacterAttribute(int i);
430N/A
430N/A /**
430N/A * Returns the start offset within the selected text.
430N/A * If there is no selection, but there is
430N/A * a caret, the start and end offsets will be the same.
430N/A *
430N/A * @return the index into the text of the start of the selection
430N/A */
430N/A public int getSelectionStart();
430N/A
430N/A /**
430N/A * Returns the end offset within the selected text.
430N/A * If there is no selection, but there is
430N/A * a caret, the start and end offsets will be the same.
430N/A *
430N/A * @return the index into teh text of the end of the selection
430N/A */
430N/A public int getSelectionEnd();
430N/A
430N/A /**
430N/A * Returns the portion of the text that is selected.
430N/A *
430N/A * @return the String portion of the text that is selected
430N/A */
430N/A public String getSelectedText();
430N/A}
430N/A