|
fop 1.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.fop.layoutmgr.BreakingAlgorithm
org.apache.fop.layoutmgr.BalancingColumnBreakingAlgorithm
public class BalancingColumnBreakingAlgorithm
This is a the breaking algorithm that is responsible for balancing columns in multi-column layout.
Nested Class Summary | |
---|---|
static interface |
PageBreakingAlgorithm.PageBreakingLayoutListener
Interface to notify about layout events during page breaking. |
Nested classes/interfaces inherited from class org.apache.fop.layoutmgr.BreakingAlgorithm |
---|
BreakingAlgorithm.BestRecords, BreakingAlgorithm.KnuthNode |
Field Summary |
---|
Fields inherited from class org.apache.fop.layoutmgr.BreakingAlgorithm |
---|
activeLines, activeNodeCount, alignment, alignmentLast, ALL_BREAKS, best, considerTooShort, endLine, incompatibleFitnessDemerit, indentFirstPart, INFINITE_RATIO, lineWidth, maxFlaggedPenaltiesCount, NO_FLAGGED_PENALTIES, ONLY_FORCED_BREAKS, par, repeatedFlaggedDemerit, startLine, totalShrink, totalStretch, totalWidth |
Constructor Summary | |
---|---|
BalancingColumnBreakingAlgorithm(LayoutManager topLevelLM,
PageProvider pageProvider,
PageBreakingAlgorithm.PageBreakingLayoutListener layoutListener,
int alignment,
int alignmentLast,
MinOptMax footnoteSeparatorLength,
boolean partOverflowRecovery,
int columnCount)
|
Method Summary | |
---|---|
protected void |
addNode(int line,
BreakingAlgorithm.KnuthNode node)
Add a node at the end of the given line's existing active nodes. |
protected BreakingAlgorithm.KnuthNode |
compareNodes(BreakingAlgorithm.KnuthNode node1,
BreakingAlgorithm.KnuthNode node2)
Compare two KnuthNodes and return the node with the least demerit. |
protected double |
computeAdjustmentRatio(BreakingAlgorithm.KnuthNode activeNode,
int difference)
Return the adjustment ratio needed to make up for the difference. |
protected double |
computeDemerits(BreakingAlgorithm.KnuthNode activeNode,
KnuthElement element,
int fitnessClass,
double r)
Computes the demerits of the current breaking (that is, up to the given element), if the next-to-last chosen breakpoint is the given active node. |
protected int |
computeDifference(BreakingAlgorithm.KnuthNode activeNode,
KnuthElement element,
int elementIndex)
Return the difference between the natural width of a line that would be made between the given active node and the given element, and the available width of the real line. |
protected void |
considerLegalBreak(KnuthElement element,
int elementIdx)
Determines if the given breakpoint is a feasible breakpoint. |
protected BreakingAlgorithm.KnuthNode |
createNode(int position,
int line,
int fitness,
int totalWidth,
int totalStretch,
int totalShrink)
Creates a new active node for a break from the best active node of the given fitness class to the element at the given position. |
protected BreakingAlgorithm.KnuthNode |
createNode(int position,
int line,
int fitness,
int totalWidth,
int totalStretch,
int totalShrink,
double adjustRatio,
int availableShrink,
int availableStretch,
int difference,
double totalDemerits,
BreakingAlgorithm.KnuthNode previous)
Creates a new active node for a feasible breakpoint at the given position. |
protected boolean |
elementCanEndLine(KnuthElement element,
int line,
int difference)
Check if the given KnuthElement can end the line with the given
number. |
protected int |
filterActiveNodes()
|
protected void |
finish()
Hook for subclasses to trigger special behavior after ending the main loop in BreakingAlgorithm.findBreakingPoints(KnuthSequence,int,double,boolean,int) |
FObj |
getFObj()
|
protected java.util.List |
getFootnoteList(int index)
Obtain the element-list corresponding to the footnote at the given index. |
protected int |
getIPDdifference()
|
protected int |
getLineWidth(int line)
Returns the line/part width of a given line/part. |
java.util.LinkedList |
getPageBreaks()
|
protected void |
handleBox(KnuthBox box)
Handle a KnuthBox . |
protected int |
handleIpdChange()
|
protected void |
handlePenaltyAt(KnuthPenalty penalty,
int position,
int allowedBreaks)
Handle a KnuthPenalty at the given position,
taking into account the type of breaks allowed. |
protected void |
initialize()
Initializes the algorithm's variables. |
void |
insertPageBreakAsFirst(AbstractBreaker.PageBreakPosition pageBreak)
Insert the given AbstractBreaker.PageBreakPosition as the first
element in the list of page-breaks |
protected BreakingAlgorithm.KnuthNode |
recoverFromTooLong(BreakingAlgorithm.KnuthNode lastTooLong)
Recover from a BreakingAlgorithm.KnuthNode leading to a line that is too long. |
void |
removeAllPageBreaks()
Removes all page breaks from the result list. |
protected int |
restartFrom(BreakingAlgorithm.KnuthNode restartingNode,
int currentIndex)
Restart from the given node at the given index. |
void |
updateData1(int total,
double demerits)
Empty method, hook for subclasses. |
void |
updateData2(BreakingAlgorithm.KnuthNode bestActiveNode,
KnuthSequence sequence,
int total)
Empty method, hook for subclasses. |
Methods inherited from class org.apache.fop.layoutmgr.BreakingAlgorithm |
---|
activateNode, calculateBreakPoints, deactivateNode, findBreakingPoints, findBreakingPoints, forceNode, getAlignment, getAlignmentLast, getElement, getLastTooShort, getLineWidth, getMaxRecoveryAttempts, getNode, handleElementAt, handleGlueAt, isPartOverflowRecoveryActivated, recoverFromOverflow, removeNode, replaceLastDeactivated, setConstantLineWidth, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BalancingColumnBreakingAlgorithm(LayoutManager topLevelLM, PageProvider pageProvider, PageBreakingAlgorithm.PageBreakingLayoutListener layoutListener, int alignment, int alignmentLast, MinOptMax footnoteSeparatorLength, boolean partOverflowRecovery, int columnCount)
Method Detail |
---|
protected double computeDemerits(BreakingAlgorithm.KnuthNode activeNode, KnuthElement element, int fitnessClass, double r)
activeNode
- considered preceding line breakelement
- considered current line breakfitnessClass
- fitness of the current liner
- adjustment ratio for the current line
protected void initialize()
initialize
in class BreakingAlgorithm
protected BreakingAlgorithm.KnuthNode recoverFromTooLong(BreakingAlgorithm.KnuthNode lastTooLong)
BreakingAlgorithm.KnuthNode
leading to a line that is too long.
The default implementation creates a new node corresponding to a break
point after the previous node that led to a line that was too short.
Overridden to defer a part to the next page, if it
must be kept within one page, but is too large to fit in
the last column.
recoverFromTooLong
in class BreakingAlgorithm
lastTooLong
- the node that leads to a "too long" line
protected BreakingAlgorithm.KnuthNode compareNodes(BreakingAlgorithm.KnuthNode node1, BreakingAlgorithm.KnuthNode node2)
compareNodes
in class BreakingAlgorithm
node1
- The first knuth node.node2
- The other knuth node.
protected BreakingAlgorithm.KnuthNode createNode(int position, int line, int fitness, int totalWidth, int totalStretch, int totalShrink, double adjustRatio, int availableShrink, int availableStretch, int difference, double totalDemerits, BreakingAlgorithm.KnuthNode previous)
createNode
in class BreakingAlgorithm
position
- index of the element in the Knuth sequenceline
- number of the line ending at the breakpointfitness
- fitness class of the line ending at the breakpoint. One of 0, 1, 2, 3.totalWidth
- accumulated width of the KnuthElements up to after the breakpointtotalStretch
- accumulated stretchability of the KnuthElements up to after the
breakpointtotalShrink
- accumulated shrinkability of the KnuthElements up to after the
breakpointadjustRatio
- adjustment ratio if the line ends at this breakpointavailableShrink
- available stretch of the line ending at this breakpointavailableStretch
- available shrink of the line ending at this breakpointdifference
- difference between target and actual line widthtotalDemerits
- minimum total demerits up to the breakpointprevious
- active node for the preceding breakpoint
protected BreakingAlgorithm.KnuthNode createNode(int position, int line, int fitness, int totalWidth, int totalStretch, int totalShrink)
createNode
in class BreakingAlgorithm
BreakingAlgorithm.createNode(int, int, int, int, int, int, double, int, int, int, double, org.apache.fop.layoutmgr.BreakingAlgorithm.KnuthNode)
,
BreakingAlgorithm.BestRecords
protected void handleBox(KnuthBox box)
KnuthBox
.
super.handleBox(box)
to avoid unwanted side-effects.
Page-breaking specific handling of the given box. Currently it adds the footnotes
cited in the given box to the list of to-be-handled footnotes.
handleBox
in class BreakingAlgorithm
box
- a block-level element possibly containing foonotes citationsprotected void handlePenaltyAt(KnuthPenalty penalty, int position, int allowedBreaks)
KnuthPenalty
at the given position,
taking into account the type of breaks allowed.
Overridden to consider penalties with value KnuthElement.INFINITE
as legal break-points, if the current keep-context allows this
(a keep-*.within-page="always" constraint still permits column-breaks)
handlePenaltyAt
in class BreakingAlgorithm
penalty
- the KnuthPenalty
to handleposition
- the position of the penalty in the listallowedBreaks
- the type of breaks that are allowedprotected int restartFrom(BreakingAlgorithm.KnuthNode restartingNode, int currentIndex)
restartFrom
in class BreakingAlgorithm
restartingNode
- the BreakingAlgorithm.KnuthNode
to restart fromcurrentIndex
- the current position index
protected void considerLegalBreak(KnuthElement element, int elementIdx)
considerLegalBreak
in class BreakingAlgorithm
element
- the paragraph's element to considerelementIdx
- the element's index inside the paragraphprotected boolean elementCanEndLine(KnuthElement element, int line, int difference)
KnuthElement
can end the line with the given
number.
elementCanEndLine
in class BreakingAlgorithm
element
- the elementline
- the line number
true
if the element can end the lineprotected int computeDifference(BreakingAlgorithm.KnuthNode activeNode, KnuthElement element, int elementIndex)
computeDifference
in class BreakingAlgorithm
activeNode
- node for the previous breakpointelement
- currently considered breakpointelementIndex
- index of the element that is considered as a breakpoint
protected double computeAdjustmentRatio(BreakingAlgorithm.KnuthNode activeNode, int difference)
computeAdjustmentRatio
in class BreakingAlgorithm
activeNode
- the currently active nodedifference
- the difference between content-length and available width
protected void finish()
BreakingAlgorithm
BreakingAlgorithm.findBreakingPoints(KnuthSequence,int,double,boolean,int)
finish
in class BreakingAlgorithm
public java.util.LinkedList getPageBreaks()
AbstractBreaker.PageBreakPosition
elements
corresponding to the computed page- and column-breakspublic void insertPageBreakAsFirst(AbstractBreaker.PageBreakPosition pageBreak)
AbstractBreaker.PageBreakPosition
as the first
element in the list of page-breaks
pageBreak
- the position to insertpublic void removeAllPageBreaks()
public void updateData1(int total, double demerits)
updateData1
in class BreakingAlgorithm
total
- number of lines for the active nodedemerits
- total demerits of the paragraph for the active nodepublic void updateData2(BreakingAlgorithm.KnuthNode bestActiveNode, KnuthSequence sequence, int total)
updateData2
in class BreakingAlgorithm
bestActiveNode
- a node in the chain of best active nodes, corresponding to
one of the optimal breakpointssequence
- the corresponding paragraphtotal
- the number of lines into which the paragraph will be brokenprotected int filterActiveNodes()
filterActiveNodes
in class BreakingAlgorithm
protected final java.util.List getFootnoteList(int index)
index
- the index in the list of footnotes
public FObj getFObj()
protected int getLineWidth(int line)
getLineWidth
in class BreakingAlgorithm
line
- the line/part number
protected int getIPDdifference()
getIPDdifference
in class BreakingAlgorithm
protected int handleIpdChange()
handleIpdChange
in class BreakingAlgorithm
protected void addNode(int line, BreakingAlgorithm.KnuthNode node)
addNode
in class BreakingAlgorithm
line
- number of the line ending at the node's corresponding breakpointnode
- the active node to add
|
fop 1.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |