]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugfix: Corrected the calculation of the full length of the section to be broken...
authorJeremias Maerki <jeremias@apache.org>
Mon, 11 Jul 2005 07:19:01 +0000 (07:19 +0000)
committerJeremias Maerki <jeremias@apache.org>
Mon, 11 Jul 2005 07:19:01 +0000 (07:19 +0000)
Own private logger for easier debugging.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@210077 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java

index 3a3c343c67d62429be8cb5a8bdcfc9a269729fed..2178dee2d7f3ad45ace54ce0bcb5f07d6a4896c4 100644 (file)
@@ -18,6 +18,8 @@
 \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
@@ -26,8 +28,11 @@ import org.apache.fop.traits.MinOptMax;
  */\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
@@ -47,12 +52,13 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm {
         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
@@ -64,8 +70,7 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm {
             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