Class PageProvider

  • All Implemented Interfaces:
    Constants

    public class PageProvider
    extends java.lang.Object
    implements Constants

    This class delivers Page instances. It also caches them as necessary.

    Additional functionality makes sure that surplus instances that are requested by the page breaker are properly discarded, especially in situations where hard breaks cause blank pages. The reason for that: The page breaker sometimes needs to preallocate additional pages since it doesn't know exactly until the end how many pages it really needs.

    • Field Detail

      • RELTO_PAGE_SEQUENCE

        public static final int RELTO_PAGE_SEQUENCE
        Indices are evaluated relative to the first page in the page-sequence.
        See Also:
        Constant Field Values
      • RELTO_CURRENT_ELEMENT_LIST

        public static final int RELTO_CURRENT_ELEMENT_LIST
        Indices are evaluated relative to the first page in the current element list.
        See Also:
        Constant Field Values
      • skipPagePositionOnly

        protected boolean skipPagePositionOnly
    • Constructor Detail

      • PageProvider

        public PageProvider​(AreaTreeHandler ath,
                            PageSequence ps)
        Main constructor.
        Parameters:
        ath - the area tree handler
        ps - The page-sequence the provider operates on
    • Method Detail

      • initialize

        public void initialize()
      • setStartOfNextElementList

        public void setStartOfNextElementList​(int startPage,
                                              int startColumn,
                                              boolean spanAll)
        The page breaker notifies the provider about the page number an element list starts on so it can later retrieve PageViewports relative to this first page.
        Parameters:
        startPage - the number of the first page for the element list.
        startColumn - the starting column number for the element list.
        spanAll - true if the current element list is for a column-spanning section
      • setLastPageIndex

        public void setLastPageIndex​(int index)
        Sets the index of the last page. This is done as soon as the position of the last page is known or assumed.
        Parameters:
        index - the index relative to the first page in the page-sequence
      • getAvailableBPD

        public int getAvailableBPD​(int index)
        Returns the available BPD for the part/page indicated by the index parameter. The index is the part/page relative to the start of the current element list. This method takes multiple columns into account.
        Parameters:
        index - zero-based index of the requested part/page
        Returns:
        the available BPD
      • compareIPDs

        public int compareIPDs​(int index)
        Compares the IPD of the given part with the following one.
        Parameters:
        index - index of the current part
        Returns:
        a negative integer, zero or a positive integer as the current IPD is less than, equal to or greater than the IPD of the following part
      • getStartingPartIndexForLastPage

        public int getStartingPartIndexForLastPage​(int partCount)
        Returns the part index (0<x<partCount) which denotes the first part on the last page generated by the current element list.
        Parameters:
        partCount - Number of parts determined by the breaking algorithm
        Returns:
        the requested part index
      • getPage

        public Page getPage​(boolean isBlank,
                            int index,
                            int relativeTo)
        Returns a Page.
        Parameters:
        isBlank - true if this page is supposed to be blank.
        index - Index of the page (see relativeTo)
        relativeTo - Defines which value the index parameter should be evaluated relative to. (One of PageProvider.RELTO_*)
        Returns:
        the requested Page
      • getPage

        protected Page getPage​(boolean isBlank,
                               int index)
        Returns a Page.
        Parameters:
        isBlank - true if the Page should be a blank one
        index - the Page's index
        Returns:
        a Page instance
      • discardCacheStartingWith

        protected void discardCacheStartingWith​(int index)
      • getIndexOfCachedLastPage

        public int getIndexOfCachedLastPage()
      • getLastPageIndex

        public int getLastPageIndex()
      • getLastPageIPD

        public int getLastPageIPD()
      • getCurrentIPD

        public int getCurrentIPD()