Class PageSequenceBuilder2


  • public class PageSequenceBuilder2
    extends Object

    Given a BlockSequence, produces Page objects one by one. The pages are obtained through a "iterator" interface.

    • Performs page breaking.
    • Constructs any "page-area" areas and fills it with collection items that are referenced from anchors on this page.
    • Adds any header and footer lines. (This is done in PageImpl.)
    • Adds "margin-region" columns. (This is done in PageImpl.)
    • Adds any "volume-transition" content (sequence-interrupted, sequence-resumed, any-interrupted and/or any-resumed).
      Note that block-interrupted and block-resumed are currently not implemented.

    The input is a sequence of blocks, which are first converted to a sequence of RowGroupSequence. If a sequence has multiple possible scenarios the best one is selected. Every RowGroupSequence either starts on a new sheet, a new page, or on a specific position on the page. A RowGroupSequence that does not fit on the page is broken, using SplitPointHandler. The cost function takes into account the gap at the bottom of the page, whether the isBreakable and RowGroup.getAvoidVolumeBreakAfterPriority() constraints of the last RowGroup are violated, and whether we're breaking inside a block that can not flow around header/footer fields while the header/footer does allow it.

    The computed VolumeKeepPriority of page is the maximum value (lowest priority) of all RowGroups on that page. Discarded RowGroups (i.e. collapsed margins) are also taken into account.

    • Constructor Detail

      • PageSequenceBuilder2

        public PageSequenceBuilder2​(int fromIndex,
                                    LayoutMaster master,
                                    int pageOffset,
                                    BlockSequence seq,
                                    FormatterContext context,
                                    DefaultContext rcontext,
                                    SequenceId seqId,
                                    BlockLineLocation blc)
        Parameters:
        fromIndex - "Index" of the first page of this PageSequenceBuilder. The exact value does not matter for PageSequenceBuilder2 itself, but SheetDataSource requires that the values returned by getGlobalStartIndex() and getToIndex() match the provided value. The value passed by SheetDataSource is the number of pages that either the whole body, or the pre- or post-content of the current volume, already contains.
        master - the layout master
        pageOffset - see the pageNumberOffset parameter in nextPage.
        seq - the input block sequence
        context - ?
        rcontext - ?
        seqId - identifier/position of the block sequence
        blc - The BlockLineLocation of the last line of the previous PageSequenceBuilder2, or null if there is no previous PageSequenceBuilder2.
    • Method Detail

      • setCurrentVolumeNumber

        public void setCurrentVolumeNumber​(int volume)
      • nextPageId

        public PageId nextPageId​(int offset)
        Gets a new PageId representing the next page in this sequence.
        Parameters:
        offset - the offset
        Returns:
        returns the next page Id
      • currentBlockLineLocation

        public BlockLineLocation currentBlockLineLocation()
        Returns:
        The BlockLineLocation of the last line of the page that was produced last (by this PageSequenceBuilder2 or the previous one), or null if no page has been produced yet.
      • hasNext

        public boolean hasNext()
      • nextPage

        public PageImpl nextPage​(int pageNumberOffset,
                                 boolean hyphenateLastLine,
                                 Optional<TransitionContent> transitionContent,
                                 boolean wasSplitInSequence,
                                 boolean isFirst)
                          throws PaginatorException,
                                 RestartPaginationException
        Parameters:
        pageNumberOffset - Page number corresponding to the first page of this PageSequenceBuilder2 minus 1, if the page numbering would be continuous between the first and the current page. This does not necessarily match the actual page number of the produced page, because for instance when a volume break happens inside a sequence, there can be a jump in the page numbering.
        hyphenateLastLine - Whether to allow the last line on the page to end on a hyphenation point (may be the case on the last page of the volume).
        transitionContent - Content to be inserted at the top (any-resumed and/or sequence-resumed) or at the bottom of the page (any-interrupted and/or sequence-interrupted). any-resumed is only enabled if isFirst is not true, sequence-resumed is only enabled if wasSplitInSequence is true, sequence-interrupted is only enabled if the page is broken within the sequence.
        wasSplitInSequence - see above
        isFirst - see above
        Returns:
        the next page
        Throws:
        PaginatorException
        RestartPaginationException
      • getSizeLast

        public int getSizeLast()
      • getSizeLast

        public int getSizeLast​(int fromIndex)
        Returns the number of supplied pages since fromIndex (getToIndex() - fromIndex), rounded to an even number if duplex, i.e. in the case of duplex it represents twice the number of sheets needed to contain the supplied pages since fromIndex (assuming that the first page after fromIndex starts on the front side of the first sheet).
        Parameters:
        fromIndex - a page index
        Returns:
        a number of pages
      • size

        public int size()
        Returns the number of supplied pages.
        Returns:
        a number of pages
      • getToIndex

        public int getToIndex()
        Returns the index of the page that will be (or "would" be) supplied next, provided that getGlobalStartIndex() is the index of the first page minus 1.
        Returns:
        a page index