diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2014-04-28 19:24:59 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2014-04-28 19:24:59 +0000 |
commit | 8dad9f03a9f70fafac850385f878c317029a38ae (patch) | |
tree | 3405e3f5956a1dd4f378de56638c82b64d132889 /src | |
parent | 0eba38fb2fed5426761c09dc003bdba9b92a6fbd (diff) | |
download | xmlgraphics-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.java | 2 | ||||
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/WhitespaceManagementPenalty.java | 6 |
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() { |