\r
package org.apache.fop.layoutmgr;\r
\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
import org.apache.fop.traits.MinOptMax;\r
\r
/**\r
*/\r
public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm {\r
\r
+ private Log log = LogFactory.getLog(BalancingColumnBreakingAlgorithm.class);\r
+ \r
private int columnCount;\r
private int fullLen;\r
+ private int idealPartLen;\r
\r
public BalancingColumnBreakingAlgorithm(LayoutManager topLevelLM,\r
PageSequenceLayoutManager.PageViewportProvider pvProvider,\r
double dem = super.computeDemerits(activeNode, element, fitnessClass, r);\r
if (log.isTraceEnabled()) {\r
log.trace("original demerit=" + dem + " " + totalWidth \r
- + " line=" + activeNode.line);\r
+ + " line=" + activeNode.line + "/" + columnCount);\r
}\r
int remParts = columnCount - activeNode.line;\r
int curPos = par.indexOf(element);\r
if (fullLen == 0) {\r
- fullLen = ElementListUtils.calcContentLength(par);\r
+ fullLen = ElementListUtils.calcContentLength(par, activeNode.position, par.size() - 1);\r
+ this.idealPartLen = (fullLen / columnCount);\r
}\r
int partLen = ElementListUtils.calcContentLength(par, activeNode.position, curPos - 1);\r
int restLen = ElementListUtils.calcContentLength(par, curPos - 1, par.size() - 1);\r
log.trace("remaining parts: " + remParts + " rest len: " + restLen \r
+ " avg=" + avgRestLen);\r
}\r
- int meanColumnLen = (fullLen / columnCount);\r
- double balance = (meanColumnLen - partLen) / 1000f;\r
+ double balance = (idealPartLen - partLen) / 1000f;\r
if (log.isTraceEnabled()) {\r
log.trace("balance=" + balance);\r
}\r