Package org.apache.fop.layoutmgr
Class AbstractBreaker
- java.lang.Object
-
- org.apache.fop.layoutmgr.AbstractBreaker
-
- Direct Known Subclasses:
LocalBreaker
,PageBreaker
public abstract class AbstractBreaker extends java.lang.Object
Abstract base class for breakers (page breakers, static region handlers etc.).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractBreaker.BlockSequence
Helper class, extending the functionality of the basicBlockKnuthSequence
.static class
AbstractBreaker.FloatPosition
static class
AbstractBreaker.PageBreakPosition
A page break position.
-
Field Summary
Fields Modifier and Type Field Description protected int
alignment
desired text alignmentprotected int
blockListIndex
blockListIndex of the current BlockSequence in blockListsprotected java.util.List<AbstractBreaker.BlockSequence>
blockLists
protected java.util.List
firstElementsForRestart
protected MinOptMax
footnoteSeparatorLength
footnote separator lengthprotected static org.apache.commons.logging.Log
log
logging instanceprotected LayoutManager
originalRestartAtLM
protected Position
positionAtBreak
protected PageSequenceLayoutManager
pslm
-
Constructor Summary
Constructors Constructor Description AbstractBreaker()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addAreas(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, int startPart, int partCount, AbstractBreaker.BlockSequence originalList, AbstractBreaker.BlockSequence effectiveList)
protected void
addAreas(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, int startPart, int partCount, AbstractBreaker.BlockSequence originalList, AbstractBreaker.BlockSequence effectiveList, LayoutContext childLC)
Phase 3 of Knuth algorithm: Adds the areasprotected void
addAreas(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, int partCount, AbstractBreaker.BlockSequence originalList, AbstractBreaker.BlockSequence effectiveList)
Phase 3 of Knuth algorithm: Adds the areasprotected abstract void
addAreas(PositionIterator posIter, LayoutContext context)
Tell the layout manager to add all the child areas implied by Position objects which will be returned by the Iterator.protected void
addAreasForFloats(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, int startPart, int partCount, AbstractBreaker.BlockSequence originalList, AbstractBreaker.BlockSequence effectiveList, LayoutContext childLC, int lastBreak, int startElementIndex, int endElementIndex)
protected boolean
containsNonRestartableLM(Position position)
Returnstrue
if the given position or one of its descendants corresponds to a non-restartable LM.protected LayoutContext
createLayoutContext()
Creates the top-level LayoutContext for the breaker operation.protected org.apache.fop.layoutmgr.PageBreakingAlgorithm.PageBreakingLayoutListener
createLayoutListener()
Creates and returns a PageBreakingLayoutListener for the PageBreakingAlgorithm to notify about layout problems.boolean
doLayout(int flowBPD, boolean autoHeight)
Starts the page breaking process.protected abstract void
doPhase3(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, int partCount, AbstractBreaker.BlockSequence originalList, AbstractBreaker.BlockSequence effectiveList)
Phase 3 of Knuth algorithm: Adds the areasprotected abstract void
finishPart(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, AbstractBreaker.PageBreakPosition pbp)
Finish part.protected abstract LayoutManager
getCurrentChildLM()
protected abstract int
getCurrentDisplayAlign()
protected int
getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn)
Gets the next block list (sequence) and adds it to a list of block lists if it's not empty.protected int
getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn, Position positionAtIPDChange, LayoutManager restartAtLM, java.util.List<KnuthElement> firstElements)
Gets the next block list (sequence) and adds it to a list of block lists if it's not empty.protected abstract java.util.List<KnuthElement>
getNextKnuthElements(LayoutContext context, int alignment)
Get a sequence of KnuthElements representing the content of the node assigned to the LMprotected java.util.List<KnuthElement>
getNextKnuthElements(LayoutContext context, int alignment, Position positionAtIPDChange, LayoutManager restartAtLM)
Get a sequence of KnuthElements representing the content of the node assigned to the LMprotected PageProvider
getPageProvider()
Returns the PageProvider if any.protected abstract LayoutManager
getTopLevelLM()
protected void
handleEmptyContent()
This method is called when no content is available for a part.protected int
handleFloatLayout(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, int optimalPageCount, AbstractBreaker.BlockSequence blockList, LayoutContext childLC)
protected int
handleSpanChange(LayoutContext childLC, int nextSequenceStartsOn)
Handles span changes reported through theLayoutContext
.protected abstract boolean
hasMoreContent()
boolean
isEmpty()
protected boolean
isPartOverflowRecoveryActivated()
Controls the behaviour of the algorithm in cases where the first element of a part overflows a line/page.protected boolean
isSinglePartFavored()
protected boolean
lastPageHasIPDChange(int optimalPageCount)
protected void
observeElementList(java.util.List elementList)
Used for debugging purposes.protected void
prepareToRedoLayout(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, int partCount, AbstractBreaker.BlockSequence originalList, AbstractBreaker.BlockSequence effectiveList)
protected boolean
shouldRedoLayout()
protected void
startPart(AbstractBreaker.BlockSequence list, int breakClass, boolean emptyContent)
Start part.protected void
updateLayoutContext(LayoutContext context)
Used to update the LayoutContext in subclasses prior to starting a new element list.protected boolean
wasLayoutRedone()
-
-
-
Field Detail
-
log
protected static final org.apache.commons.logging.Log log
logging instance
-
originalRestartAtLM
protected LayoutManager originalRestartAtLM
-
positionAtBreak
protected Position positionAtBreak
-
firstElementsForRestart
protected java.util.List firstElementsForRestart
-
pslm
protected PageSequenceLayoutManager pslm
-
blockLists
protected java.util.List<AbstractBreaker.BlockSequence> blockLists
-
blockListIndex
protected int blockListIndex
blockListIndex of the current BlockSequence in blockLists
-
alignment
protected int alignment
desired text alignment
-
footnoteSeparatorLength
protected MinOptMax footnoteSeparatorLength
footnote separator length
-
-
Method Detail
-
getCurrentDisplayAlign
protected abstract int getCurrentDisplayAlign()
- Returns:
- current display alignment
-
hasMoreContent
protected abstract boolean hasMoreContent()
- Returns:
- true if content not exhausted
-
addAreas
protected abstract void addAreas(PositionIterator posIter, LayoutContext context)
Tell the layout manager to add all the child areas implied by Position objects which will be returned by the Iterator.- Parameters:
posIter
- the position iteratorcontext
- the context
-
getTopLevelLM
protected abstract LayoutManager getTopLevelLM()
- Returns:
- top level layout manager
-
getCurrentChildLM
protected abstract LayoutManager getCurrentChildLM()
- Returns:
- current child layout manager
-
isPartOverflowRecoveryActivated
protected boolean isPartOverflowRecoveryActivated()
Controls the behaviour of the algorithm in cases where the first element of a part overflows a line/page.- Returns:
- true if the algorithm should try to send the element to the next line/page.
-
isSinglePartFavored
protected boolean isSinglePartFavored()
- Returns:
- true if one a single part should be produced if possible (ex. for block-containers)
-
getPageProvider
protected PageProvider getPageProvider()
Returns the PageProvider if any. PageBreaker overrides this method because each page may have a different available BPD which needs to be accessible to the breaking algorithm.- Returns:
- the applicable PageProvider, or null if not applicable
-
createLayoutListener
protected org.apache.fop.layoutmgr.PageBreakingAlgorithm.PageBreakingLayoutListener createLayoutListener()
Creates and returns a PageBreakingLayoutListener for the PageBreakingAlgorithm to notify about layout problems.- Returns:
- the listener instance or null if no notifications are needed
-
getNextKnuthElements
protected abstract java.util.List<KnuthElement> getNextKnuthElements(LayoutContext context, int alignment)
Get a sequence of KnuthElements representing the content of the node assigned to the LM- Parameters:
context
- the LayoutContext used to store layout informationalignment
- the desired text alignment- Returns:
- the list of KnuthElements
-
getNextKnuthElements
protected java.util.List<KnuthElement> getNextKnuthElements(LayoutContext context, int alignment, Position positionAtIPDChange, LayoutManager restartAtLM)
Get a sequence of KnuthElements representing the content of the node assigned to the LM- Parameters:
context
- the LayoutContext used to store layout informationalignment
- the desired text alignmentpositionAtIPDChange
- last element on the part before an IPD changerestartAtLM
- the layout manager from which to restart, if IPD change occurs between two LMs- Returns:
- the list of KnuthElements
-
isEmpty
public boolean isEmpty()
- Returns:
- true if there's no content that could be handled.
-
startPart
protected void startPart(AbstractBreaker.BlockSequence list, int breakClass, boolean emptyContent)
Start part.- Parameters:
list
- a block sequencebreakClass
- a break class
-
handleEmptyContent
protected void handleEmptyContent()
This method is called when no content is available for a part. Used to force empty pages.
-
finishPart
protected abstract void finishPart(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, AbstractBreaker.PageBreakPosition pbp)
Finish part.- Parameters:
alg
- a page breaking algorithmpbp
- a page break posittion
-
createLayoutContext
protected LayoutContext createLayoutContext()
Creates the top-level LayoutContext for the breaker operation.- Returns:
- the top-level LayoutContext
-
updateLayoutContext
protected void updateLayoutContext(LayoutContext context)
Used to update the LayoutContext in subclasses prior to starting a new element list.- Parameters:
context
- the LayoutContext to update
-
observeElementList
protected void observeElementList(java.util.List elementList)
Used for debugging purposes. Notifies all registered observers about the element list. Override to set different parameters.- Parameters:
elementList
- the Knuth element list
-
doLayout
public boolean doLayout(int flowBPD, boolean autoHeight)
Starts the page breaking process.- Parameters:
flowBPD
- the constant available block-progression-dimension (used for every part)autoHeight
- true if warnings about overflows should be disabled because the the BPD is really undefined (for footnote-separators, for example)
-
containsNonRestartableLM
protected boolean containsNonRestartableLM(Position position)
Returnstrue
if the given position or one of its descendants corresponds to a non-restartable LM.- Parameters:
position
- a position- Returns:
true
if there is a non-restartable LM in the hierarchy
-
doPhase3
protected abstract void doPhase3(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, int partCount, AbstractBreaker.BlockSequence originalList, AbstractBreaker.BlockSequence effectiveList)
Phase 3 of Knuth algorithm: Adds the areas- Parameters:
alg
- PageBreakingAlgorithm instance which determined the breakspartCount
- number of parts (pages) to be renderedoriginalList
- original Knuth element listeffectiveList
- effective Knuth element list (after adjustments)
-
addAreas
protected void addAreas(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, int partCount, AbstractBreaker.BlockSequence originalList, AbstractBreaker.BlockSequence effectiveList)
Phase 3 of Knuth algorithm: Adds the areas- Parameters:
alg
- PageBreakingAlgorithm instance which determined the breakspartCount
- number of parts (pages) to be renderedoriginalList
- original Knuth element listeffectiveList
- effective Knuth element list (after adjustments)
-
addAreas
protected void addAreas(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, int startPart, int partCount, AbstractBreaker.BlockSequence originalList, AbstractBreaker.BlockSequence effectiveList)
-
addAreas
protected void addAreas(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, int startPart, int partCount, AbstractBreaker.BlockSequence originalList, AbstractBreaker.BlockSequence effectiveList, LayoutContext childLC)
Phase 3 of Knuth algorithm: Adds the areas- Parameters:
alg
- PageBreakingAlgorithm instance which determined the breaksstartPart
- index of the first part (page) to be renderedpartCount
- number of parts (pages) to be renderedoriginalList
- original Knuth element listeffectiveList
- effective Knuth element list (after adjustments)
-
handleSpanChange
protected int handleSpanChange(LayoutContext childLC, int nextSequenceStartsOn)
Handles span changes reported through theLayoutContext
. Only used by the PSLM and called bygetNextBlockList()
.- Parameters:
childLC
- the LayoutContextnextSequenceStartsOn
- previous value for break handling- Returns:
- effective value for break handling
-
getNextBlockList
protected int getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn)
Gets the next block list (sequence) and adds it to a list of block lists if it's not empty.- Parameters:
childLC
- LayoutContext to usenextSequenceStartsOn
- indicates on what page the next sequence should start- Returns:
- the page on which the next content should appear after a hard break
-
getNextBlockList
protected int getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn, Position positionAtIPDChange, LayoutManager restartAtLM, java.util.List<KnuthElement> firstElements)
Gets the next block list (sequence) and adds it to a list of block lists if it's not empty.- Parameters:
childLC
- LayoutContext to usenextSequenceStartsOn
- indicates on what page the next sequence should startpositionAtIPDChange
- last element on the part before an IPD changerestartAtLM
- the layout manager from which to restart, if IPD change occurs between two LMsfirstElements
- elements from non-restartable LMs on the new page- Returns:
- the page on which the next content should appear after a hard break
-
shouldRedoLayout
protected boolean shouldRedoLayout()
-
prepareToRedoLayout
protected void prepareToRedoLayout(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, int partCount, AbstractBreaker.BlockSequence originalList, AbstractBreaker.BlockSequence effectiveList)
-
wasLayoutRedone
protected boolean wasLayoutRedone()
-
lastPageHasIPDChange
protected boolean lastPageHasIPDChange(int optimalPageCount)
-
handleFloatLayout
protected int handleFloatLayout(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, int optimalPageCount, AbstractBreaker.BlockSequence blockList, LayoutContext childLC)
-
addAreasForFloats
protected void addAreasForFloats(org.apache.fop.layoutmgr.PageBreakingAlgorithm alg, int startPart, int partCount, AbstractBreaker.BlockSequence originalList, AbstractBreaker.BlockSequence effectiveList, LayoutContext childLC, int lastBreak, int startElementIndex, int endElementIndex)
-
-