1. /*
  2. * @(#)AccessibleExtendedText.java 1.2 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.accessibility;
  8. import java.util.*;
  9. import java.awt.*;
  10. import javax.swing.text.*;
  11. /**
  12. * <P>The AccessibleExtendedText interface contains additional methods
  13. * not provided by the AccessibleText interface
  14. *
  15. * Applications can determine if an object supports the AccessibleExtendedText
  16. * interface by first obtaining its AccessibleContext (see {@link Accessible})
  17. * and then calling the {@link AccessibleContext#getAccessibleText} method of
  18. * AccessibleContext. If the return value is an instance of
  19. * AccessibleExtendedText, the object supports this interface.
  20. *
  21. * @see Accessible
  22. * @see Accessible#getAccessibleContext
  23. * @see AccessibleContext
  24. * @see AccessibleContext#getAccessibleText
  25. * @see AccessibleText.AccessibleTextChunk
  26. *
  27. * @version 1.2 12/19/03
  28. * @author Peter Korn
  29. * @author Lynn Monsanto
  30. */
  31. public interface AccessibleExtendedText {
  32. /**
  33. * Constant used to indicate that the part of the text that should be
  34. * retrieved is a line of text.
  35. *
  36. * @see #getAtIndex
  37. * @see #getAfterIndex
  38. * @see #getBeforeIndex
  39. */
  40. public static final int LINE = 4; // BugID: 4849720
  41. /**
  42. * Constant used to indicate that the part of the text that should be
  43. * retrieved is contiguous text with the same text attributes.
  44. *
  45. * @see #getAtIndex
  46. * @see #getAfterIndex
  47. * @see #getBeforeIndex
  48. */
  49. public static final int ATTRIBUTE_RUN = 5; // BugID: 4849720
  50. /**
  51. * Returns the text between two indices
  52. *
  53. * @param startIndex the start index in the text
  54. * @param endIndex the end index in the text
  55. * @return the text string if the indices are valid.
  56. * Otherwise, null is returned.
  57. */
  58. public String getTextRange(int startIndex, int endIndex);
  59. /**
  60. * Returns the AccessibleTextSequence at a given index.
  61. *
  62. * @param part the CHARACTER, WORD, SENTENCE, LINE or ATTRIBUTE_RUN to
  63. * retrieve
  64. * @param index an index within the text
  65. * @return an AccessibleTextSequence specifying the text if part and index
  66. * are valid. Otherwise, null is returned.
  67. *
  68. * @see AccessibleText.CHARACTER
  69. * @see AccessibleText.WORK
  70. * @see AccessibleText.SENTENCE
  71. */
  72. public AccessibleTextSequence getTextSequenceAt(int part, int index);
  73. /**
  74. * Returns the AccessibleTextSequence after a given index.
  75. *
  76. * @param part the CHARACTER, WORD, SENTENCE, LINE or ATTRIBUTE_RUN to
  77. * retrieve
  78. * @param index an index within the text
  79. * @return an AccessibleTextSequence specifying the text if part and index
  80. * are valid. Otherwise, null is returned.
  81. *
  82. * @see AccessibleText.CHARACTER
  83. * @see AccessibleText.WORK
  84. * @see AccessibleText.SENTENCE
  85. */
  86. public AccessibleTextSequence getTextSequenceAfter(int part, int index);
  87. /**
  88. * Returns the AccessibleTextSequence before a given index.
  89. *
  90. * @param part the CHARACTER, WORD, SENTENCE, LINE or ATTRIBUTE_RUN to
  91. * retrieve
  92. * @param index an index within the text
  93. * @return an AccessibleTextSequence specifying the text if part and index
  94. * are valid. Otherwise, null is returned.
  95. *
  96. * @see AccessibleText.CHARACTER
  97. * @see AccessibleText.WORK
  98. * @see AccessibleText.SENTENCE
  99. */
  100. public AccessibleTextSequence getTextSequenceBefore(int part, int index);
  101. /**
  102. * Returns the bounding rectangle of the text between two indices.
  103. *
  104. * @param startIndex the start index in the text
  105. * @param endIndex the end index in the text
  106. * @return the bounding rectangle of the text if the indices are valid.
  107. * Otherwise, null is returned.
  108. */
  109. public Rectangle getTextBounds(int startIndex, int endIndex);
  110. }