Class PageSplitter


  • public class PageSplitter
    extends java.lang.Object
    Utility class to help separate the spliting up of a text into lines and pages.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2013 Created on Aug 7, 2013
    • Field Detail

      • STYLES

        public static final java.lang.String[] STYLES
      • pageHeigth

        private final double pageHeigth
      • pageWidth

        private final double pageWidth
      • lineSpacing

        private final double lineSpacing
      • initialHeigth

        private final double initialHeigth
      • font

        private final javafx.scene.text.Font font
    • Constructor Detail

      • PageSplitter

        public PageSplitter​(double pageHeigth,
                            double pageWidth,
                            double lineSpacing,
                            double initialHeigth,
                            javafx.scene.text.Font font)
        Initialize the page splitter.
        Parameters:
        pageHeigth - height of a page
        pageWidth - width of a page
        lineSpacing - spacing between two lines
        initialHeigth - initial height of the page
        font - to be used.
    • Method Detail

      • overrideTextSizingUtility

        void overrideTextSizingUtility​(TextSizingUtility sizing)
        Override the sizing utility for test purposes.
        Parameters:
        sizing - service to calculate line length based on fonts.
      • setWordSplitter

        public void setWordSplitter​(IWordSplitter splitter)
      • splitIntoPages

        public java.util.List<Page> splitIntoPages​(Text text)
        Splitting up the text onto pages.
        Parameters:
        text - to be split
        Returns:
        list of Pages.
      • splitIntoPages

        private java.util.List<Page> splitIntoPages​(Text text,
                                                    boolean eliminateWhiteSpaces)
        Splitting up the text onto pages. Using the additional flag you can control the behavior on line setup. This becomes important on recursive calls, where a word was splitt and should be reassambled on a single line.
        Parameters:
        text - to be split
        eliminateWhiteSpaces - flag indicating if the words on a line should be concatenated (remove spaces)
        Returns:
        list of Pages.
      • isLineTooLong

        private boolean isLineTooLong​(double lineWidth)
      • updatePageHeight

        private double updatePageHeight​(java.lang.String line,
                                        double currentPageHeight)
        Compute the line height and add it to the page height.
        Parameters:
        line - to be checked
        currentPageHeight - current page height without line
        Returns:
        new page height