diff options
author | Jeremias Maerki <jeremias@apache.org> | 2005-07-11 07:19:01 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2005-07-11 07:19:01 +0000 |
commit | 31af39e5bf4087f6f944b50c9263bf4402c0925f (patch) | |
tree | fb9be1959cc02fc59ad2fbeca43016b45f38e77d /src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java | |
parent | 043a508d2f6242590fc2e839e4e4b1581e29fc5b (diff) | |
download | xmlgraphics-fop-31af39e5bf4087f6f944b50c9263bf4402c0925f.tar.gz xmlgraphics-fop-31af39e5bf4087f6f944b50c9263bf4402c0925f.zip |
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
Diffstat (limited to 'src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java')
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java | 13 |
1 files changed, 9 insertions, 4 deletions
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);
}
|