From: Jeremias Maerki Date: Mon, 11 Jul 2005 07:19:01 +0000 (+0000) Subject: Bugfix: Corrected the calculation of the full length of the section to be broken... X-Git-Tag: fop-0_90-alpha1~497 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=31af39e5bf4087f6f944b50c9263bf4402c0925f;p=xmlgraphics-fop.git Bugfix: Corrected the calculation of the full length of the section to be broken. Could lead to strange results. Own private logger for easier debugging. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@210077 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java index 3a3c343c6..2178dee2d 100644 --- a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java @@ -18,6 +18,8 @@ package org.apache.fop.layoutmgr; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.fop.traits.MinOptMax; /** @@ -26,8 +28,11 @@ import org.apache.fop.traits.MinOptMax; */ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { + private Log log = LogFactory.getLog(BalancingColumnBreakingAlgorithm.class); + private int columnCount; private int fullLen; + private int idealPartLen; public BalancingColumnBreakingAlgorithm(LayoutManager topLevelLM, PageSequenceLayoutManager.PageViewportProvider pvProvider, @@ -47,12 +52,13 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { double dem = super.computeDemerits(activeNode, element, fitnessClass, r); if (log.isTraceEnabled()) { log.trace("original demerit=" + dem + " " + totalWidth - + " line=" + activeNode.line); + + " line=" + activeNode.line + "/" + columnCount); } int remParts = columnCount - activeNode.line; int curPos = par.indexOf(element); if (fullLen == 0) { - fullLen = ElementListUtils.calcContentLength(par); + fullLen = ElementListUtils.calcContentLength(par, activeNode.position, par.size() - 1); + this.idealPartLen = (fullLen / columnCount); } int partLen = ElementListUtils.calcContentLength(par, activeNode.position, curPos - 1); int restLen = ElementListUtils.calcContentLength(par, curPos - 1, par.size() - 1); @@ -64,8 +70,7 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { log.trace("remaining parts: " + remParts + " rest len: " + restLen + " avg=" + avgRestLen); } - int meanColumnLen = (fullLen / columnCount); - double balance = (meanColumnLen - partLen) / 1000f; + double balance = (idealPartLen - partLen) / 1000f; if (log.isTraceEnabled()) { log.trace("balance=" + balance); }