Package ghidra.util.bean.field

# Class AnnotatedTextFieldElement

java.lang.Object
docking.widgets.fieldpanel.field.AbstractTextFieldElement
ghidra.util.bean.field.AnnotatedTextFieldElement

All Implemented Interfaces:
  `FieldElement`

public final class AnnotatedTextFieldElement extends AbstractTextFieldElement
A subclass of `FieldElement` that allows for mouse handling callbacks via the `handleMouseClicked(Navigatable, ServiceProvider)` method. This class is based upon `Annotation` objects, which are elements that perform actions when the use clicks an instance of this class in the display.

- ## Field Summary

  ### Fields inherited from class docking.widgets.fieldpanel.field.AbstractTextFieldElement

  `attributedString, column, row`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AnnotatedTextFieldElement(Annotation annotation, AttributedString prototype, Program program, int row, int column)`
  Constructor that initializes this text field element with the given annotation and row and column information.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getCharacterIndexForDataLocation(int dataRow, int dataColumn)`
  Returns the character index appropriate for the given data location
  `RowColLocation`
  `getDataLocationForCharacterIndex(int characterIndex)`
  Translates the given character index to a data location related to the data model, as determined by the FieldFactory.
  `String`
  `getDisplayString()`
  `String`
  `getRawText()`
  Returns the original annotation text in the data model, which will differ from the display text.
  `boolean`
  `handleMouseClicked(Navigatable sourceNavigatable, ServiceProvider serviceProvider)`
  This method is designed to be called when a mouse click has occurred for a given `ProgramLocation`.
  `FieldElement`
  `replaceAll(char[] targets, char replacement)`
  Returns a new FieldElement with all occurrences of the target characters replaced with the given replacement character.
  `FieldElement`
  `substring(int start, int end)`
  Returns a new FieldElement containing just the characters beginning at the given start index (inclusive) and ending at the given end index (exclusive).

  ### Methods inherited from class docking.widgets.fieldpanel.field.AbstractTextFieldElement

  `charAt, getColor, getFieldElement, getHeightAbove, getHeightBelow, getMaxCharactersForWidth, getStringWidth, getText, length, paint, substring, toString`

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

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

- ## Constructor Details

  - ### AnnotatedTextFieldElement

    public AnnotatedTextFieldElement(Annotation annotation, AttributedString prototype, Program program, int row, int column)
    Constructor that initializes this text field element with the given annotation and row and column information. The text of this element is the display text created by the annotation handler for the given annotation.
    Parameters:
      `annotation` - The Annotation that this element is describing.
      `prototype` - the prototype string used to create new strings
      `program` - the program
      `row` - The row that this element is on
      `column` - The column value of this element (the column index where this element starts)

- ## Method Details

  - ### getRawText

    public String getRawText()
    Returns the original annotation text in the data model, which will differ from the display text.
    Returns:
      the original annotation text in the data model.

  - ### getDisplayString

    public String getDisplayString()

  - ### handleMouseClicked

    public boolean handleMouseClicked(Navigatable sourceNavigatable, ServiceProvider serviceProvider)
    This method is designed to be called when a mouse click has occurred for a given `ProgramLocation`.
    Parameters:
      `sourceNavigatable` - The source Navigatable
      `serviceProvider` - A service provider from which system resources can be retrieved
    Returns:
      true if this string handles the mouse click.

  - ### getDataLocationForCharacterIndex

    public RowColLocation getDataLocationForCharacterIndex(int characterIndex)
    Description copied from interface: `FieldElement`
    Translates the given character index to a data location related to the data model, as determined by the FieldFactory.
    Specified by:
      `getDataLocationForCharacterIndex` in interface `FieldElement`
    Overrides:
      `getDataLocationForCharacterIndex` in class `AbstractTextFieldElement`
    Parameters:
      `characterIndex` - The character index to translate.
    Returns:
      The data location in the model coordinates.

  - ### getCharacterIndexForDataLocation

    public int getCharacterIndexForDataLocation(int dataRow, int dataColumn)
    Description copied from interface: `FieldElement`
    Returns the character index appropriate for the given data location
    Specified by:
      `getCharacterIndexForDataLocation` in interface `FieldElement`
    Overrides:
      `getCharacterIndexForDataLocation` in class `AbstractTextFieldElement`
    Parameters:
      `dataRow` - the row in the data model as determined by the creating field factory.
      `dataColumn` - the column in the data model as determined by the creating field factory.
    Returns:
      the character index appropriate for the given data location; -1 if this field does not contain the given location

  - ### substring

    public FieldElement substring(int start, int end)
    Description copied from interface: `FieldElement`
    Returns a new FieldElement containing just the characters beginning at the given start index (inclusive) and ending at the given end index (exclusive).
    Parameters:
      `start` - The starting index (inclusive) from which to substring this element.
      `end` - The end index (exclusive) to which the substring will be performed.
    Returns:
      a new FieldElement containing just the characters beginning at the given index.

  - ### replaceAll

    public FieldElement replaceAll(char[] targets, char replacement)
    Description copied from interface: `FieldElement`
    Returns a new FieldElement with all occurrences of the target characters replaced with the given replacement character.
    Parameters:
      `targets` - The array of characters to replace.
      `replacement` - The replacement character.
    Returns:
      a new FieldElement with all occurrences of the target characters replaced with the given replacement character.