[FOray-commit] SF.net SVN: foray: [7929] trunk/foray/foray-text/src/java/org/foray/text/ line
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2006-09-06 00:28:23
|
Revision: 7929
http://svn.sourceforge.net/foray/?rev=7929&view=rev
Author: victormote
Date: 2006-09-05 17:28:17 -0700 (Tue, 05 Sep 2006)
Log Message:
-----------
Use "this" modifier for all instance or class variables.
Modified Paths:
--------------
trunk/foray/foray-text/src/java/org/foray/text/line/LineBreaker.java
trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java
Modified: trunk/foray/foray-text/src/java/org/foray/text/line/LineBreaker.java
===================================================================
--- trunk/foray/foray-text/src/java/org/foray/text/line/LineBreaker.java 2006-09-06 00:13:44 UTC (rev 7928)
+++ trunk/foray/foray-text/src/java/org/foray/text/line/LineBreaker.java 2006-09-06 00:28:17 UTC (rev 7929)
@@ -88,7 +88,8 @@
* application is responsible to provide these values, but they are stored
* here for reference.
*/
- protected LineOutput[] outputLines = new LineOutput[LINE_COUNT_INCREMENT];
+ protected LineOutput[] outputLines
+ = new LineOutput[LineBreaker.LINE_COUNT_INCREMENT];
/**
* Index into {@link #outputLines} indicating which one was last requested
@@ -130,12 +131,12 @@
*/
public void addLineContent(final LineContent contentItem)
throws TextException {
- if (eagerMode) {
+ if (this.eagerMode) {
throw new TextException("Line-Breaking running in \"eager\" mode"
+ "can't switch to \"patient\".");
}
- patientMode = true;
- content.add(contentItem);
+ this.patientMode = true;
+ this.content.add(contentItem);
}
/**
@@ -158,7 +159,7 @@
final int start, final int end, final LineOutput output)
throws TextException {
validateEagerContent(contentItem, output);
- content.add(contentItem);
+ this.content.add(contentItem);
this.currentOutput = output;
this.currentLineContent = contentItem;
return addLineContent(contentItem, start, end, output);
@@ -171,7 +172,7 @@
*/
private void validateEagerContent(final LineContent contentItem,
final LineOutput output) throws TextException {
- if (patientMode) {
+ if (this.patientMode) {
throw new TextException("Line-Breaking running in \"patient\" mode"
+ "can't switch to \"eager\".");
}
@@ -181,7 +182,7 @@
if (output == null) {
throw new TextException("Null LineOutput.");
}
- eagerMode = true;
+ this.eagerMode = true;
}
protected abstract int addLineContent(LineContent contentItem, int start,
@@ -366,17 +367,18 @@
this.lineReceivingContent ++;
}
updateLineLengths();
- return this.outputLines[lineReceivingContent];
+ return this.outputLines[this.lineReceivingContent];
}
private void updateLineLengths() throws TextException {
- if (eagerMode) {
+ if (this.eagerMode) {
return;
}
- while (lineReceivingContent > this.lastLineRequested) {
+ while (this.lineReceivingContent > this.lastLineRequested) {
this.lastLineRequested ++;
checkArraySize();
- this.outputLines[lineReceivingContent] = this.control.getNextLine();
+ this.outputLines[this.lineReceivingContent]
+ = this.control.getNextLine();
}
}
@@ -389,7 +391,8 @@
return;
}
// Make a new array.
- final int newSize = this.outputLines.length + LINE_COUNT_INCREMENT;
+ final int newSize = this.outputLines.length
+ + LineBreaker.LINE_COUNT_INCREMENT;
final LineOutput[] newArray = new LineOutput[newSize];
// Copy the old to the new.
System.arraycopy(this.outputLines, 0, newArray, 0,
Modified: trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java
===================================================================
--- trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2006-09-06 00:13:44 UTC (rev 7928)
+++ trunk/foray/foray-text/src/java/org/foray/text/line/solitary/SolitaryLineBreaker.java 2006-09-06 00:28:17 UTC (rev 7929)
@@ -73,7 +73,7 @@
* One of {@link #NOTHING}, {@link #CONNECTOR}, or {@link #TEXT},
* indicating the class of the previous character.
*/
- private byte previousCharacter = NOTHING;
+ private byte previousCharacter = SolitaryLineBreaker.NOTHING;
/**
* The accumulated width, in millipoints, of whitespace before the current
@@ -107,17 +107,17 @@
protected int processLineText(final LineText lineText, final int start,
final int end) throws TextException {
this.currentLineText = lineText;
- this.currentChars = currentLineText.inlineText();
+ this.currentChars = this.currentLineText.inlineText();
final String language = lineText.inlineLanguage();
- finalWidth = 0;
- wordWidth = 0;
- wordStart = 0;
- spaceWidth = 0;
+ this.finalWidth = 0;
+ this.wordWidth = 0;
+ this.wordStart = 0;
+ this.spaceWidth = 0;
if (this.currentOutput.hasAnyContent()) {
- canEatLeadingSpaces = false;
+ this.canEatLeadingSpaces = false;
} else {
- canEatLeadingSpaces = true;
+ this.canEatLeadingSpaces = true;
}
final int whitespaceWidth = getCharWidth(lineText, ' ');
@@ -144,7 +144,7 @@
charCount++;
}
if (forcesLineBreak(codePoint)) {
- createLineContent(start, i, finalWidth, false);
+ createLineContent(start, i, this.finalWidth, false);
return i + 1;
}
if (allowsLineBreak(codePoint)) {
@@ -153,12 +153,12 @@
}
// If it got this far, it is TEXT.
- canEatLeadingSpaces = false;
+ this.canEatLeadingSpaces = false;
final int charWidth = charWidth(lineText, codePoint,
whitespaceWidth);
processTextChar(language, thisCharStarts, charWidth);
- if ((finalWidth + spaceWidth + wordWidth)
+ if ((this.finalWidth + this.spaceWidth + this.wordWidth)
<= currentLineWidthRemaining()) {
// Content fits on the current line. We are done with this char.
continue;
@@ -170,37 +170,39 @@
}
if (lineText.inlineHyphenate()) {
final int ret = tryHyphenation();
- if (ret != wordStart) {
- finalWidth += spaceWidth;
- finalWidth += wordWidth;
- finalWidth += getHyphenWidth(lineText);
- createLineContent(start, ret - 1, finalWidth, true);
+ if (ret != this.wordStart) {
+ this.finalWidth += this.spaceWidth;
+ this.finalWidth += this.wordWidth;
+ this.finalWidth += getHyphenWidth(lineText);
+ createLineContent(start, ret - 1, this.finalWidth, true);
return ret;
}
}
- if (wordStart == start && ! this.currentOutput.hasAnyContent()) {
+ if (this.wordStart == start
+ && ! this.currentOutput.hasAnyContent()) {
// This is the first word on this line.
overflowMessage();
- finalWidth += spaceWidth;
- finalWidth += wordWidth;
- finalWidth -= charWidth;
- createLineContent(start, i - charCount, finalWidth, false);
+ this.finalWidth += this.spaceWidth;
+ this.finalWidth += this.wordWidth;
+ this.finalWidth -= charWidth;
+ createLineContent(start, i - charCount, this.finalWidth, false);
/* Return the index at the start of this character*/
return i - charCount + 1;
}
// Break the line at the end of the previous word.
- createLineContent(start, wordStart - 1, finalWidth, false);
- return wordStart;
+ createLineContent(start, this.wordStart - 1, this.finalWidth,
+ false);
+ return this.wordStart;
}
/* We have now read through each character. */
/* If this ends with white space, place remaining contents on this
* line. */
- if (previousCharacter == CONNECTOR) {
+ if (this.previousCharacter == SolitaryLineBreaker.CONNECTOR) {
return remainingContentOnThisLine(startIndex, endIndex);
}
/* Otherwise the word may continue into the next text. See if the
* entire word fits. */
- if (finalWidth + spaceWidth + wordWidth
+ if (this.finalWidth + this.spaceWidth + this.wordWidth
+ sizeFirstWordNextText(lineText, startIndex, endIndex)
<= currentLineWidthRemaining()) {
return remainingContentOnThisLine(startIndex, endIndex);
@@ -211,8 +213,8 @@
/* If nothing else works, the content doesn't fit on this line.
* Break the line at the end of the previous word. */
- createLineContent(start, wordStart - 1, finalWidth, false);
- return wordStart;
+ createLineContent(start, this.wordStart - 1, this.finalWidth, false);
+ return this.wordStart;
}
/**
@@ -224,9 +226,9 @@
*/
private int remainingContentOnThisLine(final int startIndex,
final int endIndex) throws TextException {
- finalWidth += spaceWidth;
- finalWidth += wordWidth;
- createLineContent(startIndex, endIndex, finalWidth, false);
+ this.finalWidth += this.spaceWidth;
+ this.finalWidth += this.wordWidth;
+ createLineContent(startIndex, endIndex, this.finalWidth, false);
return endIndex + 1;
}
@@ -269,29 +271,29 @@
*/
private void processTextChar(final String language, final int i,
final int charWidth) {
- if (previousCharacter == CONNECTOR) {
+ if (this.previousCharacter == SolitaryLineBreaker.CONNECTOR) {
// Current is TEXT, previous is WHITESPACE.
- wordWidth = charWidth;
- wordStart = i;
- } else if (previousCharacter == TEXT) {
+ this.wordWidth = charWidth;
+ this.wordStart = i;
+ } else if (this.previousCharacter == SolitaryLineBreaker.TEXT) {
if (canBreakMidWord(language)) {
- finalWidth += spaceWidth;
- spaceWidth = 0;
+ this.finalWidth += this.spaceWidth;
+ this.spaceWidth = 0;
// add the current word
- if (i > wordStart) {
- finalWidth += wordWidth;
+ if (i > this.wordStart) {
+ this.finalWidth += this.wordWidth;
}
- spaceWidth = 0;
- wordStart = i;
- wordWidth = charWidth;
+ this.spaceWidth = 0;
+ this.wordStart = i;
+ this.wordWidth = charWidth;
} else {
- wordWidth += charWidth;
+ this.wordWidth += charWidth;
}
} else { // nothing previous
- wordStart = i;
- wordWidth = charWidth;
+ this.wordStart = i;
+ this.wordWidth = charWidth;
}
- previousCharacter = TEXT;
+ this.previousCharacter = SolitaryLineBreaker.TEXT;
}
/**
@@ -303,24 +305,24 @@
*/
private void processLineBreakPossibility(final LineText lineText,
final int codePoint) {
- if (previousCharacter == TEXT) {
+ if (this.previousCharacter == SolitaryLineBreaker.TEXT) {
// Current is WHITESPACE and previous TEXT.
/*
* The current word made it, so add any accumulated space
* before the current word.
*/
- finalWidth += spaceWidth;
+ this.finalWidth += this.spaceWidth;
// Reset space width.
- spaceWidth = 0;
+ this.spaceWidth = 0;
// Add the current word.
- finalWidth += wordWidth;
+ this.finalWidth += this.wordWidth;
// Reset word width.
- wordWidth = 0;
+ this.wordWidth = 0;
}
- if (! canEatLeadingSpaces) {
- spaceWidth += getCharWidth(lineText, codePoint);
+ if (! this.canEatLeadingSpaces) {
+ this.spaceWidth += getCharWidth(lineText, codePoint);
}
- previousCharacter = CONNECTOR;
+ this.previousCharacter = SolitaryLineBreaker.CONNECTOR;
}
/**
@@ -365,11 +367,11 @@
final String country = this.currentLineText.inlineCountry();
// Count the number of chars at the beginning that should be ignored.
final int actualWordStart = server.wordStarts(this.currentChars,
- wordStart, language, country);
+ this.wordStart, language, country);
if (actualWordStart < 0) {
return this.wordStart;
}
- final int nonWordChars = actualWordStart - wordStart;
+ final int nonWordChars = actualWordStart - this.wordStart;
// Extract the word that should be evaluated by the hyphenation system.
final int wordSize = server.wordSize(this.currentChars, actualWordStart,
language, country);
@@ -390,12 +392,12 @@
this.currentLineText, wordToHyphenate, hyph);
// If none fit, then the word cannot be hyphenated.
if (index < 0) {
- return wordStart;
+ return this.wordStart;
}
// Compute the number of characters that should be included.
final int charsToInclude = hyph.getPoints()[index];
// Add it and the non-word characters to the count to be returned.
- return wordStart + nonWordChars + charsToInclude;
+ return this.wordStart + nonWordChars + charsToInclude;
}
/**
@@ -403,8 +405,9 @@
*/
private int selectDiscretionaryHyphenationPoint(final LineText lineText,
final String word, final Hyphenation hyph) throws TextException {
- final int remainingWidth = this.currentLineWidthRemaining() - finalWidth
- - spaceWidth - getHyphenWidth(this.currentLineText);
+ final int remainingWidth = this.currentLineWidthRemaining()
+ - this.finalWidth
+ - this.spaceWidth - getHyphenWidth(this.currentLineText);
final int[] hyphenationPoints = hyph.getPoints();
final byte[] hyphenationWeights = hyph.getWeights();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|