Class PageSequenceBuilder2
- java.lang.Object
-
- org.daisy.dotify.formatter.impl.page.PageSequenceBuilder2
-
public class PageSequenceBuilder2 extends Object
Given a
BlockSequence
, producesPage
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 inPageImpl
.) - Adds any "
volume-transition
" content (sequence-interrupted
,sequence-resumed
,any-interrupted
and/orany-resumed
).
Note thatblock-interrupted
andblock-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. EveryRowGroupSequence
either starts on a new sheet, a new page, or on a specific position on the page. ARowGroupSequence
that does not fit on the page is broken, usingSplitPointHandler
. The cost function takes into account the gap at the bottom of the page, whether theisBreakable
andRowGroup.getAvoidVolumeBreakAfterPriority()
constraints of the lastRowGroup
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 allRowGroup
s on that page. DiscardedRowGroup
s (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 PageSequenceBuilder2
copyUnlessNull(PageSequenceBuilder2 template)
BlockLineLocation
currentBlockLineLocation()
int
getGlobalStartIndex()
Returns the provided value offromIndex
inPageSequenceBuilder2(int, LayoutMaster, int, BlockSequence, FormatterContext, DefaultContext, SequenceId, BlockLineLocation)
.int
getSizeLast()
int
getSizeLast(int fromIndex)
Returns the number of supplied pages sincefromIndex
(getToIndex()
-fromIndex
), rounded to an even number if duplex, i.e.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.boolean
hasNext()
PageImpl
nextPage(int pageNumberOffset, boolean hyphenateLastLine, Optional<TransitionContent> transitionContent, boolean wasSplitInSequence, boolean isFirst)
PageId
nextPageId(int offset)
Gets a new PageId representing the next page in this sequence.void
setCurrentVolumeNumber(int volume)
int
size()
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 forPageSequenceBuilder2
itself, butSheetDataSource
requires that the values returned bygetGlobalStartIndex()
andgetToIndex()
match the provided value. The value passed bySheetDataSource
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 masterpageOffset
- see thepageNumberOffset
parameter innextPage
.seq
- the input block sequencecontext
- ?rcontext
- ?seqId
- identifier/position of the block sequenceblc
- TheBlockLineLocation
of 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 thisPageSequenceBuilder2
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 ifisFirst
is nottrue
, sequence-resumed is only enabled ifwasSplitInSequence
istrue
, sequence-interrupted is only enabled if the page is broken within the sequence.wasSplitInSequence
- see aboveisFirst
- 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 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 afterfromIndex
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
-
getGlobalStartIndex
public int getGlobalStartIndex()
Returns the provided value offromIndex
inPageSequenceBuilder2(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
-
-