Package docking.widgets.fieldpanel

# Class AccessibleFieldPanelDelegate

java.lang.Object
docking.widgets.fieldpanel.AccessibleFieldPanelDelegate

public class AccessibleFieldPanelDelegate extends Object
Contains all the code for implementing the AccessibleFieldPanel which is an inner class in the FieldPanel class. The AccessibleFieldPanel has to be declared as an inner class because it needs to extend AccessibleJComponent which is a non-static inner class of JComponent. However, we did not want to put all the logic in there as FieldPanel is already an extremely large and complex class. Also, by delegating the logic, testing is much easier.

The model for accessibility for the FieldPanel is a bit complex because the field panel displays text, but in a 2 dimensional array of fields, where each field has potentially 2 dimensional text. So for the purpose of accessibility, the FieldPanel acts as both a text field and a text component.

To support screen readers reacting to cursor movements in the FieldPanel, the FieldPanel acts like a text field, but it acts like it only has the text of one inner Field at a time (The one where the cursor is). The other approach that was considered was to treat the field panel as a single text document. This would be difficult to implement because of the way fields are multi-lined. Also, the user of the screen reader would lose all concepts that there are fields. By maintaining the fields as a concept to the screen reader, it can provide more meaningful descriptions as the cursor is moved between fields.

The Field panel also acts as an `AccessibleComponent` with virtual children for each of its visible fields. This is what allows screen readers to read the context of whatever the mouse is hovering over keeping the data separated by the field boundaries.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AccessibleFieldPanelDelegate(List<AnchoredLayout> layouts, AccessibleContext context, FieldPanel panel)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Accessible`
  `getAccessibleAt(Point p)`
  Returns the `AccessibleField` that is at the given point relative to the FieldPanel.
  `AccessibleField`
  `getAccessibleField(int fieldNum)`
  Returns the n'th AccessibleField that is visible on the screen.
  `AccessibleField`
  `getAccessibleField(FieldLocation loc)`
  Returns the AccessibleField associated with the given field location.
  `String`
  `getAfterIndex(int part, int index)`
  Returns the char, word, or sentence after the given char index.
  `String`
  `getAtIndex(int part, int index)`
  Returns the char, word, or sentence at the given char index.
  `String`
  `getBeforeIndex(int part, int index)`
  Returns the char, word, or sentence at the given char index.
  `int`
  `getCaretPosition()`
  Returns the caret position relative the current active field.
  `Rectangle`
  `getCharacterBounds(int index)`
  Return the bounds relative to the field panel for the character at the given index
  `int`
  `getCharCount()`
  Returns the number of characters in the current active field.
  `int`
  `getFieldCount()`
  Returns the number of visible field showing on the screen in the field panel.
  `String`
  `getFieldDescription()`
  Returns a description of the current field
  `int`
  `getIndexAtPoint(Point p)`
  Returns the character index at the given point relative to the FieldPanel.
  `String`
  `getSelectedText()`
  Returns either null if the field is not selected or the full field text if it is selected.
  `int`
  `getSelectionEnd()`
  Returns the selection character end index.
  `int`
  `getSelectionStart()`
  Returns the selection character start index.
  `void`
  `setCaret(FieldLocation newCursorLoc, EventTrigger trigger)`
  Tells this delegate that the cursor moved.
  `void`
  `setFieldDescriptionProvider(FieldDescriptionProvider provider)`
  Sets the `FieldDescriptionProvider` that can generate descriptions of the current field.
  `void`
  `setLayouts(List<AnchoredLayout> layouts)`
  Whenever the set of visible layouts changes, the field panel rebuilds its info for the new visible fields and notifies the accessibility system that its children changed.
  `void`
  `setSelection(FieldSelection currentSelection, EventTrigger trigger)`
  Tells this delegate that the selection has changed.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### AccessibleFieldPanelDelegate

    public AccessibleFieldPanelDelegate(List<AnchoredLayout> layouts, AccessibleContext context, FieldPanel panel)

- ## Method Details

  - ### setLayouts

    public void setLayouts(List<AnchoredLayout> layouts)
    Whenever the set of visible layouts changes, the field panel rebuilds its info for the new visible fields and notifies the accessibility system that its children changed.
    Parameters:
      `layouts` - the new set of visible layouts.

  - ### setCaret

    public void setCaret(FieldLocation newCursorLoc, EventTrigger trigger)
    Tells this delegate that the cursor moved. It updates its internal state and fires events to the accessibility system.
    Parameters:
      `newCursorLoc` - the new FieldLoation of the cursor
      `trigger` - the event trigger

  - ### setSelection

    public void setSelection(FieldSelection currentSelection, EventTrigger trigger)
    Tells this delegate that the selection has changed. If the current field is in the selection, it sets the current AccessibleField to be selected. (A field is either entirely selected or not)
    Parameters:
      `currentSelection` - the new current field panel selection
      `trigger` - the event trigger

  - ### getCaretPosition

    public int getCaretPosition()
    Returns the caret position relative the current active field.
    Returns:
      the caret position relative the current active field

  - ### getCharCount

    public int getCharCount()
    Returns the number of characters in the current active field.
    Returns:
      the number of characters in the current active field.

  - ### getAccessibleField

    public AccessibleField getAccessibleField(int fieldNum)
    Returns the n'th AccessibleField that is visible on the screen.
    Parameters:
      `fieldNum` - the number of the field to get
    Returns:
      the n'th AccessibleField that is visible on the screen

  - ### getAccessibleField

    public AccessibleField getAccessibleField(FieldLocation loc)
    Returns the AccessibleField associated with the given field location.
    Parameters:
      `loc` - the FieldLocation to get the visible field for
    Returns:
      the AccessibleField associated with the given field location

  - ### getCharacterBounds

    public Rectangle getCharacterBounds(int index)
    Return the bounds relative to the field panel for the character at the given index
    Parameters:
      `index` - the index of the character in the active field whose bounds is to be returned.
    Returns:
      the bounds relative to the field panel for the character at the given index

  - ### getIndexAtPoint

    public int getIndexAtPoint(Point p)
    Returns the character index at the given point relative to the FieldPanel. Note this only returns chars in the active field.
    Parameters:
      `p` - the point to get the character for
    Returns:
      the character index at the given point relative to the FieldPanel.

  - ### getAtIndex

    public String getAtIndex(int part, int index)
    Returns the char, word, or sentence at the given char index.
    Parameters:
      `part` - specifies char, word or sentence (See `AccessibleText`)
      `index` - the character index to get data for
    Returns:
      the char, word, or sentences at the given char index

  - ### getAfterIndex

    public String getAfterIndex(int part, int index)
    Returns the char, word, or sentence after the given char index.
    Parameters:
      `part` - specifies char, word or sentence (See `AccessibleText`)
      `index` - the character index to get data for
    Returns:
      the char, word, or sentence after the given char index

  - ### getBeforeIndex

    public String getBeforeIndex(int part, int index)
    Returns the char, word, or sentence at the given char index.
    Parameters:
      `part` - specifies char, word or sentence (See `AccessibleText`)
      `index` - the character index to get data for
    Returns:
      the char, word, or sentence at the given char index

  - ### getFieldCount

    public int getFieldCount()
    Returns the number of visible field showing on the screen in the field panel.
    Returns:
      the number of visible field showing on the screen in the field panel

  - ### getAccessibleAt

    public Accessible getAccessibleAt(Point p)
    Returns the `AccessibleField` that is at the given point relative to the FieldPanel.
    Parameters:
      `p` - the point to get an Accessble child at
    Returns:
      the `AccessibleField` that is at the given point relative to the FieldPanel

  - ### getFieldDescription

    public String getFieldDescription()
    Returns a description of the current field
    Returns:
      a description of the current field

  - ### setFieldDescriptionProvider

    public void setFieldDescriptionProvider(FieldDescriptionProvider provider)
    Sets the `FieldDescriptionProvider` that can generate descriptions of the current field.
    Parameters:
      `provider` - the description provider

  - ### getSelectionStart

    public int getSelectionStart()
    Returns the selection character start index. This currently always returns 0 as selections are all or nothing.
    Returns:
      the selection character start index.

  - ### getSelectionEnd

    public int getSelectionEnd()
    Returns the selection character end index. This is either 0, indicating there is no selection or the index at the end of the text meaning the entire field is selected.
    Returns:
      the selection character start index.

  - ### getSelectedText

    public String getSelectedText()
    Returns either null if the field is not selected or the full field text if it is selected.
    Returns:
      either null if the field is not selected or the full field text if it is selected