Class TextChunk

All Implemented Interfaces:
Shape, Serializable, Cloneable, HasText

public class TextChunk extends RectangularTextContainer<TextElement>
See Also:
  • Field Details

    • EMPTY

      public static final TextChunk EMPTY
  • Constructor Details

    • TextChunk

      public TextChunk(float top, float left, float width, float height)
    • TextChunk

      public TextChunk(TextElement textElement)
    • TextChunk

      public TextChunk(List<TextElement> textElements)
  • Method Details

    • groupByDirectionality

      public TextChunk groupByDirectionality(Boolean isLtrDominant)
      Splits a TextChunk into N TextChunks, where each chunk is of a single directionality, and then reverse the RTL ones. what we're doing here is *reversing* the Unicode bidi algorithm in the language of that algorithm, each chunk is a (maximal) directional run. We attach whitespace to the beginning of non-RTL
    • isLtrDominant

      public int isLtrDominant()
      Overrides:
      isLtrDominant in class Rectangle
    • merge

      public TextChunk merge(TextChunk other)
    • add

      public void add(TextElement textElement)
    • add

      public void add(List<TextElement> elements)
    • getText

      public String getText()
      Specified by:
      getText in interface HasText
      Overrides:
      getText in class RectangularTextContainer<TextElement>
    • getText

      public String getText(boolean useLineReturns)
      Specified by:
      getText in interface HasText
      Overrides:
      getText in class RectangularTextContainer<TextElement>
    • isSameChar

      public boolean isSameChar(Character c)
      Returns true if text contained in this TextChunk is the same repeated character
    • isSameChar

      public boolean isSameChar(Character[] c)
    • splitAt

      public TextChunk[] splitAt(int i)
      Splits a TextChunk in two, at the position of the i-th TextElement
    • squeeze

      public List<TextChunk> squeeze(Character c, int minRunLength)
      Removes runs of identical TextElements in this TextChunk For example, if the TextChunk contains this string of characters: "1234xxxxx56xx" and c == 'x' and minRunLength == 4, this method will return a list of TextChunk such that: ["1234", "56xx"]
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Rectangle2D
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Rectangle2D
    • allSameChar

      public static boolean allSameChar(List<TextChunk> textChunks)
    • groupByLines

      public static List<Line> groupByLines(List<TextChunk> textChunks)