alg.setConstantLineWidth(flowBPD);
int optimalPageCount = alg.findBreakingPoints(effectiveList, 1, true,
BreakingAlgorithm.ALL_BREAKS);
- if (alg.ipdChanged()) {
+ if (alg.getIPDdifference() != 0) {
KnuthNode optimalBreak = alg.getBestNodeBeforeIPDChange();
int positionIndex = optimalBreak.position;
KnuthElement elementAtBreak = alg.getElement(positionIndex);
LayoutManager restartAtLM = null;
List firstElements = Collections.EMPTY_LIST;
if (containsNonRestartableLM(positionAtBreak)) {
+ if (alg.getIPDdifference() > 0) {
+ log.warn("Content that cannot handle IPD changes is flowing to a"
+ + " narrower page. Part of it may be clipped"
+ + " by the page border.");
+ }
firstElements = new LinkedList();
boolean boxFound = false;
Iterator iter = effectiveList.listIterator(positionIndex + 1);
elementIndex, previousIsBox, allowedBreaks).isBox();
if (activeNodeCount == 0) {
- if (ipdChanged()) {
+ if (getIPDdifference() != 0) {
return handleIpdChange();
}
if (!force) {
return line;
}
- protected boolean ipdChanged() {
- return false;
+ protected int getIPDdifference() {
+ return 0;
}
protected int handleIpdChange() {
//Controls whether a single part should be forced if possible (ex. block-container)
private boolean favorSinglePart = false;
- private boolean ipdChange;
+ private int ipdDifference;
private KnuthNode bestNodeForIPDChange;
//Used to keep track of switches in keep-context
}
/** {@inheritDoc} */
- protected boolean ipdChanged() {
- return ipdChange;
+ protected int getIPDdifference() {
+ return ipdDifference;
}
/** {@inheritDoc} */
* @param node the active node to add
*/
protected void addNode(int line, KnuthNode node) {
- if (node.position < par.size() - 1 && line > 0 && ipdChange(line - 1)) {
+ if (node.position < par.size() - 1 && line > 0
+ && (ipdDifference = compareIPDs(line - 1)) != 0) {
log.trace("IPD changes at page " + line);
- ipdChange = true;
if (bestNodeForIPDChange == null
|| node.totalDemerits < bestNodeForIPDChange.totalDemerits) {
bestNodeForIPDChange = node;
* The whole sequence could actually fit on the last page before
* the IPD change. No need to do any special handling.
*/
- ipdChange = false;
+ ipdDifference = 0;
}
super.addNode(line, node);
}
return bestNodeForIPDChange;
}
- /** {@inheritDoc} */
- protected boolean ipdChange(int line) {
+ private int compareIPDs(int line) {
if (pageProvider == null) {
- return false;
+ return 0;
}
- return pageProvider.ipdChange(line);
+ return pageProvider.compareIPDs(line);
}
}
}
/**
- * Returns true if the part following the given one has a different IPD.
+ * Compares the IPD of the given part with the following one.
*
* @param index index of the current part
- * @return true if the following part has a different IPD, false otherwise
+ * @return 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
*/
- public boolean ipdChange(int index) {
+ public int compareIPDs(int index) {
int columnCount = 0;
int colIndex = startColumnOfCurrentElementList + index;
int pageIndex = -1;
} while (colIndex >= columnCount);
if (colIndex + 1 < columnCount) {
// Next part is a column on same page => same IPD
- return false;
+ return 0;
} else {
Page nextPage = getPage(false, pageIndex + 1, RELTO_CURRENT_ELEMENT_LIST);
return page.getPageViewport().getBodyRegion().getIPD()
- != nextPage.getPageViewport().getBodyRegion().getIPD();
+ - nextPage.getPageViewport().getBodyRegion().getIPD();
}
}