Class MTextDocument.Portion

java.lang.Object
chemaxon.struc.graphics.MTextDocument.Portion
Enclosing class:
MTextDocument

public class MTextDocument.Portion extends Object
Selected text.
  • Method Details

    • getStartPos

      public final int getStartPos()
      Gets the position of the first character.
      Returns:
      the start index
    • getEndPos

      public final int getEndPos()
      Gets the position of the last character + 1.
      Returns:
      the end index
    • length

      public final int length()
      Gets the number of characters.
      Returns:
      the length
    • portionWidth

      public final double portionWidth(Graphics g, MFont dmfont, FontMetrics fm0)
      Gets the width of this portion.
      Parameters:
      g - the graphics context or null
      fm0 - default font metrics
      Returns:
      the width
    • portionXAdvance

      public final double portionXAdvance(Graphics g, MFont dmf, FontMetrics fm0)
      Gets the x coordinate change from the beginning to the end of this portion.
      Parameters:
      g - the graphics context or null
      fm0 - default font metrics
      Returns:
      the width
    • portionXAdvance

      public final double portionXAdvance(Graphics g, MFont dmfont, FontMetrics fm0, boolean lastxadv)
      Gets the width of this portion.
      Parameters:
      g - the graphics context or null
      fm0 - default font metrics
      lastxadv - whether to calculate the x advance for the next section beginning at the last character
      Returns:
      the width
    • getEndDx

      public final double getEndDx()
      Gets the x shift at the end. It can be nonzero only if a new section starts at the end of this portion. This method should only be called after portionWidth.
      Returns:
      the x shift
    • getAscent

      public final double getAscent(Graphics g, FontMetrics fm0)
      Gets the ascent of this portion.
      Parameters:
      g - the graphics context or null
      fm0 - default font metrics
      Returns:
      the ascent
    • getDescent

      public final double getDescent(Graphics g, FontMetrics fm0)
      Gets the descent of this portion.
      Parameters:
      g - the graphics context or null
      fm0 - default font metrics
      Returns:
      the descent
    • getPortion

      public final MTextDocument.Portion getPortion(int start, int end)
      Gets a portion of the text relative to this portion.
      Parameters:
      start - relative start position
      end - relative end position
      Returns:
      the portion
    • getPlainText

      public final String getPlainText()
      Gets the selected text as a plain text string.
      Returns:
      the text
    • toString

      public final String toString()
      Gets the string representation of the portion.
      Overrides:
      toString in class Object
      Returns:
      the string
    • endsWith

      public boolean endsWith(char c)
      Tests whether this text portion ends with the specified character.
      Parameters:
      c - the character
      Returns:
      true if c is the last character, false otherwise