summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2014-04-28 19:24:59 +0000
committerVincent Hennebert <vhennebert@apache.org>2014-04-28 19:24:59 +0000
commit8dad9f03a9f70fafac850385f878c317029a38ae (patch)
tree3405e3f5956a1dd4f378de56638c82b64d132889 /src
parent0eba38fb2fed5426761c09dc003bdba9b92a6fbd (diff)
downloadxmlgraphics-fop-8dad9f03a9f70fafac850385f878c317029a38ae.tar.gz
xmlgraphics-fop-8dad9f03a9f70fafac850385f878c317029a38ae.zip
Create penalty only once and store it in WhitespaceManagementPenalty
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_WhitespaceManagement@1590758 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/WhitespaceManagementPenalty.java6
2 files changed, 5 insertions, 3 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
index 8b8cc4982..db849a40f 100644
--- a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
+++ b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
@@ -600,7 +600,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
private int handleWhitespaceManagementPenalty(KnuthPageNode activeNode,
WhitespaceManagementPenalty penalty, int elementIndex) {
for (Variant var : penalty.getVariants()) {
- int difference = computeDifference(activeNode, var.toPenalty(), elementIndex);
+ int difference = computeDifference(activeNode, var.getPenalty(), elementIndex);
double r = computeAdjustmentRatio(activeNode, difference);
if (r >= -1.0) {
activeNode.addVariant(var);
diff --git a/src/java/org/apache/fop/layoutmgr/WhitespaceManagementPenalty.java b/src/java/org/apache/fop/layoutmgr/WhitespaceManagementPenalty.java
index 20c83d205..e34d24b9a 100644
--- a/src/java/org/apache/fop/layoutmgr/WhitespaceManagementPenalty.java
+++ b/src/java/org/apache/fop/layoutmgr/WhitespaceManagementPenalty.java
@@ -36,14 +36,16 @@ public class WhitespaceManagementPenalty extends KnuthPenalty {
public final List<ListElement> knuthList;
public final int width;
+ private final KnuthPenalty penalty;
public Variant(List<ListElement> knuthList, int width) {
this.knuthList = knuthList;
this.width = width;
+ this.penalty = new KnuthPenalty(width, 0, false, null, false);
}
- public KnuthElement toPenalty() {
- return new KnuthPenalty(width, 0, false, null, false);
+ public KnuthElement getPenalty() {
+ return penalty;
}
public WhitespaceManagementPenalty getWhitespaceManagementPenalty() {