vhennebert
Mon, 12 May 2008 05:31:08 -0700
Author: vhennebert Date: Mon May 12 05:30:42 2008 New Revision: 655489 URL: http://svn.apache.org/viewvc?rev=655489&view=rev Log: Replaced hack in TableStepper to get the steps' penalty values with a more proper implementation. Allows in the same time to avoid skimming, at each step, through the active cells' LinkedLists of elements, which may have a negative impact on performance Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableStepper.java Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java?rev=655489&r1=655488&r2=655489&view=diff ============================================================================== --- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java (original) +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java Mon May 12 05:30:42 2008 @@ -99,6 +99,8 @@ private int totalLength; /** Length of the penalty ending this step, if any. */ private int penaltyLength; + /** Value of the penalty ending this step, 0 if the step does not end on a penalty. */ + private int penaltyValue; /** * One of [EMAIL PROTECTED] Constants#EN_AUTO}, [EMAIL PROTECTED] Constants#EN_COLUMN}, * [EMAIL PROTECTED] Constants#EN_PAGE}, [EMAIL PROTECTED] Constants#EN_EVEN_PAGE}, @@ -127,6 +129,7 @@ this.contentLength = other.contentLength; this.totalLength = other.totalLength; this.penaltyLength = other.penaltyLength; + this.penaltyValue = other.penaltyValue; this.condBeforeContentLength = other.condBeforeContentLength; this.breakClass = other.breakClass; } @@ -287,6 +290,7 @@ private void gotoNextLegalBreak() { afterNextStep.penaltyLength = 0; + afterNextStep.penaltyValue = 0; afterNextStep.condBeforeContentLength = 0; afterNextStep.breakClass = Constants.EN_AUTO; boolean breakFound = false; @@ -299,8 +303,9 @@ if (el.getP() < KnuthElement.INFINITE) { // First legal break point breakFound = true; - afterNextStep.penaltyLength = el.getW(); KnuthPenalty p = (KnuthPenalty) el; + afterNextStep.penaltyLength = p.getW(); + afterNextStep.penaltyValue = p.getP(); if (p.isForcedBreak()) { afterNextStep.breakClass = p.getBreakClass(); } @@ -542,7 +547,14 @@ return keepWithNextStrength; } - + int getPenaltyValue() { + if (includedInLastStep()) { + return nextStep.penaltyValue; + } else { + return previousStep.penaltyValue; + } + } + /** [EMAIL PROTECTED] */ public String toString() { return "Cell " + (pgu.getRowIndex() + 1) + "." + (pgu.getColIndex() + 1); Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableStepper.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableStepper.java?rev=655489&r1=655488&r2=655489&view=diff ============================================================================== --- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableStepper.java (original) +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableStepper.java Mon May 12 05:30:42 2008 @@ -200,20 +200,11 @@ } //Put all involved grid units into a list - int stepPenalty = 0; List cellParts = new java.util.ArrayList(columnCount); for (Iterator iter = activeCells.iterator(); iter.hasNext();) { ActiveCell activeCell = (ActiveCell) iter.next(); CellPart part = activeCell.createCellPart(); cellParts.add(part); - - //Record highest penalty value of part - if (part.end >= 0) { - KnuthElement endEl = (KnuthElement)part.pgu.getElements().get(part.end); - if (endEl instanceof KnuthPenalty) { - stepPenalty = Math.max(stepPenalty, endEl.getP()); - } - } } //Create elements for step @@ -242,9 +233,11 @@ } int strength = BlockLevelLayoutManager.KEEP_AUTO; + int stepPenalty = 0; for (Iterator iter = activeCells.iterator(); iter.hasNext();) { ActiveCell activeCell = (ActiveCell) iter.next(); strength = Math.max(strength, activeCell.getKeepWithNextStrength()); + stepPenalty = Math.max(stepPenalty, activeCell.getPenaltyValue()); } if (!rowFinished) { strength = Math.max(strength, rowGroup[activeRowIndex].getKeepTogetherStrength()); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]