diff options
author | Jeremias Maerki <jeremias@apache.org> | 2005-06-29 12:57:51 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2005-06-29 12:57:51 +0000 |
commit | f9a98ac2dcc84393751d82cb8d45f3f6eb3c44c9 (patch) | |
tree | ee889c9f76a139f8a1ad9d08d382f52d9f6b64bf /src/java/org/apache | |
parent | 83f9038f807b87dbb77e6b119a1026f9cd0b278f (diff) | |
download | xmlgraphics-fop-f9a98ac2dcc84393751d82cb8d45f3f6eb3c44c9.tar.gz xmlgraphics-fop-f9a98ac2dcc84393751d82cb8d45f3f6eb3c44c9.zip |
Enable starting the break process at an arbitrary position inside an element list.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@202363 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java index a09680821..0128eccbc 100644 --- a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java @@ -21,7 +21,6 @@ package org.apache.fop.layoutmgr; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.fop.layoutmgr.PageBreakingAlgorithm.KnuthPageNode; import org.apache.fop.traits.MinOptMax; /** @@ -322,6 +321,13 @@ public abstract class BreakingAlgorithm { } public int findBreakingPoints(KnuthSequence par, /*int lineWidth,*/ + double threshold, boolean force, + boolean hyphenationAllowed) { + return findBreakingPoints(par, 0, threshold, force, hyphenationAllowed); + } + + public int findBreakingPoints(KnuthSequence par, int startIndex, + /*int lineWidth,*/ double threshold, boolean force, boolean hyphenationAllowed) { this.par = par; @@ -343,7 +349,7 @@ public abstract class BreakingAlgorithm { boolean previousIsBox = false; // index of the first KnuthBox in the sequence - int firstBoxIndex = 0; + int firstBoxIndex = startIndex; while (alignment != org.apache.fop.fo.Constants.EN_CENTER && ! ((KnuthElement) par.get(firstBoxIndex)).isBox()) { firstBoxIndex++; @@ -354,13 +360,13 @@ public abstract class BreakingAlgorithm { addNode(0, createNode(firstBoxIndex, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, null)); if (log.isTraceEnabled()) { - log.trace("Looping over " + par.size() + " box objects"); + log.trace("Looping over " + (par.size() - startIndex) + " elements"); } KnuthNode lastForced = getNode(0); // main loop - for (int i = 0; i < par.size(); i++) { + for (int i = startIndex; i < par.size(); i++) { thisElement = getElement(i); if (thisElement.isBox()) { // a KnuthBox object is not a legal line break @@ -658,13 +664,16 @@ public abstract class BreakingAlgorithm { } /** - * Figure out the fitness class of this line (tight, loose, + * <p>Figure out the fitness class of this line (tight, loose, * very tight or very loose). + * </p> + * <p>See the section on "More Bells and Whistles" in Knuth's + * "Breaking Paragraphs Into Lines". + * </p> * @param r * @return */ private int computeFitness(double r) { - int newFitnessClass; if (r < -0.5) { return 0; } else if (r <= 0.5) { |