aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2008-05-12 12:30:42 +0000
committerVincent Hennebert <vhennebert@apache.org>2008-05-12 12:30:42 +0000
commit6d07774192bb641251bd72b7ea68f012f20e2d88 (patch)
tree7d103a63c5a1710b6bcdc0484521d708b9495c6e /src/java
parent792c78edcbb37ed4e3ae213dfd18fa6be56bbb1d (diff)
downloadxmlgraphics-fop-6d07774192bb641251bd72b7ea68f012f20e2d88.tar.gz
xmlgraphics-fop-6d07774192bb641251bd72b7ea68f012f20e2d88.zip
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
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@655489 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/ActiveCell.java16
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableStepper.java11
2 files changed, 16 insertions, 11 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java b/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java
index 70e2b2330..feb4b67ac 100644
--- a/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java
+++ b/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java
@@ -99,6 +99,8 @@ class ActiveCell {
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 {@link Constants#EN_AUTO}, {@link Constants#EN_COLUMN},
* {@link Constants#EN_PAGE}, {@link Constants#EN_EVEN_PAGE},
@@ -127,6 +129,7 @@ class ActiveCell {
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 @@ class ActiveCell {
private void gotoNextLegalBreak() {
afterNextStep.penaltyLength = 0;
+ afterNextStep.penaltyValue = 0;
afterNextStep.condBeforeContentLength = 0;
afterNextStep.breakClass = Constants.EN_AUTO;
boolean breakFound = false;
@@ -299,8 +303,9 @@ class ActiveCell {
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 @@ class ActiveCell {
return keepWithNextStrength;
}
-
+ int getPenaltyValue() {
+ if (includedInLastStep()) {
+ return nextStep.penaltyValue;
+ } else {
+ return previousStep.penaltyValue;
+ }
+ }
+
/** {@inheritDoc} */
public String toString() {
return "Cell " + (pgu.getRowIndex() + 1) + "." + (pgu.getColIndex() + 1);
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
index 2d3c990f8..f514844ac 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
@@ -200,20 +200,11 @@ public class TableStepper {
}
//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 @@ public class TableStepper {
}
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());