ice.pilots.html4
Class Html4DocumentAccess

java.lang.Object
  extended byice.pilots.html4.Html4DocumentAccess

public class Html4DocumentAccess
extends Object

An initial implementation of the DocumentAccess


Field Summary
static int ALL
           
static int CHARACTER_TYPE
           
static int MAX_TYPE
           
static int SENTENCE_TYPE
           
static int WORD_TYPE
           
 
Constructor Summary
Html4DocumentAccess()
           
Html4DocumentAccess(ThePilot aPilot)
          Construct the Accessibility Implementation with a concrete tool that can provide the underlying layout support.
 
Method Summary
 int getCaretPosition(int aType)
          Retrieve the current Caret position for an element type.
 CharacterAttributes getCharAttributes(int aIndex)
          Retrieve the CSS attributes for a character identified by its index.
 int getCount(int aType)
          Retrieve the number of chars, words, sentences, or paragraphs in the document
 String getCurrentText(int aType)
          Retrieve the text at the current cursor location.
 int getIndexAtPoint(int aX, int aY, int scrollX, int scrollY)
          Retrieve the character Index of a point X,Y on the screen, with a scroll bar position.
 int getIndexOfNode(DNode node)
          Given a node, returns the character index offset for that node.
 String getNext(int aType)
          Get the next entity of a given type.
 DNode getNodeByIndex(int aType, int aIndex)
          Return the DOM Node associated with a particular element.
 String getPrevious(int aType)
          Retrieve the previous entity of a given type.
 String getSelectedText()
          Retrieve the text that is currently selected.
 int getSelectionEnd()
          Retrieve the index of the character that is the last in any selected passage of text.
 int getSelectionStart()
          Get the index of the character that is the first in any selected passage of text.
 String getText(int aType, int aIndex)
          Get the text indicated by the 'type' and the position in the document given by 'index'.
 String getTextAt(int aType, int aX, int aY, int aScrollX, int aScrollY)
          Position the cursor to whatever text is at the pixel location in the rendered document, and return the type of text element that is found there.
 void positionToIndex(int aType, int aIndex)
          Position the caret to an element in the document.
 void selectWordByIndex(int wordIndex)
          Select the word given by the wordIndex.
 void setSelection(int type, int x, int y)
          Selects specified entity under the specified point on the screen.
 void setSelection(int x1, int y1, int x2, int y2)
          Allows you to set a text selection on a page by specifying a bounding box (like a drag rectangle).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHARACTER_TYPE

public static final int CHARACTER_TYPE
See Also:
Constant Field Values

WORD_TYPE

public static final int WORD_TYPE
See Also:
Constant Field Values

SENTENCE_TYPE

public static final int SENTENCE_TYPE
See Also:
Constant Field Values

MAX_TYPE

public static final int MAX_TYPE
See Also:
Constant Field Values

ALL

public static final int ALL
See Also:
Constant Field Values
Constructor Detail

Html4DocumentAccess

public Html4DocumentAccess(ThePilot aPilot)
Construct the Accessibility Implementation with a concrete tool that can provide the underlying layout support.

Parameters:
aPilot - instance of the HTML4 pilot to obtain the required references from

Html4DocumentAccess

public Html4DocumentAccess()
Method Detail

getCurrentText

public String getCurrentText(int aType)
Retrieve the text at the current cursor location. For a character, this will be the character after the current index. For a

Parameters:
aType - The enumerated type of text to retrieve.
Returns:
The text of the type enclosing the current location.

getTextAt

public String getTextAt(int aType,
                        int aX,
                        int aY,
                        int aScrollX,
                        int aScrollY)
Position the cursor to whatever text is at the pixel location in the rendered document, and return the type of text element that is found there.

Parameters:
aType - The enumerated text type
aX - The X position of the pixel.
aY - The Y position of the pixel
aScrollX - The current X position of the scroll bar.
aScrollY - The current Y position of the scroll bar.
Returns:
The text at the specified location, null if the position is not over a text node

getText

public String getText(int aType,
                      int aIndex)
Get the text indicated by the 'type' and the position in the document given by 'index'. This provides the ability to 'get the text of the third paragraph', and 'get the 10000th char'. This method will update the cursor position to be at the last read text.

Parameters:
aType - The Enumerated text type
aIndex - The zero based text index of the given type
Returns:
The text of the given type. Null, if the index is out of range.

positionToIndex

public void positionToIndex(int aType,
                            int aIndex)
Position the caret to an element in the document. The index must be in the range of
0 <= index < getCount( aType )

Parameters:
aType - The element enumeration
aIndex - The index of the element

getCaretPosition

public int getCaretPosition(int aType)
Retrieve the current Caret position for an element type. Returns the current caret location as an index from the start of the rendered page in the range of
0 <= index < getCount( aType )

Parameters:
aType - The element enumeration
Returns:
The current caret location

getCharAttributes

public CharacterAttributes getCharAttributes(int aIndex)
Retrieve the CSS attributes for a character identified by its index.

Parameters:
aIndex - The index of the character in the range 0 < index < getCount(DocumentAccess.CHARACTER_TYPE)
Returns:
The CSSAttribs object describing the formatting for the character. Null if the Index is out of range

getIndexOfNode

public int getIndexOfNode(DNode node)
Given a node, returns the character index offset for that node.

Parameters:
node - the node of interest
Returns:
the character index of the node

getIndexAtPoint

public int getIndexAtPoint(int aX,
                           int aY,
                           int scrollX,
                           int scrollY)
Retrieve the character Index of a point X,Y on the screen, with a scroll bar position. Returns an index of the range of
0 <= index < getCount( aType ) if there is a character at the point or -1 if there is no character at that screen position

Returns:
The character index of the screen position, or -1 if none

getNodeByIndex

public DNode getNodeByIndex(int aType,
                            int aIndex)
Return the DOM Node associated with a particular element. Currently, one single sentence is can be associated with one node, but this is not necessarily guaranteed.

Parameters:
aType - the element enumeration
aIndex - The index of the element
Returns:
The DOM Node associated with the CSSBox containing the element

getNext

public String getNext(int aType)
Get the next entity of a given type. For the various types, this will move the cursor to just before the next element, and return that element.

Parameters:
aType - The enumerated type of text to retrieve
Returns:
The next text passage of the given type

getPrevious

public String getPrevious(int aType)
Retrieve the previous entity of a given type. For all types, this will move the cursor to just before the previous element, and return that element.

Parameters:
aType - The enumerated type of text to retrieve
Returns:
The previous text passage of the given type

getSelectionStart

public int getSelectionStart()
Get the index of the character that is the first in any selected passage of text. Selected is considered to be from left to right. If the user is dragging from right to left, it is the start index which will decrease.

Returns:
The char index in the document which is the starting point for selection.

getSelectionEnd

public int getSelectionEnd()
Retrieve the index of the character that is the last in any selected passage of text.

Returns:
The index of the final text selection character index

getSelectedText

public String getSelectedText()
Retrieve the text that is currently selected.

Returns:
The currently selected text from the document.

getCount

public int getCount(int aType)
Retrieve the number of chars, words, sentences, or paragraphs in the document

Parameters:
aType - The enumerated type to count
Returns:
The number of elements of aType found in the document.

setSelection

public void setSelection(int x1,
                         int y1,
                         int x2,
                         int y2)
Allows you to set a text selection on a page by specifying a bounding box (like a drag rectangle). This is a publicly exposed wrapper method that calls into CSSLayout.

Parameters:
x1 - starting x coordinate
y1 - starting y coordinate
x2 - ending x coordinate
y2 - ending y coordinate

setSelection

public void setSelection(int type,
                         int x,
                         int y)
Selects specified entity under the specified point on the screen.

Parameters:
x - the x coordinate
y - the y coordinate

selectWordByIndex

public void selectWordByIndex(int wordIndex)
Select the word given by the wordIndex. The range for the wordIndex argument falls in the range given by getCount( WORD ). This method will set the selection range to span the indicated word.

Parameters:
wordIndex - The index of the word that is selected