Class PageSequenceBuilder2
- java.lang.Object
-
- org.daisy.dotify.formatter.impl.page.PageSequenceBuilder2
-
public class PageSequenceBuilder2 extends Object
Given a
BlockSequence, producesPageobjects 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 inPageImpl.) - Adds any "
volume-transition" content (sequence-interrupted,sequence-resumed,any-interruptedand/orany-resumed).
Note thatblock-interruptedandblock-resumedare 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. EveryRowGroupSequenceeither starts on a new sheet, a new page, or on a specific position on the page. ARowGroupSequencethat does not fit on the page is broken, usingSplitPointHandler. The cost function takes into account the gap at the bottom of the page, whether theisBreakableandRowGroup.getAvoidVolumeBreakAfterPriority()constraints of the lastRowGroupare 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
VolumeKeepPriorityof page is the maximum value (lowest priority) of allRowGroups on that page. DiscardedRowGroups (i.e. collapsed margins) are also taken into account.
-
-
Constructor Summary
Constructors Constructor Description PageSequenceBuilder2(int fromIndex, LayoutMaster master, int pageOffset, BlockSequence seq, FormatterContext context, DefaultContext rcontext, SequenceId seqId, BlockLineLocation blc)PageSequenceBuilder2(PageSequenceBuilder2 template)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PageSequenceBuilder2copyUnlessNull(PageSequenceBuilder2 template)BlockLineLocationcurrentBlockLineLocation()intgetGlobalStartIndex()Returns the provided value offromIndexinPageSequenceBuilder2(int, LayoutMaster, int, BlockSequence, FormatterContext, DefaultContext, SequenceId, BlockLineLocation).intgetSizeLast()intgetSizeLast(int fromIndex)Returns the number of supplied pages sincefromIndex(getToIndex()-fromIndex), rounded to an even number if duplex, i.e.intgetToIndex()Returns the index of the page that will be (or "would" be) supplied next, provided thatgetGlobalStartIndex()is the index of the first page minus 1.booleanhasNext()PageImplnextPage(int pageNumberOffset, boolean hyphenateLastLine, Optional<TransitionContent> transitionContent, boolean wasSplitInSequence, boolean isFirst)PageIdnextPageId(int offset)Gets a new PageId representing the next page in this sequence.voidsetCurrentVolumeNumber(int volume)intsize()Returns the number of supplied pages.
-
-
-
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 thisPageSequenceBuilder. The exact value does not matter forPageSequenceBuilder2itself, butSheetDataSourcerequires that the values returned bygetGlobalStartIndex()andgetToIndex()match the provided value. The value passed bySheetDataSourceis the number of pages that either the whole body, or the pre- or post-content of the current volume, already contains.master- the layout masterpageOffset- see thepageNumberOffsetparameter innextPage.seq- the input block sequencecontext- ?rcontext- ?seqId- identifier/position of the block sequenceblc- TheBlockLineLocationof the last line of the previous PageSequenceBuilder2, or null if there is no previous PageSequenceBuilder2.
-
PageSequenceBuilder2
public PageSequenceBuilder2(PageSequenceBuilder2 template)
-
-
Method Detail
-
copyUnlessNull
public static PageSequenceBuilder2 copyUnlessNull(PageSequenceBuilder2 template)
-
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 thisPageSequenceBuilder2minus 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 ifisFirstis nottrue, sequence-resumed is only enabled ifwasSplitInSequenceistrue, sequence-interrupted is only enabled if the page is broken within the sequence.wasSplitInSequence- see aboveisFirst- see above- Returns:
- the next page
- Throws:
PaginatorExceptionRestartPaginationException
-
getSizeLast
public int getSizeLast()
-
getSizeLast
public int getSizeLast(int fromIndex)
Returns the number of supplied pages sincefromIndex(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 sincefromIndex(assuming that the first page afterfromIndexstarts 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
-
getGlobalStartIndex
public int getGlobalStartIndex()
Returns the provided value offromIndexinPageSequenceBuilder2(int, LayoutMaster, int, BlockSequence, FormatterContext, DefaultContext, SequenceId, BlockLineLocation).- Returns:
- a page index
-
getToIndex
public int getToIndex()
Returns the index of the page that will be (or "would" be) supplied next, provided thatgetGlobalStartIndex()is the index of the first page minus 1.- Returns:
- a page index
-
-