aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
diff options
context:
space:
mode:
authorLuca Furini <lfurini@apache.org>2005-09-16 13:24:16 +0000
committerLuca Furini <lfurini@apache.org>2005-09-16 13:24:16 +0000
commitbbd08a9bb0c11581bf3ef496d5b8aacab30d8c6a (patch)
tree77796af4d649618ddaefed0f538bf6a09b30a6a4 /src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
parent29697aee2699b47a3951a266463306b88ce2c38b (diff)
downloadxmlgraphics-fop-bbd08a9bb0c11581bf3ef496d5b8aacab30d8c6a.tar.gz
xmlgraphics-fop-bbd08a9bb0c11581bf3ef496d5b8aacab30d8c6a.zip
Implemented the wrap-option property.
The overflow property is not yet implemented, so at the moment if wrap-option = "no-wrap" and the text overflows it invades the margins. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@289531 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java')
-rw-r--r--src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
index 5909f3391..c689e37a3 100644
--- a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
+++ b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
@@ -47,6 +47,11 @@ public abstract class BreakingAlgorithm {
private static final int MAX_RECOVERY_ATTEMPTS = 50;
+ // constants identifying a subset of the feasible breaks
+ public static final int ALL_BREAKS = 0; // all feasible breaks are ok
+ public static final int NO_FLAGGED_PENALTIES = 1; // this forbids hyphenation
+ public static final int ONLY_FORCED_BREAKS = 2; // wrap-option = "no-wrap"
+
// parameters of Knuth's algorithm:
// penalty value for flagged penalties
private int flaggedPenalty = 50;
@@ -324,14 +329,14 @@ public abstract class BreakingAlgorithm {
public int findBreakingPoints(KnuthSequence par, /*int lineWidth,*/
double threshold, boolean force,
- boolean hyphenationAllowed) {
- return findBreakingPoints(par, 0, threshold, force, hyphenationAllowed);
+ int allowedBreaks) {
+ return findBreakingPoints(par, 0, threshold, force, allowedBreaks);
}
public int findBreakingPoints(KnuthSequence par, int startIndex,
/*int lineWidth,*/
double threshold, boolean force,
- boolean hyphenationAllowed) {
+ int allowedBreaks) {
this.par = par;
this.threshold = threshold;
this.force = force;
@@ -378,7 +383,9 @@ public abstract class BreakingAlgorithm {
} else if (thisElement.isGlue()) {
// a KnuthGlue object is a legal line break
// only if the previous object is a KnuthBox
- if (previousIsBox) {
+ // consider these glues according to the value of allowedBreaks
+ if (previousIsBox
+ && !(allowedBreaks == ONLY_FORCED_BREAKS)) {
considerLegalBreak(thisElement, i);
}
totalWidth += thisElement.getW();
@@ -388,10 +395,11 @@ public abstract class BreakingAlgorithm {
} else {
// a KnuthPenalty is a legal line break
// only if its penalty is not infinite;
- // if hyphenationAllowed is false, ignore flagged penalties
- if (((KnuthPenalty) thisElement).getP()
- < KnuthElement.INFINITE
- && (hyphenationAllowed || !((KnuthPenalty) thisElement).isFlagged())) {
+ // consider all penalties, non-flagged penalties or non-forcing penalties
+ // according to the value of allowedBreaks
+ if (((KnuthPenalty) thisElement).getP() < KnuthElement.INFINITE
+ && (!(allowedBreaks == NO_FLAGGED_PENALTIES) || !(((KnuthPenalty) thisElement).isFlagged()))
+ && (!(allowedBreaks == ONLY_FORCED_BREAKS) || ((KnuthPenalty) thisElement).getP() == -KnuthElement.INFINITE)) {
considerLegalBreak(thisElement, i);
}
previousIsBox = false;