From 8dad9f03a9f70fafac850385f878c317029a38ae Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Mon, 28 Apr 2014 19:24:59 +0000 Subject: 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 --- src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java | 2 +- src/java/org/apache/fop/layoutmgr/WhitespaceManagementPenalty.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') 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 knuthList; public final int width; + private final KnuthPenalty penalty; public Variant(List 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() { -- cgit v1.2.3