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()
      Creates a text pointer at position (0, 0).
    • TextPointer

      public TextPointer(int row, int column)
      Creates a text pointer at the specified row and column.
      Parameters:
      row - the row index (0-based)
      column - the column index (0-based)
    • TextPointer

      public TextPointer(TextPointer parent)
      Creates a text pointer by copying another text pointer.
      Parameters:
      parent - the text pointer to copy
  • 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.