You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2009/12/22 18:20:53 UTC
svn commit: r893238 [2/4] - in /xmlgraphics/fop/trunk:
src/java/org/apache/fop/area/ src/java/org/apache/fop/fo/properties/
src/java/org/apache/fop/layoutmgr/ src/java/org/apache/fop/layoutmgr/inline/
src/java/org/apache/fop/layoutmgr/list/ src/java/or...
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceResolver.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceResolver.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceResolver.java Tue Dec 22 17:20:51 2009
@@ -152,7 +152,7 @@
}
private void removeConditionalBorderAndPadding(
- UnresolvedListElement[] elems, MinOptMax[] lengths, boolean reverse) {
+ UnresolvedListElement[] elems, MinOptMax[] lengths, boolean reverse) {
for (int i = 0; i < elems.length; i++) {
int effIndex;
if (reverse) {
@@ -176,7 +176,7 @@
}
private void performSpaceResolutionRule1(UnresolvedListElement[] elems, MinOptMax[] lengths,
- boolean reverse) {
+ boolean reverse) {
for (int i = 0; i < elems.length; i++) {
int effIndex;
if (reverse) {
@@ -274,7 +274,7 @@
}
lengths[i] = null;
} else {
- greatestOptimum = Math.max(greatestOptimum, space.getLength().opt);
+ greatestOptimum = Math.max(greatestOptimum, space.getLength().getOpt());
remaining++;
}
}
@@ -291,7 +291,7 @@
continue;
}
space = (SpaceElement)elems[i];
- if (space.getLength().opt < greatestOptimum) {
+ if (space.getLength().getOpt() < greatestOptimum) {
if (log.isDebugEnabled()) {
log.debug("Nulling space-specifier with smaller optimum length "
+ "using 4.3.1, rule 3: "
@@ -313,8 +313,8 @@
continue;
}
space = (SpaceElement)elems[i];
- min = Math.max(min, space.getLength().min);
- max = Math.min(max, space.getLength().max);
+ min = Math.max(min, space.getLength().getMin());
+ max = Math.min(max, space.getLength().getMax());
if (remaining > 1) {
if (log.isDebugEnabled()) {
log.debug("Nulling non-last space-specifier using 4.3.1, rule 3, second part: "
@@ -323,8 +323,7 @@
lengths[i] = null;
remaining--;
} else {
- lengths[i].min = min;
- lengths[i].max = max;
+ lengths[i] = MinOptMax.getInstance(min, lengths[i].getOpt(), max);
}
}
@@ -409,54 +408,27 @@
}
private MinOptMax sum(MinOptMax[] lengths) {
- MinOptMax sum = new MinOptMax();
+ MinOptMax sum = MinOptMax.ZERO;
for (int i = 0; i < lengths.length; i++) {
if (lengths[i] != null) {
- sum.add(lengths[i]);
+ sum = sum.plus(lengths[i]);
}
}
return sum;
}
private void generate(ListIterator iter) {
- MinOptMax noBreakLength = new MinOptMax();
- MinOptMax glue1; //space before break possibility if break occurs
- //MinOptMax glue2; //difference between glue 1 and 3 when no break occurs
- MinOptMax glue3; //space after break possibility if break occurs
- glue1 = sum(firstPartLengths);
- glue3 = sum(secondPartLengths);
- noBreakLength = sum(noBreakLengths);
-
- //This doesn't produce the right glue2
- //glue2 = new MinOptMax(noBreakLength);
- //glue2.subtract(glue1);
- //glue2.subtract(glue3);
-
- int glue2w = noBreakLength.opt - glue1.opt - glue3.opt;
- int glue2stretch = (noBreakLength.max - noBreakLength.opt);
- int glue2shrink = (noBreakLength.opt - noBreakLength.min);
- glue2stretch -= glue1.max - glue1.opt;
- glue2stretch -= glue3.max - glue3.opt;
- glue2shrink -= glue1.opt - glue1.min;
- glue2shrink -= glue3.opt - glue3.min;
+ MinOptMax spaceBeforeBreak = sum(firstPartLengths);
+ MinOptMax spaceAfterBreak = sum(secondPartLengths);
boolean hasPrecedingNonBlock = false;
- if (log.isDebugEnabled()) {
- log.debug("noBreakLength=" + noBreakLength
- + ", glue1=" + glue1
- + ", glue2=" + glue2w + "+" + glue2stretch + "-" + glue2shrink
- + ", glue3=" + glue3);
- }
if (breakPoss != null) {
- boolean forcedBreak = breakPoss.isForcedBreak();
- if (glue1.isNonZero()) {
- iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE,
- false, (Position)null, true));
- iter.add(new KnuthGlue(glue1.opt, glue1.max - glue1.opt, glue1.opt - glue1.min,
- (Position)null, true));
- if (forcedBreak) {
+ if (spaceBeforeBreak.isNonZero()) {
+ iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, null, true));
+ iter.add(new KnuthGlue(spaceBeforeBreak, null, true));
+ if (breakPoss.isForcedBreak()) {
//Otherwise, the preceding penalty and glue will be cut off
- iter.add(new KnuthBox(0, (Position)null, true));
+ iter.add(new KnuthBox(0, null, true));
}
}
iter.add(new KnuthPenalty(breakPoss.getPenaltyWidth(), breakPoss.getPenaltyValue(),
@@ -465,32 +437,38 @@
if (breakPoss.getPenaltyValue() <= -KnuthPenalty.INFINITE) {
return; //return early. Not necessary (even wrong) to add additional elements
}
- if (glue2w != 0 || glue2stretch != 0 || glue2shrink != 0) {
- iter.add(new KnuthGlue(glue2w, glue2stretch, glue2shrink,
- (Position)null, true));
+
+ // No break
+ // TODO: We can't use a MinOptMax for glue2, because min <= opt <= max is not always true - why?
+ MinOptMax noBreakLength = sum(noBreakLengths);
+ MinOptMax spaceSum = spaceBeforeBreak.plus(spaceAfterBreak);
+ int glue2width = noBreakLength.getOpt() - spaceSum.getOpt();
+ int glue2stretch = noBreakLength.getStretch() - spaceSum.getStretch();
+ int glue2shrink = noBreakLength.getShrink() - spaceSum.getShrink();
+
+ if (glue2width != 0 || glue2stretch != 0 || glue2shrink != 0) {
+ iter.add(new KnuthGlue(glue2width, glue2stretch, glue2shrink, null, true));
}
} else {
- if (glue1.isNonZero()) {
- throw new IllegalStateException("glue1 should be 0 in this case");
+ if (spaceBeforeBreak.isNonZero()) {
+ throw new IllegalStateException("spaceBeforeBreak should be 0 in this case");
}
}
Position pos = null;
if (breakPoss == null) {
pos = new SpaceHandlingPosition(this);
}
- if (glue3.isNonZero() || pos != null) {
+ if (spaceAfterBreak.isNonZero() || pos != null) {
iter.add(new KnuthBox(0, pos, true));
}
- if (glue3.isNonZero()) {
- iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE,
- false, (Position)null, true));
- iter.add(new KnuthGlue(glue3.opt, glue3.max - glue3.opt, glue3.opt - glue3.min,
- (Position)null, true));
+ if (spaceAfterBreak.isNonZero()) {
+ iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, null, true));
+ iter.add(new KnuthGlue(spaceAfterBreak, null, true));
hasPrecedingNonBlock = true;
}
if (isLast && hasPrecedingNonBlock) {
//Otherwise, the preceding penalty and glue will be cut off
- iter.add(new KnuthBox(0, (Position)null, true));
+ iter.add(new KnuthBox(0, null, true));
}
}
@@ -608,9 +586,7 @@
/** {@inheritDoc} */
public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("SpaceHandlingPosition");
- return sb.toString();
+ return "SpaceHandlingPosition";
}
}
@@ -741,5 +717,4 @@
}
-
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java Tue Dec 22 17:20:51 2009
@@ -31,12 +31,10 @@
*/
public class SpaceSpecifier implements Cloneable {
-
private boolean startsReferenceArea;
private boolean hasForcing = false;
private List spaceVals = new ArrayList();
-
/**
* Creates a new SpaceSpecifier.
* @param startsReferenceArea true if it starts a new reference area
@@ -76,7 +74,7 @@
* @return true if any space-specifiers have been added.
*/
public boolean hasSpaces() {
- return (spaceVals.size() > 0);
+ return !spaceVals.isEmpty();
}
/**
@@ -84,24 +82,22 @@
* area, and the added space is conditional, and there are no
* non-conditional values in the sequence yet, then ignore it. Otherwise
* add it to the sequence.
+ *
+ * @param space the space to add.
*/
- public void addSpace(SpaceVal moreSpace) {
- if (!startsReferenceArea
- || !moreSpace.isConditional()
- || !spaceVals.isEmpty()) {
- if (moreSpace.isForcing()) {
+ public void addSpace(SpaceVal space) {
+ if (!startsReferenceArea || !space.isConditional() || hasSpaces()) {
+ if (space.isForcing()) {
if (!hasForcing) {
// Remove all other values (must all be non-forcing)
spaceVals.clear();
hasForcing = true;
}
- spaceVals.add(moreSpace);
+ spaceVals.add(space);
} else if (!hasForcing) {
// Don't bother adding all 0 space-specifier if not forcing
- if (moreSpace.getSpace().min != 0
- || moreSpace.getSpace().opt != 0
- || moreSpace.getSpace().max != 0) {
- spaceVals.add(moreSpace);
+ if (space.getSpace().isNonZero()) {
+ spaceVals.add(space);
}
}
}
@@ -109,11 +105,11 @@
/**
- * Resolve the current sequence of space-specifiers, accounting for
- * forcing values.
- * @param endsReferenceArea True if the sequence should be resolved
- * at the trailing edge of reference area.
- * @return The resolved value as a min/opt/max triple.
+ * Resolve the current sequence of space-specifiers, accounting for forcing values.
+ *
+ * @param endsReferenceArea whether the sequence should be resolved at the trailing edge of
+ * reference area.
+ * @return the resolved value as a min/opt/max triple.
*/
public MinOptMax resolve(boolean endsReferenceArea) {
int lastIndex = spaceVals.size();
@@ -127,24 +123,30 @@
}
}
}
- MinOptMax resolvedSpace = new MinOptMax(0);
+ MinOptMax resolvedSpace = MinOptMax.ZERO;
int maxPrecedence = -1;
for (int index = 0; index < lastIndex; index++) {
SpaceVal spaceVal = (SpaceVal) spaceVals.get(index);
+ MinOptMax space = spaceVal.getSpace();
if (hasForcing) {
- resolvedSpace.add(spaceVal.getSpace());
- } else if (spaceVal.getPrecedence() > maxPrecedence) {
- maxPrecedence = spaceVal.getPrecedence();
- resolvedSpace = spaceVal.getSpace();
- } else if (spaceVal.getPrecedence() == maxPrecedence) {
- if (spaceVal.getSpace().opt > resolvedSpace.opt) {
- resolvedSpace = spaceVal.getSpace();
- } else if (spaceVal.getSpace().opt == resolvedSpace.opt) {
- if (resolvedSpace.min < spaceVal.getSpace().min) {
- resolvedSpace.min = spaceVal.getSpace().min;
- }
- if (resolvedSpace.max > spaceVal.getSpace().max) {
- resolvedSpace.max = spaceVal.getSpace().max;
+ resolvedSpace = resolvedSpace.plus(space);
+ } else {
+ int precedence = spaceVal.getPrecedence();
+ if (precedence > maxPrecedence) {
+ maxPrecedence = precedence;
+ resolvedSpace = space;
+ } else if (precedence == maxPrecedence) {
+ if (space.getOpt() > resolvedSpace.getOpt()) {
+ resolvedSpace = space;
+ } else if (space.getOpt() == resolvedSpace.getOpt()) {
+ if (resolvedSpace.getMin() < space.getMin()) {
+ resolvedSpace = MinOptMax.getInstance(space.getMin(),
+ resolvedSpace.getOpt(), resolvedSpace.getMax());
+ }
+ if (resolvedSpace.getMax() > space.getMax()) {
+ resolvedSpace = MinOptMax.getInstance(resolvedSpace.getMin(),
+ resolvedSpace.getOpt(), space.getMax());
+ }
}
}
}
@@ -154,8 +156,7 @@
}
public String toString() {
- return "Space Specifier (resolved at begin/end of ref. area:):\n" +
- resolve(false).toString() + "\n" +
- resolve(true).toString();
+ return "Space Specifier (resolved at begin/end of ref. area:):\n"
+ + resolve(false) + "\n" + resolve(true);
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/TraitSetter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/TraitSetter.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/TraitSetter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/TraitSetter.java Tue Dec 22 17:20:51 2009
@@ -21,6 +21,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.area.Area;
import org.apache.fop.area.Trait;
import org.apache.fop.datatypes.LengthBase;
@@ -29,7 +30,6 @@
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.CommonMarginBlock;
-import org.apache.fop.fo.properties.CommonMarginBlock;
import org.apache.fop.fo.properties.CommonTextDecoration;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
import org.apache.fop.fonts.Font;
@@ -46,11 +46,12 @@
/**
* Sets border and padding traits on areas.
- * @param area area to set the traits on
- * @param bpProps border and padding properties
+ *
+ * @param area area to set the traits on
+ * @param bpProps border and padding properties
* @param bNotFirst True if the area is not the first area
- * @param bNotLast True if the area is not the last area
- * @param context Property evaluation context
+ * @param bNotLast True if the area is not the last area
+ * @param context Property evaluation context
*/
public static void setBorderPaddingTraits(Area area,
CommonBorderPaddingBackground bpProps, boolean bNotFirst, boolean bNotLast,
@@ -74,27 +75,28 @@
}
addBorderTrait(area, bpProps, bNotFirst,
- CommonBorderPaddingBackground.START,
- BorderProps.SEPARATE, Trait.BORDER_START);
+ CommonBorderPaddingBackground.START,
+ BorderProps.SEPARATE, Trait.BORDER_START);
addBorderTrait(area, bpProps, bNotLast,
- CommonBorderPaddingBackground.END,
- BorderProps.SEPARATE, Trait.BORDER_END);
+ CommonBorderPaddingBackground.END,
+ BorderProps.SEPARATE, Trait.BORDER_END);
addBorderTrait(area, bpProps, false,
- CommonBorderPaddingBackground.BEFORE,
- BorderProps.SEPARATE, Trait.BORDER_BEFORE);
+ CommonBorderPaddingBackground.BEFORE,
+ BorderProps.SEPARATE, Trait.BORDER_BEFORE);
addBorderTrait(area, bpProps, false,
- CommonBorderPaddingBackground.AFTER,
- BorderProps.SEPARATE, Trait.BORDER_AFTER);
+ CommonBorderPaddingBackground.AFTER,
+ BorderProps.SEPARATE, Trait.BORDER_AFTER);
}
/**
* Sets border traits on an area.
- * @param area area to set the traits on
+ *
+ * @param area area to set the traits on
* @param bpProps border and padding properties
- * @param mode the border paint mode (see BorderProps)
+ * @param mode the border paint mode (see BorderProps)
*/
private static void addBorderTrait(Area area,
CommonBorderPaddingBackground bpProps,
@@ -103,9 +105,9 @@
int iBP = bpProps.getBorderWidth(iSide, bDiscard);
if (iBP > 0) {
area.addTrait(oTrait,
- new BorderProps(bpProps.getBorderStyle(iSide),
- iBP, bpProps.getBorderColor(iSide),
- mode));
+ new BorderProps(bpProps.getBorderStyle(iSide),
+ iBP, bpProps.getBorderColor(iSide),
+ mode));
}
}
@@ -119,7 +121,7 @@
* @deprecated Call the other addBorders() method and addPadding separately.
*/
public static void addBorders(Area area, CommonBorderPaddingBackground bordProps,
- PercentBaseContext context) {
+ PercentBaseContext context) {
BorderProps bps = getBorderProps(bordProps, CommonBorderPaddingBackground.BEFORE);
if (bps != null) {
area.addTrait(Trait.BORDER_BEFORE, bps);
@@ -397,9 +399,9 @@
int imageWidthMpt = back.getImageInfo().getSize().getWidthMpt();
int lengthBaseValue = width - imageWidthMpt;
SimplePercentBaseContext simplePercentBaseContext
- = new SimplePercentBaseContext(context,
- LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL,
- lengthBaseValue);
+ = new SimplePercentBaseContext(context,
+ LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL,
+ lengthBaseValue);
int horizontal = backProps.backgroundPositionHorizontal.getValue(
simplePercentBaseContext);
back.setHoriz(horizontal);
@@ -421,7 +423,7 @@
int imageHeightMpt = back.getImageInfo().getSize().getHeightMpt();
int lengthBaseValue = height - imageHeightMpt;
SimplePercentBaseContext simplePercentBaseContext
- = new SimplePercentBaseContext(context,
+ = new SimplePercentBaseContext(context,
LengthBase.IMAGE_BACKGROUND_POSITION_VERTICAL,
lengthBaseValue);
int vertical = backProps.backgroundPositionVertical.getValue(
@@ -459,8 +461,8 @@
}
int spaceStart = startIndent
- - bpProps.getBorderStartWidth(false)
- - bpProps.getPaddingStart(false, context);
+ - bpProps.getBorderStartWidth(false)
+ - bpProps.getPaddingStart(false, context);
if (spaceStart != 0) {
area.addTrait(Trait.SPACE_START, new Integer(spaceStart));
}
@@ -469,8 +471,8 @@
area.addTrait(Trait.END_INDENT, new Integer(endIndent));
}
int spaceEnd = endIndent
- - bpProps.getBorderEndWidth(false)
- - bpProps.getPaddingEnd(false, context);
+ - bpProps.getBorderEndWidth(false)
+ - bpProps.getPaddingEnd(false, context);
if (spaceEnd != 0) {
area.addTrait(Trait.SPACE_END, new Integer(spaceEnd));
}
@@ -504,14 +506,15 @@
public static int getEffectiveSpace(double adjust, MinOptMax space) {
if (space == null) {
return 0;
- }
- int sp = space.opt;
- if (adjust > 0) {
- sp = sp + (int)(adjust * (space.max - space.opt));
} else {
- sp = sp + (int)(adjust * (space.opt - space.min));
+ int spaceOpt = space.getOpt();
+ if (adjust > 0) {
+ spaceOpt += (int) (adjust * space.getStretch());
+ } else {
+ spaceOpt += (int) (adjust * space.getShrink());
+ }
+ return spaceOpt;
}
- return sp;
}
/**
@@ -521,16 +524,17 @@
* @param spaceBefore the space-before space specifier
* @param spaceAfter the space-after space specifier
*/
- public static void addSpaceBeforeAfter(Area area, double adjust,
- MinOptMax spaceBefore, MinOptMax spaceAfter) {
- int space;
- space = getEffectiveSpace(adjust, spaceBefore);
- if (space != 0) {
- area.addTrait(Trait.SPACE_BEFORE, new Integer(space));
- }
- space = getEffectiveSpace(adjust, spaceAfter);
- if (space != 0) {
- area.addTrait(Trait.SPACE_AFTER, new Integer(space));
+ public static void addSpaceBeforeAfter(Area area, double adjust, MinOptMax spaceBefore,
+ MinOptMax spaceAfter) {
+ addSpaceTrait(area, Trait.SPACE_BEFORE, spaceBefore, adjust);
+ addSpaceTrait(area, Trait.SPACE_AFTER, spaceAfter, adjust);
+ }
+
+ private static void addSpaceTrait(Area area, Integer spaceTrait,
+ MinOptMax space, double adjust) {
+ int effectiveSpace = getEffectiveSpace(adjust, space);
+ if (effectiveSpace != 0) {
+ area.addTrait(spaceTrait, new Integer(effectiveSpace));
}
}
@@ -540,7 +544,7 @@
* @param breakBefore the value for break-before
* @param breakAfter the value for break-after
*/
- public static void addBreaks(Area area, int breakBefore, int breakAfter) {
+ public static void addBreaks(Area area, int breakBefore, int breakAfter) {
/* Currently disabled as these traits are never used by the renderers
area.addTrait(Trait.BREAK_AFTER, new Integer(breakAfter));
area.addTrait(Trait.BREAK_BEFORE, new Integer(breakBefore));
@@ -593,7 +597,7 @@
area.addTrait(Trait.PTR, ptr);
}
}
-
+
/**
* Sets the producer's ID as a trait on the area. This can be used to track back the
* generating FO node.
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -23,6 +23,7 @@
import java.util.List;
import org.apache.fop.area.Trait;
+import org.apache.fop.area.inline.TextArea;
import org.apache.fop.fo.flow.Character;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fonts.Font;
@@ -67,14 +68,13 @@
hyphIPD = fobj.getCommonHyphenation().getHyphIPD(font);
borderProps = fobj.getCommonBorderPaddingBackground();
setCommonBorderPaddingBackground(borderProps);
- org.apache.fop.area.inline.TextArea chArea = getCharacterInlineArea(fobj);
+ TextArea chArea = getCharacterInlineArea(fobj);
chArea.setBaselineOffset(font.getAscender());
setCurrentArea(chArea);
}
- private org.apache.fop.area.inline.TextArea getCharacterInlineArea(Character node) {
- org.apache.fop.area.inline.TextArea text
- = new org.apache.fop.area.inline.TextArea();
+ private TextArea getCharacterInlineArea(Character node) {
+ TextArea text = new TextArea();
char ch = node.getCharacter();
if (CharUtilities.isAnySpace(ch)) {
// add space unless it's zero-width:
@@ -103,9 +103,9 @@
Character fobj = (Character)this.fobj;
- ipd = new MinOptMax(font.getCharWidth(fobj.getCharacter()));
+ ipd = MinOptMax.getInstance(font.getCharWidth(fobj.getCharacter()));
- curArea.setIPD(ipd.opt);
+ curArea.setIPD(ipd.getOpt());
curArea.setBPD(font.getAscender() - font.getDescender());
TraitSetter.addFontTraits(curArea, font);
@@ -126,16 +126,16 @@
areaInfo = new AreaInfo((short) 0, ipd, false, alignmentContext);
// node is a fo:Character
- if (letterSpaceIPD.min == letterSpaceIPD.max) {
+ if (letterSpaceIPD.isStiff()) {
// constant letter space, only return a box
- seq.add(new KnuthInlineBox(areaInfo.ipdArea.opt, areaInfo.alignmentContext,
+ seq.add(new KnuthInlineBox(areaInfo.ipdArea.getOpt(), areaInfo.alignmentContext,
notifyPos(new LeafPosition(this, 0)), false));
} else {
// adjustable letter space, return a sequence of elements;
// at the moment the character is supposed to have no letter spaces,
// but returning this sequence allows us to change only one element
// if addALetterSpaceTo() is called
- seq.add(new KnuthInlineBox(areaInfo.ipdArea.opt, areaInfo.alignmentContext,
+ seq.add(new KnuthInlineBox(areaInfo.ipdArea.getOpt(), areaInfo.alignmentContext,
notifyPos(new LeafPosition(this, 0)), false));
seq.add(new KnuthPenalty(0, KnuthElement.INFINITE, false,
new LeafPosition(this, -1), true));
@@ -154,9 +154,8 @@
}
/** {@inheritDoc} */
- public void getWordChars(StringBuffer sbChars, Position bp) {
- sbChars.append
- (((org.apache.fop.area.inline.TextArea) curArea).getText());
+ public String getWordChars(Position pos) {
+ return ((TextArea) curArea).getText();
}
/** {@inheritDoc} */
@@ -189,10 +188,9 @@
addKnuthElementsForBorderPaddingStart(returnList);
- if (letterSpaceIPD.min == letterSpaceIPD.max
- || areaInfo.iLScount == 0) {
+ if (letterSpaceIPD.isStiff() || areaInfo.iLScount == 0) {
// constant letter space, or no letter space
- returnList.add(new KnuthInlineBox(areaInfo.ipdArea.opt,
+ returnList.add(new KnuthInlineBox(areaInfo.ipdArea.getOpt(),
areaInfo.alignmentContext,
notifyPos(new LeafPosition(this, 0)), false));
if (areaInfo.bHyphenated) {
@@ -202,24 +200,17 @@
}
} else {
// adjustable letter space
- returnList.add
- (new KnuthInlineBox(areaInfo.ipdArea.opt
- - areaInfo.iLScount * letterSpaceIPD.opt,
- areaInfo.alignmentContext,
- notifyPos(new LeafPosition(this, 0)), false));
+ returnList.add(new KnuthInlineBox(areaInfo.ipdArea.getOpt()
+ - areaInfo.iLScount * letterSpaceIPD.getOpt(), areaInfo.alignmentContext,
+ notifyPos(new LeafPosition(this, 0)), false));
returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false,
- new LeafPosition(this, -1), true));
- returnList.add
- (new KnuthGlue(areaInfo.iLScount * letterSpaceIPD.opt,
- areaInfo.iLScount * letterSpaceIPD.max - letterSpaceIPD.opt,
- areaInfo.iLScount * letterSpaceIPD.opt - letterSpaceIPD.min,
- new LeafPosition(this, -1), true));
- returnList.add(new KnuthInlineBox(0, null,
- notifyPos(new LeafPosition(this, -1)), true));
+ new LeafPosition(this, -1), true));
+ returnList.add(new KnuthGlue(letterSpaceIPD.mult(areaInfo.iLScount),
+ new LeafPosition(this, -1), true));
+ returnList.add(new KnuthInlineBox(0, null, notifyPos(new LeafPosition(this, -1)), true));
if (areaInfo.bHyphenated) {
- returnList.add
- (new KnuthPenalty(hyphIPD, KnuthPenalty.FLAGGED_PENALTY, true,
- new LeafPosition(this, -1), false));
+ returnList.add(new KnuthPenalty(hyphIPD, KnuthPenalty.FLAGGED_PENALTY, true,
+ new LeafPosition(this, -1), false));
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -296,7 +296,8 @@
log.warn(this.getClass().getName() + " should not receive a call to removeWordSpace(list)");
}
- public void getWordChars(StringBuffer sbChars, Position pos) {
+ public String getWordChars(Position pos) {
+ return "";
}
public void hyphenate(Position pos, HyphContext hc) {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -19,6 +19,7 @@
package org.apache.fop.layoutmgr.inline;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
@@ -144,7 +145,7 @@
padding += borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false, this);
padding += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false);
}
- extraBPD = new MinOptMax(padding);
+ extraBPD = MinOptMax.getInstance(padding);
}
@@ -161,7 +162,7 @@
borderAndPadding
+= borderProps.getBorderWidth(CommonBorderPaddingBackground.END, isNotLast);
}
- return new MinOptMax(borderAndPadding);
+ return MinOptMax.getInstance(borderAndPadding);
}
@@ -325,16 +326,20 @@
KnuthSequence sequence = (KnuthSequence) seqIter.next();
sequence.wrapPositions(this);
}
+ int insertionStartIndex = 0;
if (lastSequence != null && lastSequence.appendSequenceOrClose
((KnuthSequence) returnedList.get(0))) {
- returnedList.remove(0);
+ insertionStartIndex = 1;
}
// add border and padding to the first complete sequence of this LM
if (!borderAdded && !returnedList.isEmpty()) {
addKnuthElementsForBorderPaddingStart((KnuthSequence) returnedList.get(0));
borderAdded = true;
}
- returnList.addAll(returnedList);
+ for (Iterator iter = returnedList.listIterator(insertionStartIndex);
+ iter.hasNext();) {
+ returnList.add(iter.next());
+ }
} else { // A block LM
BlockKnuthSequence sequence = new BlockKnuthSequence(returnedList);
sequence.wrapPositions(this);
@@ -488,8 +493,7 @@
boolean isLast = (getContext().isLastArea() && prevLM == lastChildLM);
if (hasTrailingFence(isLast)) {
- addSpace(getCurrentArea(),
- getContext().getTrailingSpace().resolve(false),
+ addSpace(getCurrentArea(), getContext().getTrailingSpace().resolve(false),
getContext().getSpaceAdjust());
context.setTrailingSpace(new SpaceSpecifier(false));
} else {
@@ -504,7 +508,7 @@
// Not sure if lastPos can legally be null or if that masks a different problem.
// But it seems to fix bug 38053.
setTraits(areaCreated, lastPos == null || !isLast(lastPos));
- parentLM.addChildArea(getCurrentArea());
+ parentLayoutManager.addChildArea(getCurrentArea());
addMarkersToPage(
false,
@@ -520,8 +524,7 @@
public void addChildArea(Area childArea) {
Area parent = getCurrentArea();
if (getContext().resolveLeadingSpace()) {
- addSpace(parent,
- getContext().getLeadingSpace().resolve(false),
+ addSpace(parent, getContext().getLeadingSpace().resolve(false),
getContext().getSpaceAdjust());
}
parent.addChildArea(childArea);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -48,20 +48,19 @@
void removeWordSpace(List oldList);
/**
- * Get the word chars corresponding to the given position
+ * Get the word chars corresponding to the given position.
*
- * @param sbChars the StringBuffer used to append word chars
- * @param pos the Position referring to the needed word chars
+ * @param pos the position referring to the needed word chars.
*/
- void getWordChars(StringBuffer sbChars, Position pos);
+ String getWordChars(Position pos);
/**
* Tell the LM to hyphenate a word
*
* @param pos the Position referring to the word
- * @param hc the HyphContext storing hyphenation information
+ * @param hyphContext the HyphContext storing hyphenation information
*/
- void hyphenate(Position pos, HyphContext hc);
+ void hyphenate(Position pos, HyphContext hyphContext);
/**
* Tell the LM to apply the changes due to hyphenation
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -80,7 +80,7 @@
*/
protected InlineStackingLayoutManager(FObj node) {
super(node);
- extraBPD = new MinOptMax(0);
+ extraBPD = MinOptMax.ZERO;
}
/**
@@ -100,7 +100,7 @@
* @return the extra IPD as a MinOptMax spec
*/
protected MinOptMax getExtraIPD(boolean bNotFirst, boolean bNotLast) {
- return new MinOptMax(0);
+ return MinOptMax.ZERO;
}
@@ -179,23 +179,21 @@
}
/**
- * Adds a space to the area
+ * Adds a space to the area.
+ *
* @param parentArea the area to which to add the space
* @param spaceRange the space range specifier
- * @param dSpaceAdjust the factor by which to stretch or shrink the space
+ * @param spaceAdjust the factor by which to stretch or shrink the space
*/
- protected void addSpace(Area parentArea, MinOptMax spaceRange,
- double dSpaceAdjust) {
+ protected void addSpace(Area parentArea, MinOptMax spaceRange, double spaceAdjust) {
if (spaceRange != null) {
- int iAdjust = spaceRange.opt;
- if (dSpaceAdjust > 0.0) {
+ int iAdjust = spaceRange.getOpt();
+ if (spaceAdjust > 0.0) {
// Stretch by factor
- iAdjust += (int) ((double) (spaceRange.max
- - spaceRange.opt) * dSpaceAdjust);
- } else if (dSpaceAdjust < 0.0) {
+ iAdjust += (int) (spaceRange.getStretch() * spaceAdjust);
+ } else if (spaceAdjust < 0.0) {
// Shrink by factor
- iAdjust += (int) ((double) (spaceRange.opt
- - spaceRange.min) * dSpaceAdjust);
+ iAdjust += (int) (spaceRange.getShrink() * spaceAdjust);
}
if (iAdjust != 0) {
//getLogger().debug("Add leading space: " + iAdjust);
@@ -257,10 +255,9 @@
}
/** {@inheritDoc} */
- public void getWordChars(StringBuffer sbChars, Position pos) {
+ public String getWordChars(Position pos) {
Position newPos = pos.getPosition();
- ((InlineLevelLayoutManager)
- newPos.getLM()).getWordChars(sbChars, newPos);
+ return ((InlineLevelLayoutManager) newPos.getLM()).getWordChars(newPos);
}
/** {@inheritDoc} */
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java Tue Dec 22 17:20:51 2009
@@ -19,7 +19,6 @@
package org.apache.fop.layoutmgr.inline;
-import org.apache.fop.layoutmgr.inline.AlignmentContext;
import org.apache.fop.layoutmgr.FootnoteBodyLayoutManager;
import org.apache.fop.layoutmgr.KnuthBox;
import org.apache.fop.layoutmgr.Position;
@@ -32,13 +31,13 @@
/**
* Create a new KnuthBox.
*
- * @param w the width of this box
+ * @param width the width of this box
* @param alignmentContext the alignmentContext for this box
- * @param pos the Position stored in this box
- * @param bAux is this box auxiliary?
+ * @param pos the Position stored in this box
+ * @param auxiliary is this box auxiliary?
*/
- public KnuthInlineBox(int w, AlignmentContext alignmentContext, Position pos, boolean bAux) {
- super(w, pos, bAux);
+ public KnuthInlineBox(int width, AlignmentContext alignmentContext, Position pos, boolean auxiliary) {
+ super(width, pos, auxiliary);
this.alignmentContext = alignmentContext;
}
@@ -69,11 +68,4 @@
public boolean isAnchor() {
return (footnoteBodyLM != null);
}
-
-
- /** {@inheritDoc} */
- public String toString() {
- StringBuffer sb = new StringBuffer(super.toString());
- return sb.toString();
- }
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -19,6 +19,7 @@
package org.apache.fop.layoutmgr.inline;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -109,7 +110,7 @@
- borderPaddingWidth;
int max = fobj.getLeaderLength().getMaximum(this).getLength().getValue(this)
- borderPaddingWidth;
- return new MinOptMax(min, opt, max);
+ return MinOptMax.getInstance(min, opt, max);
}
private InlineArea getLeaderInlineArea(LayoutContext context) {
@@ -226,7 +227,7 @@
KnuthPossPosIter contentIter = new KnuthPossPosIter(contentList, 0, contentList.size());
clm.addAreas(contentIter, context);
- parentLM.addChildArea(curArea);
+ parentLayoutManager.addChildArea(curArea);
while (posIter.hasNext()) {
posIter.next();
@@ -235,8 +236,7 @@
}
/** {@inheritDoc} */
- public List getNextKnuthElements(LayoutContext context,
- int alignment) {
+ public List getNextKnuthElements(LayoutContext context, int alignment) {
MinOptMax ipd;
curArea = get(context);
KnuthSequence seq = new InlineKnuthSequence();
@@ -256,45 +256,34 @@
ipd = getAllocationIPD(context.getRefIPD());
if (fobj.getLeaderPattern() == EN_USECONTENT && curArea instanceof FilledArea) {
// If we have user supplied content make it fit if we can
- int unitWidth = ((FilledArea)curArea).getUnitWidth();
- if (ipd.opt < unitWidth && ipd.max >= unitWidth) {
- ipd.opt = unitWidth;
+ int unitWidth = ((FilledArea) curArea).getUnitWidth();
+ if (ipd.getOpt() < unitWidth && unitWidth <= ipd.getMax()) {
+ ipd = MinOptMax.getInstance(ipd.getMin(), unitWidth, ipd.getMax());
}
}
// create the AreaInfo object to store the computed values
areaInfo = new AreaInfo((short) 0, ipd, false, context.getAlignmentContext());
- curArea.setAdjustingInfo(ipd.max - ipd.opt, ipd.opt - ipd.min, 0);
+ curArea.setAdjustingInfo(ipd.getStretch(), ipd.getShrink(), 0);
addKnuthElementsForBorderPaddingStart(seq);
// node is a fo:Leader
- seq.add(new KnuthInlineBox(0, alignmentContext,
- new LeafPosition(this, -1), true));
+ seq.add(new KnuthInlineBox(0, alignmentContext, new LeafPosition(this, -1), true));
seq.add(new KnuthPenalty(0, KnuthElement.INFINITE, false,
- new LeafPosition(this, -1), true));
+ new LeafPosition(this, -1), true));
if (alignment == EN_JUSTIFY || alignment == 0) {
- seq.add
- (new KnuthGlue(areaInfo.ipdArea.opt,
- areaInfo.ipdArea.max - areaInfo.ipdArea.opt,
- areaInfo.ipdArea.opt - areaInfo.ipdArea.min,
- new LeafPosition(this, 0), false));
+ seq.add(new KnuthGlue(areaInfo.ipdArea, new LeafPosition(this, 0), false));
} else {
- seq.add
- (new KnuthGlue(areaInfo.ipdArea.opt,
- 0,
- 0,
- new LeafPosition(this, 0), false));
+ seq.add(new KnuthGlue(areaInfo.ipdArea.getOpt(), 0, 0,
+ new LeafPosition(this, 0), false));
}
- seq.add(new KnuthInlineBox(0, alignmentContext,
- new LeafPosition(this, -1), true));
+ seq.add(new KnuthInlineBox(0, alignmentContext, new LeafPosition(this, -1), true));
addKnuthElementsForBorderPaddingEnd(seq);
- LinkedList returnList = new LinkedList();
- returnList.add(seq);
setFinished(true);
- return returnList;
+ return Collections.singletonList(seq);
}
/** {@inheritDoc} */
@@ -310,8 +299,7 @@
}
/** {@inheritDoc} */
- public List getChangedKnuthElements(List oldList,
- int alignment) {
+ public List getChangedKnuthElements(List oldList, int alignment) {
if (isFinished()) {
return null;
}
@@ -325,17 +313,10 @@
returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false,
new LeafPosition(this, -1), true));
if (alignment == EN_JUSTIFY || alignment == 0) {
- returnList.add
- (new KnuthGlue(areaInfo.ipdArea.opt,
- areaInfo.ipdArea.max - areaInfo.ipdArea.opt,
- areaInfo.ipdArea.opt - areaInfo.ipdArea.min,
- new LeafPosition(this, 0), false));
+ returnList.add(new KnuthGlue(areaInfo.ipdArea, new LeafPosition(this, 0), false));
} else {
- returnList.add
- (new KnuthGlue(areaInfo.ipdArea.opt,
- 0,
- 0,
- new LeafPosition(this, 0), false));
+ returnList.add(new KnuthGlue(areaInfo.ipdArea.getOpt(), 0, 0,
+ new LeafPosition(this, 0), false));
}
returnList.add(new KnuthInlineBox(0, areaInfo.alignmentContext,
new LeafPosition(this, -1), true));
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -21,6 +21,7 @@
import java.util.LinkedList;
import java.util.List;
+import java.util.Collections;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -163,7 +164,7 @@
* @return the min/opt/max ipd of the inline area
*/
protected MinOptMax getAllocationIPD(int refIPD) {
- return new MinOptMax(curArea.getIPD());
+ return MinOptMax.getInstance(curArea.getIPD());
}
/**
@@ -186,7 +187,7 @@
false, false, this);
TraitSetter.addBackground(area, commonBorderPaddingBackground, this);
}
- parentLM.addChildArea(area);
+ parentLayoutManager.addChildArea(area);
}
while (posIter.hasNext()) {
@@ -236,16 +237,14 @@
*/
protected void widthAdjustArea(InlineArea area, LayoutContext context) {
double dAdjust = context.getIPDAdjust();
- int width = areaInfo.ipdArea.opt;
+ int adjustment = 0;
if (dAdjust < 0) {
- width = (int) (width + dAdjust * (areaInfo.ipdArea.opt
- - areaInfo.ipdArea.min));
+ adjustment += (int) (dAdjust * areaInfo.ipdArea.getShrink());
} else if (dAdjust > 0) {
- width = (int) (width + dAdjust * (areaInfo.ipdArea.max
- - areaInfo.ipdArea.opt));
+ adjustment += (int) (dAdjust * areaInfo.ipdArea.getStretch());
}
- area.setIPD(width);
- area.setAdjustment(width - areaInfo.ipdArea.opt);
+ area.setIPD(areaInfo.ipdArea.getOpt() + adjustment);
+ area.setAdjustment(adjustment);
}
/** {@inheritDoc} */
@@ -270,16 +269,13 @@
addKnuthElementsForBorderPaddingStart(seq);
- seq.add(new KnuthInlineBox(areaInfo.ipdArea.opt, alignmentContext,
+ seq.add(new KnuthInlineBox(areaInfo.ipdArea.getOpt(), alignmentContext,
notifyPos(new LeafPosition(this, 0)), false));
addKnuthElementsForBorderPaddingEnd(seq);
- LinkedList returnList = new LinkedList();
-
- returnList.add(seq);
setFinished(true);
- return returnList;
+ return Collections.singletonList(seq);
}
/** {@inheritDoc} */
@@ -299,11 +295,12 @@
}
/** {@inheritDoc} */
- public void getWordChars(StringBuffer sbChars, Position pos) {
+ public String getWordChars(Position pos) {
+ return "";
}
/** {@inheritDoc} */
- public void hyphenate(Position pos, HyphContext hc) {
+ public void hyphenate(Position pos, HyphContext hyphContext) {
}
/** {@inheritDoc} */
@@ -325,7 +322,7 @@
// fobj is a fo:ExternalGraphic, fo:InstreamForeignObject,
// fo:PageNumber or fo:PageNumberCitation
- returnList.add(new KnuthInlineBox(areaInfo.ipdArea.opt, areaInfo.alignmentContext,
+ returnList.add(new KnuthInlineBox(areaInfo.ipdArea.getOpt(), areaInfo.alignmentContext,
notifyPos(new LeafPosition(this, 0)), true));
addKnuthElementsForBorderPaddingEnd(returnList);
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -43,6 +43,7 @@
import org.apache.fop.fonts.FontTriplet;
import org.apache.fop.hyphenation.Hyphenation;
import org.apache.fop.hyphenation.Hyphenator;
+import org.apache.fop.layoutmgr.Adjustment;
import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
import org.apache.fop.layoutmgr.BreakElement;
import org.apache.fop.layoutmgr.BreakingAlgorithm;
@@ -235,11 +236,10 @@
// set the minimum amount of empty space at the end of the
// last line
if (textAlignment == EN_CENTER) {
- lineFiller = new MinOptMax(lastLineEndIndent);
+ lineFiller = MinOptMax.getInstance(lastLineEndIndent);
} else {
- lineFiller = new MinOptMax(lastLineEndIndent,
- lastLineEndIndent,
- layoutManager.ipd);
+ lineFiller = MinOptMax.getInstance(lastLineEndIndent, lastLineEndIndent,
+ layoutManager.ipd);
}
// add auxiliary elements at the beginning of the paragraph
@@ -272,7 +272,7 @@
&& textAlignmentLast != EN_JUSTIFY) {
this.add(new KnuthGlue(0, 3 * DEFAULT_SPACE_WIDTH, 0,
null, false));
- this.add(new KnuthPenalty(lineFiller.opt, -KnuthElement.INFINITE,
+ this.add(new KnuthPenalty(lineFiller.getOpt(), -KnuthElement.INFINITE,
false, null, false));
ignoreAtEnd = 2;
} else if (textAlignmentLast != EN_JUSTIFY) {
@@ -282,14 +282,14 @@
this.add(new KnuthPenalty(0, KnuthElement.INFINITE,
false, null, false));
this.add(new KnuthGlue(0,
- lineFiller.max - lineFiller.opt,
- lineFiller.opt - lineFiller.min, null, false));
- this.add(new KnuthPenalty(lineFiller.opt, -KnuthElement.INFINITE,
+ lineFiller.getStretch(),
+ lineFiller.getShrink(), null, false));
+ this.add(new KnuthPenalty(lineFiller.getOpt(), -KnuthElement.INFINITE,
false, null, false));
ignoreAtEnd = 3;
} else {
// add only the element representing the forced break
- this.add(new KnuthPenalty(lineFiller.opt, -KnuthElement.INFINITE,
+ this.add(new KnuthPenalty(lineFiller.getOpt(), -KnuthElement.INFINITE,
false, null, false));
ignoreAtEnd = 1;
}
@@ -393,7 +393,7 @@
(bestActiveNode.line > 1 ? bestActiveNode.previous.position + 1 : 0),
bestActiveNode.position,
bestActiveNode.availableShrink - (addedPositions > 0
- ? 0 : ((Paragraph)par).lineFiller.opt - ((Paragraph)par).lineFiller.min),
+ ? 0 : ((Paragraph) par).lineFiller.getShrink()),
bestActiveNode.availableStretch,
difference, ratio, indent), activePossibility);
addedPositions++;
@@ -784,7 +784,7 @@
int iBPcount = 0;
LineBreakingAlgorithm alg = new LineBreakingAlgorithm(alignment,
textAlignment, textAlignmentLast,
- textIndent.getValue(this), currPar.lineFiller.opt,
+ textIndent.getValue(this), currPar.lineFiller.getOpt(),
lineHeight.getValue(this), lead, follow,
(knuthParagraphs.indexOf(currPar) == 0),
hyphenationLadderCount.getEnum() == EN_NO_LIMIT
@@ -1057,12 +1057,12 @@
breaker.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, elementPosition, false));
breaker.add(new KnuthGlue(0, -nConditionalOptionalLines * constantLineHeight,
-nConditionalEliminableLines * constantLineHeight,
- LINE_NUMBER_ADJUSTMENT, elementPosition, false));
+ Adjustment.LINE_NUMBER_ADJUSTMENT, elementPosition, false));
breaker.add(new KnuthPenalty(nConditionalOptionalLines * constantLineHeight,
0, false, elementPosition, false));
breaker.add(new KnuthGlue(0, nConditionalOptionalLines * constantLineHeight,
nConditionalEliminableLines * constantLineHeight,
- LINE_NUMBER_ADJUSTMENT, elementPosition, false));
+ Adjustment.LINE_NUMBER_ADJUSTMENT, elementPosition, false));
} else if (nLastLines != 0) {
breaker.add(new KnuthPenalty(0, 0, false, elementPosition, false));
}
@@ -1083,7 +1083,7 @@
list.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, elementPosition, false));
list.add(new KnuthGlue(0, nConditionalOptionalLines * constantLineHeight,
nConditionalEliminableLines * constantLineHeight,
- LINE_NUMBER_ADJUSTMENT, elementPosition, false));
+ Adjustment.LINE_NUMBER_ADJUSTMENT, elementPosition, false));
list.add(new KnuthBox(0, elementPosition,
(nLastLines == 0 ? true : false)));
}
@@ -1094,7 +1094,7 @@
list.add(new KnuthBox(0, elementPosition, false));
list.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, elementPosition, false));
list.add(new KnuthGlue(0, 1 * constantLineHeight, 0,
- LINE_NUMBER_ADJUSTMENT, elementPosition, false));
+ Adjustment.LINE_NUMBER_ADJUSTMENT, elementPosition, false));
list.add(new KnuthBox(0, elementPosition, false));
}
@@ -1104,7 +1104,7 @@
list.add(new KnuthBox(1 * constantLineHeight, elementPosition, false));
list.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, elementPosition, false));
list.add(new KnuthGlue(0, 0, 1 * constantLineHeight,
- LINE_NUMBER_ADJUSTMENT, elementPosition, false));
+ Adjustment.LINE_NUMBER_ADJUSTMENT, elementPosition, false));
list.add(new KnuthBox(0, elementPosition, false));
}
@@ -1200,7 +1200,7 @@
llPoss = (LineLayoutPossibilities)lineLayoutsList.get(p);
//log.debug("demerits of the chosen layout: " + llPoss.getChosenDemerits());
for (int i = 0; i < llPoss.getChosenLineCount(); i++) {
- if (!((BlockLevelLayoutManager) parentLM).mustKeepTogether()
+ if (!((BlockLevelLayoutManager) parentLayoutManager).mustKeepTogether()
&& i >= fobj.getOrphans()
&& i <= llPoss.getChosenLineCount() - fobj.getWidows()) {
// null penalty allowing a page break between lines
@@ -1213,21 +1213,19 @@
//log.debug("linewidth= " + lbp.lineWidth + " difference= " + lbp.difference + " indent= " + lbp.startIndent);
MinOptMax contentIPD;
if (alignment == EN_JUSTIFY) {
- contentIPD = new MinOptMax(
+ contentIPD = MinOptMax.getInstance(
lbp.lineWidth - lbp.difference - lbp.availableShrink,
lbp.lineWidth - lbp.difference,
lbp.lineWidth - lbp.difference + lbp.availableStretch);
} else if (alignment == EN_CENTER) {
- contentIPD = new MinOptMax(lbp.lineWidth - 2 * lbp.startIndent);
+ contentIPD = MinOptMax.getInstance(lbp.lineWidth - 2 * lbp.startIndent);
} else if (alignment == EN_END) {
- contentIPD = new MinOptMax(lbp.lineWidth - lbp.startIndent);
+ contentIPD = MinOptMax.getInstance(lbp.lineWidth - lbp.startIndent);
} else {
- contentIPD = new MinOptMax(lbp.lineWidth - lbp.difference + lbp.startIndent);
+ contentIPD = MinOptMax.getInstance(lbp.lineWidth - lbp.difference + lbp.startIndent);
}
- returnList.add(new KnuthBlockBox(lbp.lineHeight,
- contentIPD,
- (lbp.ipdAdjust != 0
- ? lbp.lineWidth - lbp.difference : 0),
+ returnList.add(new KnuthBlockBox(lbp.lineHeight, contentIPD, (lbp.ipdAdjust != 0
+ ? lbp.lineWidth - lbp.difference : 0),
lbp, false));
}
}
@@ -1277,7 +1275,7 @@
boxCount = 1;
auxCount = 0;
sbChars = new StringBuffer();
- currLM.getWordChars(sbChars, firstElement.getPosition());
+ sbChars.append(currLM.getWordChars(firstElement.getPosition()));
// look if next elements are boxes too
while (currParIterator.hasNext()) {
nextElement = (KnuthElement) currParIterator.next();
@@ -1289,7 +1287,7 @@
}
// append text to recreate the whole word
boxCount++;
- currLM.getWordChars(sbChars, nextElement.getPosition());
+ sbChars.append(currLM.getWordChars(nextElement.getPosition()));
} else if (!nextElement.isAuxiliary()) {
// a non-auxiliary non-box KnuthElement: stop
// go back to the last box or auxiliary element
@@ -1583,7 +1581,7 @@
lineArea.setBPD(lineArea.getBPD() + context.getSpaceAfter());
}
lineArea.finalise();
- parentLM.addChildArea(lineArea);
+ parentLayoutManager.addChildArea(lineArea);
}
/**
@@ -1633,7 +1631,7 @@
blocklc.setTrailingSpace(new SpaceSpecifier(false));
}
lineArea.updateExtentsFromChildren();
- parentLM.addChildArea(lineArea);
+ parentLayoutManager.addChildArea(lineArea);
}
/**
@@ -1644,9 +1642,8 @@
if (childArea instanceof InlineArea) {
Area parent = getCurrentArea();
if (getContext().resolveLeadingSpace()) {
- addSpace(parent,
- getContext().getLeadingSpace().resolve(false),
- getContext().getSpaceAdjust());
+ addSpace(parent, getContext().getLeadingSpace().resolve(false),
+ getContext().getSpaceAdjust());
}
parent.addChildArea(childArea);
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -46,7 +46,7 @@
/** {@inheritDoc} */
public InlineArea get(LayoutContext context) {
- curArea = getPageNumberCitationLastInlineArea(parentLM);
+ curArea = getPageNumberCitationLastInlineArea(parentLayoutManager);
return curArea;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java?rev=893238&r1=893237&r2=893238&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java Tue Dec 22 17:20:51 2009
@@ -116,7 +116,7 @@
// update the ipd of the area
area.handleIPDVariation(getStringWidth(area.getText()) - area.getIPD());
// update the width stored in the AreaInfo object
- areaInfo.ipdArea = new MinOptMax(area.getIPD());
+ areaInfo.ipdArea = MinOptMax.getInstance(area.getIPD());
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org