Interface TwoDimensional.Position

  • Enclosing interface:
    TwoDimensional

    public static interface TwoDimensional.Position
    A two dimensional position, with a major offset (such as a paragraph index within a document) and a minor dimension (such as a segment index or column position within a paragraph). Major and minor positions begin at 0.
    • Method Detail

      • getTargetObject

        TwoDimensional getTargetObject()
        The TwoDimensional object that this position refers to.
      • getMajor

        int getMajor()
        The major dimension, e.g. paragraph number within a document
      • getMinor

        int getMinor()
        The minor dimension, e.g. segment index or column offset within a paragraph.
      • sameAs

        boolean sameAs​(TwoDimensional.Position other)
        Returns true if the given position is equal to this position, that is they both point to the same place in the same two-dimensional object. Otherwise returns false.
      • clamp

        TwoDimensional.Position clamp()
        Returns a new position which clamps the minor position to be valid given the major position. (i.e. if the position is beyond the end of a given paragraph, moves the position back to the end of the paragraph).
      • toOffset

        int toOffset()
        Converts this position to an overall offset within the original TwoDimensional item (to which getTargetObject() refers). For example, moving a caret to a relative position (paragraph 2, column 3) might result in the offset value (absolute position) of 28.