Class BreakPointHandler


  • public class BreakPointHandler
    extends Object
    Breaks a paragraph of text into rows. It is assumed that all preferred break points are supplied with the input string.

    Soft hyphen (0x00ad) and zero width space (0x200b) characters can also be used for non-standard hyphenation.

    Soft hyphen (0x00ad), zero width space (0x200b), dash (0x002d) and space are used to determine an appropriate break point. Soft hyphens are removed in the result.

    • Constructor Detail

      • BreakPointHandler

        public BreakPointHandler​(String str)
        Create a new BreakPointHandler. All preferred break points must be in supplied with the input String, represented by hyphen 0x2d, soft hyphen 0xad or space 0x20.
        Parameters:
        str - the paragraph to break into rows.
    • Method Detail

      • copy

        public BreakPointHandler copy()
        Creates a new copy of this object in its current state.
        Returns:
        returns a new instance
      • mark

        public void mark()
        Marks the current state for later use with reset().
      • reset

        public void reset()
        Resets the state to the last call to mark(), or the initial state, if no call to mark has been made.
      • nextRow

        public BreakPoint nextRow​(int breakPoint,
                                  boolean force)
        Gets the next row from this BreakPointHandler.
        Parameters:
        breakPoint - the desired breakpoint for this row
        force - if force is allowed if no breakpoint is found
        Returns:
        returns the next BreakPoint
      • nextRow

        public BreakPoint nextRow​(int breakPoint,
                                  boolean force,
                                  boolean ignoreHyphens)
        Gets the next row from this BreakPointHandler.
        Parameters:
        breakPoint - the desired breakpoint for this row
        force - if force is allowed if no breakpoint is found
        ignoreHyphens - ignore hyphenation points inside words
        Returns:
        returns the next break point
      • countRemaining

        public int countRemaining()
        Counts the remaining characters, excluding unused breakpoints.
        Returns:
        returns the number of remaining characters
      • getRemaining

        public String getRemaining()
        Gets the remaining characters, removing unused breakpoint characters.
        Returns:
        returns the remaining characters
      • hasNext

        public boolean hasNext()
        Does this BreakPointHandler has any text left to break into rows.
        Returns:
        returns true if this BreakPointHandler has any text left to break into rows