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 gm...@apache.org on 2004/03/17 04:37:32 UTC
cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr TextLayoutManager.java
gmazza 2004/03/16 19:37:32
Modified: src/java/org/apache/fop/layoutmgr TextLayoutManager.java
Log:
minor simplifications; removed redundant variables.
Revision Changes Path
1.12 +37 -41 xml-fop/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java
Index: TextLayoutManager.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- TextLayoutManager.java 12 Mar 2004 00:41:04 -0000 1.11
+++ TextLayoutManager.java 17 Mar 2004 03:37:32 -0000 1.12
@@ -21,7 +21,6 @@
import java.util.ArrayList;
import org.apache.fop.fo.FOText;
-import org.apache.fop.fo.TextInfo;
import org.apache.fop.traits.SpaceVal;
import org.apache.fop.area.Trait;
import org.apache.fop.area.inline.InlineArea;
@@ -63,9 +62,8 @@
/** Non-space characters on which we can end a line. */
private static final String BREAK_CHARS = "-/" ;
+ private FOText foText;
private char[] textArray;
- private int textArrayLength;
- private TextInfo textInfo;
private static final char NEWLINE = '\n';
private static final char SPACE = '\u0020'; // Normal space
@@ -95,25 +93,23 @@
/**
* Create a Text layout manager.
*
- * @param chars character array
- * @param length length of the above array to be processed
- * @param textInfo the text information for doing layout
+ * @param node The FOText object to be rendered
*/
public TextLayoutManager(FOText node) {
super(node);
- this.textArray = new char[node.ca.length - node.start];
- System.arraycopy(node.ca, node.start, this.textArray, 0,
+ foText = node;
+ textArray = new char[node.ca.length - node.start];
+ System.arraycopy(node.ca, node.start, textArray, 0,
node.ca.length - node.start);
- this.textArrayLength = node.ca.length - node.start;
- this.textInfo = node.textInfo;
- this.vecAreaInfo = new java.util.ArrayList();
+
+ vecAreaInfo = new java.util.ArrayList();
// With CID fonts, space isn't neccesary currentFontState.width(32)
- spaceCharIPD = textInfo.fs.getCharWidth(' ');
+ spaceCharIPD = foText.textInfo.fs.getCharWidth(' ');
// Use hyphenationChar property
- hyphIPD = textInfo.fs.getCharWidth('-');
+ hyphIPD = foText.textInfo.fs.getCharWidth('-');
// Make half-space: <space> on either side of a word-space)
- SpaceVal ws = textInfo.wordSpacing;
+ SpaceVal ws = foText.textInfo.wordSpacing;
halfWS = new SpaceVal(MinOptMax.multiply(ws.getSpace(), 0.5),
ws.isConditional(), ws.isForcing(), ws.getPrecedence());
}
@@ -161,7 +157,7 @@
*/
public boolean canBreakBefore(LayoutContext context) {
char c = textArray[iNextStart];
- return ((c == NEWLINE) || (textInfo.bWrap
+ return ((c == NEWLINE) || (foText.textInfo.bWrap
&& (CharUtilities.isBreakableSpace(c)
|| (BREAK_CHARS.indexOf(c) >= 0 && (iNextStart == 0
|| Character.isLetterOrDigit(textArray[iNextStart-1]))))));
@@ -205,15 +201,15 @@
boolean bCanHyphenate = true;
int iStopIndex = iNextStart + hc.getNextHyphPoint();
- if (textArrayLength < iStopIndex || textInfo.bCanHyphenate == false) {
- iStopIndex = textArrayLength;
+ if (textArray.length < iStopIndex || foText.textInfo.bCanHyphenate == false) {
+ iStopIndex = textArray.length;
bCanHyphenate = false;
}
hc.updateOffset(iStopIndex - iNextStart);
for (; iNextStart < iStopIndex; iNextStart++) {
char c = textArray[iNextStart];
- hyphIPD.opt += textInfo.fs.getCharWidth(c);
+ hyphIPD.opt += foText.textInfo.fs.getCharWidth(c);
// letter-space?
}
// Need to include hyphen size too, but don't count it in the
@@ -261,11 +257,11 @@
* retained.
*/
if (context.suppressLeadingSpace()) {
- for (; iNextStart < textArrayLength
+ for (; iNextStart < textArray.length
&& textArray[iNextStart] == SPACE; iNextStart++) {
}
// If now at end, nothing to compose here!
- if (iNextStart >= textArrayLength) {
+ if (iNextStart >= textArray.length) {
setFinished(true);
return null; // Or an "empty" BreakPoss?
}
@@ -286,7 +282,7 @@
short iWScount = 0; // Count of word spaces
boolean bSawNonSuppressible = false;
- for (; iNextStart < textArrayLength; iNextStart++) {
+ for (; iNextStart < textArray.length; iNextStart++) {
char c = textArray[iNextStart];
if (CharUtilities.isAnySpace(c) == false) {
break;
@@ -320,11 +316,11 @@
bSawNonSuppressible = true;
spaceIPD.add(pendingSpace.resolve(false));
pendingSpace.clear();
- wordIPD += textInfo.fs.getCharWidth(c);
+ wordIPD += foText.textInfo.fs.getCharWidth(c);
}
}
- if (iNextStart < textArrayLength) {
+ if (iNextStart < textArray.length) {
spaceIPD.add(pendingSpace.resolve(false));
} else {
// This FO ended with spaces. Return the BP
@@ -347,10 +343,10 @@
// Look for a legal line-break: breakable white-space and certain
// characters such as '-' which can serve as word breaks.
// Don't look for hyphenation points here though
- for (; iNextStart < textArrayLength; iNextStart++) {
+ for (; iNextStart < textArray.length; iNextStart++) {
char c = textArray[iNextStart];
// Include any breakable white-space as break char
- if ((c == NEWLINE) || (textInfo.bWrap
+ if ((c == NEWLINE) || (foText.textInfo.bWrap
&& (CharUtilities.isBreakableSpace(c)
|| (BREAK_CHARS.indexOf(c) >= 0 && (iNextStart == 0
|| Character.isLetterOrDigit(textArray[iNextStart-1])))))) {
@@ -358,7 +354,7 @@
if (c != SPACE) {
iNextStart++;
if (c != NEWLINE) {
- wordIPD += textInfo.fs.getCharWidth(c);
+ wordIPD += foText.textInfo.fs.getCharWidth(c);
} else {
iFlags |= BreakPoss.FORCE;
}
@@ -367,18 +363,18 @@
// line-end, set a flag for parent LM.
int iLastChar;
for (iLastChar = iNextStart;
- iLastChar < textArrayLength
+ iLastChar < textArray.length
&& textArray[iLastChar] == SPACE; iLastChar++) {
//nop
}
- if (iLastChar == textArrayLength) {
+ if (iLastChar == textArray.length) {
iFlags |= BreakPoss.REST_ARE_SUPPRESS_AT_LB;
}
return makeBreakPoss(iThisStart, spaceIPD, wordIPD,
context.getLeadingSpace(), null, iFlags,
iWScount);
}
- wordIPD += textInfo.fs.getCharWidth(c);
+ wordIPD += foText.textInfo.fs.getCharWidth(c);
// Note, if a normal non-breaking space, is it stretchable???
// If so, keep a count of these embedded spaces.
}
@@ -412,15 +408,15 @@
bp.setStackingSize(ipd);
}
// TODO: make this correct (see Keiron's vertical alignment code)
- bp.setNonStackingSize(new MinOptMax(textInfo.lineHeight));
+ bp.setNonStackingSize(new MinOptMax(foText.textInfo.lineHeight));
/* Set max ascender and descender (offset from baseline),
* used for calculating the bpd of the line area containing
* this text.
*/
- //bp.setDescender(textInfo.fs.getDescender());
- //bp.setAscender(textInfo.fs.getAscender());
- if (iNextStart == textArrayLength) {
+ //bp.setDescender(foText.textInfo.fs.getDescender());
+ //bp.setAscender(foText.textInfo.fs.getAscender());
+ if (iNextStart == textArray.length) {
flags |= BreakPoss.ISLAST;
setFinished(true);
}
@@ -518,12 +514,12 @@
// Set LAST flag if done making characters
int iLastChar;
for (iLastChar = ai.iBreakIndex;
- iLastChar < textArrayLength && textArray[iLastChar] == SPACE;
+ iLastChar < textArray.length && textArray[iLastChar] == SPACE;
iLastChar++) {
//nop
}
context.setFlags(LayoutContext.LAST_AREA,
- iLastChar == textArrayLength);
+ iLastChar == textArray.length);
// Can we have any trailing space? Yes, if last char was a space!
context.setTrailingSpace(new SpaceSpecifier(false));
@@ -548,16 +544,16 @@
protected TextArea createTextArea(String str, int width, int base) {
TextArea textArea = new TextArea();
textArea.setWidth(width);
- textArea.setHeight(textInfo.fs.getAscender()
- - textInfo.fs.getDescender());
- textArea.setOffset(textInfo.fs.getAscender());
+ textArea.setHeight(foText.textInfo.fs.getAscender()
+ - foText.textInfo.fs.getDescender());
+ textArea.setOffset(foText.textInfo.fs.getAscender());
textArea.setOffset(base);
textArea.setTextArea(str);
- textArea.addTrait(Trait.FONT_NAME, textInfo.fs.getFontName());
+ textArea.addTrait(Trait.FONT_NAME, foText.textInfo.fs.getFontName());
textArea.addTrait(Trait.FONT_SIZE,
- new Integer(textInfo.fs.getFontSize()));
- textArea.addTrait(Trait.COLOR, this.textInfo.color);
+ new Integer(foText.textInfo.fs.getFontSize()));
+ textArea.addTrait(Trait.COLOR, foText.textInfo.color);
return textArea;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org