Class TextPointer

java.lang.Object
eu.svjatoslav.sixth.e3d.gui.TextPointer
All Implemented Interfaces:
Comparable<TextPointer>

public class TextPointer extends Object implements Comparable<TextPointer>
A pointer to a character in a text using row and column.

It can be used to represent a cursor position in a text. Also, it can be used to represent beginning and end of a selection.

  • Field Details

    • row

      public int row
      The row of the character. Starts from 0.
    • column

      public int column
      The column of the character. Starts from 0.
  • Constructor Details

    • TextPointer

      public TextPointer()
    • TextPointer

      public TextPointer(int row, int column)
    • TextPointer

      public TextPointer(TextPointer parent)
  • Method Details

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(TextPointer textPointer)
      Compares this pointer to another pointer.
      Specified by:
      compareTo in interface Comparable<TextPointer>
      Parameters:
      textPointer - The pointer to compare to.
      Returns:
      • -1 if this pointer is smaller than the argument pointer.
      • 0 if they are equal.
      • 1 if this pointer is bigger than the argument pointer.
    • isBetween

      public boolean isBetween(TextPointer start, TextPointer end)
      Checks if this pointer is between the argument pointers.

      This pointer is considered to be between the pointers if it is bigger or equal to the start pointer and smaller than the end pointer.

      Parameters:
      start - The start pointer.
      end - The end pointer.
      Returns:
      True if this pointer is between the specified pointers.