[FOray-commit] SF.net SVN: foray: [8270] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2006-10-03 01:54:26
|
Revision: 8270
http://svn.sourceforge.net/foray/?rev=8270&view=rev
Author: victormote
Date: 2006-10-02 18:54:03 -0700 (Mon, 02 Oct 2006)
Log Message:
-----------
Modify a copy of the parameter, instead of the parameter itself.
Modified Paths:
--------------
trunk/foray/foray-ps/src/java/org/foray/ps/PSInteger.java
trunk/foray/foray-ps/src/java/org/foray/ps/PSInterpreter.java
trunk/foray/foray-ps/src/java/org/foray/ps/PSReal.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
trunk/foray/foray-ps/src/java/org/foray/ps/filter/ASCII85Filter.java
trunk/foray/foray-ps/src/java/org/foray/ps/filter/EncryptFilter.java
trunk/foray/foray-render/src/java/org/foray/render/awt/viewer/UserMessage.java
trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/ps/ASCII85OutputStream.java
trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java
trunk/foray/foray-text/src/java/org/foray/text/line/LineBreaker.java
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PSInteger.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/PSInteger.java 2006-10-02 23:57:40 UTC (rev 8269)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/PSInteger.java 2006-10-03 01:54:03 UTC (rev 8270)
@@ -203,24 +203,26 @@
* @return The base-10 integral value of this digit in this base, or a -1
* if the digit is not valid in this base.
*/
- private static byte getPlaceValue(final byte base, byte input) {
+ private static byte getPlaceValue(final byte base, final byte input) {
+ byte modifiedInput = input;
// Normalize the letters to be all caps
- if (input >= 'a' && input <= 'z') {
- input -= ' ';
+ if (modifiedInput >= 'a' && modifiedInput <= 'z') {
+ modifiedInput -= ' ';
}
byte placeValue = -1;
/*
* If it is an alphabetic character subtract an extra 7 for the ASCII
* characters between 9 and A.
*/
- if (input >= 'A' && input <= 'Z') {
- placeValue = (byte) (input - 'A' + WKConstants.RADIX_BASE_10);
+ if (modifiedInput >= 'A' && modifiedInput <= 'Z') {
+ placeValue = (byte) (modifiedInput - 'A'
+ + WKConstants.RADIX_BASE_10);
/*
* If a numeral, just subtract the 0x30 that is the difference between
* an ASCII 0 and a integer 0.
*/
- } else if (input >= '0' && input <= '9') {
- placeValue = (byte) (input - '0');
+ } else if (modifiedInput >= '0' && modifiedInput <= '9') {
+ placeValue = (byte) (modifiedInput - '0');
}
// If placeValue is not a valid number in this base, bail out
if (placeValue >= base) {
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PSInterpreter.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/PSInterpreter.java 2006-10-02 23:57:40 UTC (rev 8269)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/PSInterpreter.java 2006-10-03 01:54:03 UTC (rev 8270)
@@ -242,7 +242,7 @@
* @throws PSException For invalid parameters.
*/
public PSInterpreter(final Log logger, final PSInput input,
- PSSystemDict systemDict) throws PSException {
+ final PSSystemDict systemDict) throws PSException {
if (input == null) {
logger.error("PostScript Error: No standard input.");
return;
@@ -253,32 +253,33 @@
// Place it on the execution stack.
this.executionStack.push(this.standardInput);
// Get the System Dictionary.
- if (systemDict == null) {
- systemDict = new ReadOnlySystemDict(this);
+ PSSystemDict systemDictToUse = systemDict;
+ if (systemDictToUse == null) {
+ systemDictToUse = new ReadOnlySystemDict(this);
}
// Register this as the parent of the System Dictionary
- systemDict.setPSInterpreter(this);
+ systemDictToUse.setPSInterpreter(this);
// Add the Standard Encoding to the System Dictionary.
PSName name = new PSName(this, "StandardEncoding", false, false);
EncodingVector encoding = EncodingVector.getPredefinedEncoding(
name.getValue());
PSArray array = new PSArray(this, encoding.getGlyphList(),
false);
- systemDict.addItem(name, array);
+ systemDictToUse.addItem(name, array);
// Add the ISO Latin 1 Encoding to the System Dictionary.
name = new PSName(this, "ISOLatin1Encoding", false, false);
encoding = EncodingVector.getPredefinedEncoding(name.getValue());
array = new PSArray(this, encoding.getGlyphList(), false);
- systemDict.addItem(name, array);
+ systemDictToUse.addItem(name, array);
// Add the System Dictionary to the dictionary stack.
- this.dictionaryStack.push(systemDict);
+ this.dictionaryStack.push(systemDictToUse);
/*
* Add "systemdict" as an entry in itself. See PLRM2, Section 8.2,
* "systemdict" entry. It is not an operator, but is an element in the
* systemdict dictionary.
*/
name = new PSName(this, "systemdict", false, false);
- systemDict.addItem(name, systemDict);
+ systemDictToUse.addItem(name, systemDictToUse);
// Create a Global Dictionary & push it on the dictionary Stack.
PSDictionary newDict = new PSDictionary(this, 0);
this.dictionaryStack.push(newDict);
@@ -288,7 +289,7 @@
* systemdict dictionary.
*/
name = new PSName(this, "globaldict", false, false);
- systemDict.addItem(name, newDict);
+ systemDictToUse.addItem(name, newDict);
// Create a User Dictionary & push it on the dictionary Stack.
newDict = new PSDictionary(this, 0);
this.dictionaryStack.push(newDict);
@@ -298,7 +299,7 @@
* systemdict dictionary.
*/
name = new PSName(this, "userdict", false, false);
- systemDict.addItem(name, newDict);
+ systemDictToUse.addItem(name, newDict);
/*
* Create an "internaldict".
* The need for this is inferred from the internaldict operator
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PSReal.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/PSReal.java 2006-10-02 23:57:40 UTC (rev 8269)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/PSReal.java 2006-10-03 01:54:03 UTC (rev 8270)
@@ -207,20 +207,21 @@
* @param doubleValue The double primitive to format.
* @return The double primitive as PostScript output.
*/
- public static String doubleOut(double doubleValue) {
+ public static String doubleOut(final double doubleValue) {
final StringBuffer p = new StringBuffer();
- if (doubleValue < 0) {
- doubleValue = -doubleValue;
+ double modifiedDoubleValue = doubleValue;
+ if (modifiedDoubleValue < 0) {
+ modifiedDoubleValue = -modifiedDoubleValue;
p.append("-");
}
- final double trouble = doubleValue % 1;
+ final double trouble = modifiedDoubleValue % 1;
if (trouble > 0.950) {
- p.append((int) doubleValue + 1);
+ p.append((int) modifiedDoubleValue + 1);
} else if (trouble < 0.050) {
- p.append((int) doubleValue);
+ p.append((int) modifiedDoubleValue);
} else {
- final String doubleString = Double.toString(doubleValue);
+ final String doubleString = Double.toString(modifiedDoubleValue);
final int decimal = doubleString.indexOf(".");
if (decimal != -1) {
p.append(doubleString.substring(0, decimal));
@@ -245,20 +246,21 @@
* the value should be 8.
* @return The double primitive as PostScript output.
*/
- public static String doubleOut(double doubleValue, final int radix) {
+ public static String doubleOut(final double doubleValue, final int radix) {
final StringBuffer p = new StringBuffer();
- if (doubleValue < 0) {
- doubleValue = -doubleValue;
+ double modifiedDoubleValue = doubleValue;
+ if (modifiedDoubleValue < 0) {
+ modifiedDoubleValue = -modifiedDoubleValue;
p.append("-");
}
- final double trouble = doubleValue % 1;
+ final double trouble = modifiedDoubleValue % 1;
if (trouble > (1.0 - (5.0 / (Math.pow(10.0, radix))))) {
- p.append((int) doubleValue + 1);
+ p.append((int) modifiedDoubleValue + 1);
} else if (trouble < (5.0 / (Math.pow(10.0, radix)))) {
- p.append((int) doubleValue);
+ p.append((int) modifiedDoubleValue);
} else {
- final String doubleString = Double.toString(doubleValue);
+ final String doubleString = Double.toString(modifiedDoubleValue);
final int decimal = doubleString.indexOf(".");
if (decimal != -1) {
p.append(doubleString.substring(0, decimal));
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2006-10-02 23:57:40 UTC (rev 8269)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingParser.java 2006-10-03 01:54:03 UTC (rev 8270)
@@ -462,17 +462,18 @@
* @param minimumPad The minimum padding size that should be added.
* @return The padded String.
*/
- public static String padSpaces(String string, final int desiredColumn,
+ public static String padSpaces(final String string, final int desiredColumn,
final int minimumPad) {
/* The String length + 1 is the next column that will be written if
* no padding is added. */
int spacesToPad = desiredColumn - (string.length() + 1);
spacesToPad = Math.max(spacesToPad, minimumPad);
+ String modifiedString = string;
while (spacesToPad > 0) {
- string = string + " ";
+ modifiedString = modifiedString + " ";
spacesToPad--;
}
- return string;
+ return modifiedString;
}
/**
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/filter/ASCII85Filter.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/filter/ASCII85Filter.java 2006-10-02 23:57:40 UTC (rev 8269)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/filter/ASCII85Filter.java 2006-10-03 01:54:03 UTC (rev 8270)
@@ -139,28 +139,28 @@
* values of 0)
* @throws PSFilterException If an illegal character is found in the input.
*/
- private byte[] convertWord(long word) throws PSFilterException {
- word = word & 0xffffffff;
- if (word < 0) {
- word = -word;
+ private byte[] convertWord(final long word) throws PSFilterException {
+ long wordMasked = word & 0xffffffff;
+ if (wordMasked < 0) {
+ wordMasked = -wordMasked;
}
- if (word == 0) {
+ if (wordMasked == 0) {
final byte[] result = { (byte) ASCII85Filter.ASCII85_ZERO };
return result;
}
- final byte c5 = (byte) ((word % ASCII85Filter.BASE_85_4)
+ final byte c5 = (byte) ((wordMasked % ASCII85Filter.BASE_85_4)
+ ASCII85Filter.ASCII85_START);
- word = word / ASCII85Filter.BASE_85_4;
- final byte c4 = (byte) ((word % ASCII85Filter.BASE_85_4)
+ wordMasked = wordMasked / ASCII85Filter.BASE_85_4;
+ final byte c4 = (byte) ((wordMasked % ASCII85Filter.BASE_85_4)
+ ASCII85Filter.ASCII85_START);
- word = word / ASCII85Filter.BASE_85_4;
- final byte c3 = (byte) ((word % ASCII85Filter.BASE_85_4)
+ wordMasked = wordMasked / ASCII85Filter.BASE_85_4;
+ final byte c3 = (byte) ((wordMasked % ASCII85Filter.BASE_85_4)
+ ASCII85Filter.ASCII85_START);
- word = word / ASCII85Filter.BASE_85_4;
- final byte c2 = (byte) ((word % ASCII85Filter.BASE_85_4)
+ wordMasked = wordMasked / ASCII85Filter.BASE_85_4;
+ final byte c2 = (byte) ((wordMasked % ASCII85Filter.BASE_85_4)
+ ASCII85Filter.ASCII85_START);
- word = word / ASCII85Filter.BASE_85_4;
- final byte c1 = (byte) ((word % ASCII85Filter.BASE_85_4)
+ wordMasked = wordMasked / ASCII85Filter.BASE_85_4;
+ final byte c1 = (byte) ((wordMasked % ASCII85Filter.BASE_85_4)
+ ASCII85Filter.ASCII85_START);
final byte[] ret = { c1 , c2, c3, c4, c5 };
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/filter/EncryptFilter.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/filter/EncryptFilter.java 2006-10-02 23:57:40 UTC (rev 8269)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/filter/EncryptFilter.java 2006-10-03 01:54:03 UTC (rev 8270)
@@ -157,14 +157,12 @@
/**
* {@inheritDoc}
*/
- public byte[] decode(byte[] input) throws PSFilterException {
+ public byte[] decode(final byte[] input) throws PSFilterException {
if (! this.formatResolved) {
resolveFormat(input);
- /*
- * If the format is not yet resolved, it is because we don't have
- * all of the first 4 bytes are yet. Fill the input array with
- * spaces and return it.
- */
+ /* If the format is not yet resolved, it is because we don't have
+ * all of the first 4 bytes yet. Fill the input array with spaces
+ * and return it. */
if (! this.formatResolved) {
for (int i = 0; i < input.length; i++) {
input[i] = ' ';
@@ -172,16 +170,17 @@
return input;
}
}
+ byte[] output = input;
if (this.hexFormat) {
if (this.hexFilter == null) {
this.hexFilter = new ASCIIHexFilter();
}
- input = this.hexFilter.decode(input);
+ output = this.hexFilter.decode(input);
}
for (int i = 0; i < input.length; i++) {
- input[i] = decrypt(input[i]);
+ output[i] = decrypt(input[i]);
}
- return input;
+ return output;
}
/**
Modified: trunk/foray/foray-render/src/java/org/foray/render/awt/viewer/UserMessage.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/awt/viewer/UserMessage.java 2006-10-02 23:57:40 UTC (rev 8269)
+++ trunk/foray/foray-render/src/java/org/foray/render/awt/viewer/UserMessage.java 2006-10-03 01:54:03 UTC (rev 8270)
@@ -132,7 +132,7 @@
/**
* Ersetzt die eventuellen Platzhalter durch die übergebenen Parameter
*/
- String prepareMessage(String rawText, final String[] par) {
+ String prepareMessage(final String rawText, final String[] par) {
logger.info("prepareMessage(): " + rawText + ", parameter: "
+ par);
int index = rawText.indexOf(PARAMETER_TAG);
@@ -155,6 +155,7 @@
return rawText;
}
int tagCount = 0;
+ String modifiedText = rawText;
while (rawText.indexOf(PARAMETER_TAG) != -1) {
index = rawText.indexOf(PARAMETER_TAG);
try {
@@ -166,10 +167,10 @@
ex.printStackTrace();
return composedMess + rawText;
}
- rawText = rawText.substring(index + PARAMETER_TAG.length());
+ modifiedText = rawText.substring(index + PARAMETER_TAG.length());
tagCount++;
}
- composedMess += rawText;
+ composedMess += modifiedText;
if (tagCount != par.length) {
logger.info("Die zu der Meldung " + actMessId
+ " übergebenen Parameter sind mehr als die Meldung "
Modified: trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java 2006-10-02 23:57:40 UTC (rev 8269)
+++ trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java 2006-10-03 01:54:03 UTC (rev 8270)
@@ -162,24 +162,28 @@
/**
* {@inheritDoc}
*/
- protected void drawRectangle(final int x, final int y, int w, int h,
- final boolean stroke, final Color strokeColor,
+ protected void drawRectangle(final int x, final int y, final int w,
+ final int h, final boolean stroke, final Color strokeColor,
final boolean fill, final Color fillColor) {
- if ((h >= 0 && h < 720) || (h < 0 && h > -720) || w < 720) {
- if (w < 720) {
- w = 720;
+ int width = w;
+ int height = h;
+ if ((height >= 0 && height < 720)
+ || (height < 0 && height > -720)
+ || width < 720) {
+ if (width < 720) {
+ width = 720;
}
- if (h > 0 && h < 720) {
- h = 720;
- } else if (h < 0 && h > -720) {
- h = -720;
+ if (height > 0 && height < 720) {
+ height = 720;
+ } else if (height < 0 && height > -720) {
+ height = -720;
}
- addRect(x, y, w, h, strokeColor, strokeColor);
+ addRect(x, y, width, height, strokeColor, strokeColor);
} else {
- addRect(x, y, w, 720, strokeColor, strokeColor);
- addRect(x, y, 720, h, strokeColor, strokeColor);
- addRect(x + w - 720, y, 720, h, strokeColor, strokeColor);
- addRect(x, y - h + 720, w, 720, strokeColor, strokeColor);
+ addRect(x, y, width, 720, strokeColor, strokeColor);
+ addRect(x, y, 720, height, strokeColor, strokeColor);
+ addRect(x + width - 720, y, 720, height, strokeColor, strokeColor);
+ addRect(x, y - height + 720, width, 720, strokeColor, strokeColor);
}
}
@@ -193,15 +197,17 @@
* @param fill the fill color/gradient
* @param stroke the stroke color/gradient
*/
- protected void addRect(final int x, int y, final int w, int h,
+ protected void addRect(final int x, final int y, final int w, final int h,
final Color stroke, final Color fill) {
- if ((w == 0) || (h == 0)) {
+ int modifiedY = y;
+ int height = h;
+ if ((w == 0) || (height == 0)) {
return;
}
- if (h < 0) {
- h *= -1;
+ if (height < 0) {
+ height *= -1;
} else {
- y += h;
+ modifiedY += height;
}
final int lineshade = (int) (100 - ((0.3f * stroke.getRed()
@@ -218,19 +224,19 @@
}
currentStream.add("\033*v1O\033&a" + xpos + "h"
- + (pageHeight - (y / 100)) + "V" + "\033*c"
- + (w / 100) + "h" + (h / 100) + "V" + "\033*c"
+ + (pageHeight - (modifiedY / 100)) + "V" + "\033*c"
+ + (w / 100) + "h" + (height / 100) + "V" + "\033*c"
+ lineshade + "G" + "\033*c2P");
- if (fillshade != lineshade && (w >= 720 || h >= 720)) {
+ if (fillshade != lineshade && (w >= 720 || height >= 720)) {
xpos = xoffset + ((x + 240) / 100);
if (xpos < 0) {
xpos = 0;
getLogger().warn("Horizontal position out of bounds.");
}
currentStream.add("\033&a" + xpos + "h"
- + (pageHeight - ((y + 240)) / 100) + "V"
+ + (pageHeight - ((modifiedY + 240)) / 100) + "V"
+ "\033*c" + ((w - 480) / 100) + "h"
- + ((h - 480) / 100) + "V" + "\033*c"
+ + ((height - 480) / 100) + "V" + "\033*c"
+ fillshade + "G" + "\033*c2P");
}
// Reset pattern transparency mode.
Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/ASCII85OutputStream.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/ps/ASCII85OutputStream.java 2006-10-02 23:57:40 UTC (rev 8269)
+++ trunk/foray/foray-render/src/java/org/foray/render/ps/ASCII85OutputStream.java 2006-10-03 01:54:03 UTC (rev 8270)
@@ -140,31 +140,33 @@
* @return 5 bytes (or a single byte of the 'z' character for word
* values of 0)
*/
- private byte[] convertWord(long word) throws IOException {
- word = word & 0xffffffff;
+ private byte[] convertWord(final long word) throws IOException {
+ long maskedWord = word & 0xffffffff;
- if (word == 0) {
+ if (maskedWord == 0) {
return ASCII85OutputStream.ZERO_ARRAY;
}
- if (word < 0) {
- word = -word;
+ if (maskedWord < 0) {
+ maskedWord = -maskedWord;
}
- final byte c1 = (byte) ((word / ASCII85OutputStream.BASE_85_1) & 0xFF);
- final byte c2 = (byte) (((word - (c1 * ASCII85OutputStream.BASE_85_1))
+ final byte c1 = (byte) ((maskedWord / ASCII85OutputStream.BASE_85_1)
+ & 0xFF);
+ final byte c2 = (byte) (((maskedWord - (
+ c1 * ASCII85OutputStream.BASE_85_1))
/ ASCII85OutputStream.BASE_85_2) & 0xFF);
final byte c3 =
- (byte) (((word - (c1 * ASCII85OutputStream.BASE_85_1)
+ (byte) (((maskedWord - (c1 * ASCII85OutputStream.BASE_85_1)
- (c2 * ASCII85OutputStream.BASE_85_2))
/ ASCII85OutputStream.BASE_85_3)
& 0xFF);
final byte c4 =
- (byte) (((word - (c1 * ASCII85OutputStream.BASE_85_1)
+ (byte) (((maskedWord - (c1 * ASCII85OutputStream.BASE_85_1)
- (c2 * ASCII85OutputStream.BASE_85_2)
- (c3 * ASCII85OutputStream.BASE_85_3))
/ ASCII85OutputStream.BASE_85_4)
& 0xFF);
final byte c5 =
- (byte) (((word - (c1 * ASCII85OutputStream.BASE_85_1)
+ (byte) (((maskedWord - (c1 * ASCII85OutputStream.BASE_85_1)
- (c2 * ASCII85OutputStream.BASE_85_2)
- (c3 * ASCII85OutputStream.BASE_85_3)
- (c4 * ASCII85OutputStream.BASE_85_4)))
Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2006-10-02 23:57:40 UTC (rev 8269)
+++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2006-10-03 01:54:03 UTC (rev 8270)
@@ -413,14 +413,15 @@
}
protected void addFilledRect(final int x, final int y, final int w,
- int h, final Color col) {
+ final int h, final Color col) {
// XXX: cater for braindead, legacy -ve heights
- if (h < 0) {
- h = -h;
+ int height = h;
+ if (height < 0) {
+ height = -height;
}
write("newpath");
- write(x + " " + y + " " + w + " " + -h + " re");
+ write(x + " " + y + " " + w + " " + -height + " re");
/*
write(x + " " + y + " M");
write(w + " 0 rlineto");
Modified: trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java 2006-10-02 23:57:40 UTC (rev 8269)
+++ trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java 2006-10-03 01:54:03 UTC (rev 8270)
@@ -101,7 +101,8 @@
super(logger, renderConfig);
}
- void addStr(int row, int col, String str, final boolean ischar) {
+ void addStr(final int row, final int col, final String str,
+ final boolean ischar) {
if (this.debug) {
getLogger().info("TXTRenderer.addStr(" + row + ", " + col
+ ", \"" + str + "\", " + ischar + ")");
@@ -110,45 +111,50 @@
return;
}
StringBuffer sb;
+ int modifiedRow = row;
if (row < 0) {
- row = 0;
+ modifiedRow = 0;
}
if (ischar) {
- sb = this.charData[row];
+ sb = this.charData[modifiedRow];
} else {
- sb = this.decoData[row];
+ sb = this.decoData[modifiedRow];
}
if (sb == null) {
sb = new StringBuffer();
}
+ int modifiedColumn = col;
if ((col + str.length()) > this.maxX) {
- col = this.maxX - str.length();
+ modifiedColumn = this.maxX - str.length();
}
+ String modifiedString = str;
if (col < 0) {
- col = 0;
+ modifiedColumn = 0;
if (str.length() > this.maxX) {
- str = str.substring(0, this.maxX);
+ modifiedString = str.substring(0, this.maxX);
}
}
// Pad to col
- for (int countr = sb.length(); countr < col; countr++) {
+ for (int countr = sb.length(); countr < modifiedColumn; countr++) {
sb.append(' ');
}
getLogger().debug("TXTRenderer.addStr() sb.length()=" + sb.length());
- for (int countr = col; countr < (col + str.length()); countr++) {
+ for (int countr = modifiedColumn;
+ countr < (modifiedColumn + modifiedString.length()); countr++) {
if (countr >= sb.length()) {
- sb.append(str.charAt(countr - col));
+ sb.append(modifiedString.charAt(countr - modifiedColumn));
} else {
getLogger().debug("TXTRenderer.addStr() sb.length()="
+ sb.length() + " countr=" + countr);
- sb.setCharAt(countr, str.charAt(countr - col));
+ sb.setCharAt(countr, modifiedString.charAt(
+ countr - modifiedColumn));
}
}
if (ischar) {
- this.charData[row] = sb;
+ this.charData[modifiedRow] = sb;
} else {
- this.decoData[row] = sb;
+ this.decoData[modifiedRow] = sb;
}
}
@@ -196,25 +202,27 @@
* @param h the height in millipoints
* @param stroke the stroke color/gradient
*/
- protected void drawRectangle(final int x, final int y, int w, int h,
- final Color stroke) {
- if (h < 0) {
- h *= -1;
+ protected void drawRectangle(final int x, final int y, final int w,
+ final int h, final Color stroke) {
+ int width = w;
+ int height = h;
+ if (height < 0) {
+ height *= -1;
}
- if (h < 720 || w < 720) {
- if (w < 720) {
- w = 720;
+ if (height < 720 || width < 720) {
+ if (width < 720) {
+ width = 720;
}
- if (h < 720) {
- h = 720;
+ if (height < 720) {
+ height = 720;
}
- addRect(x, y, w, h, stroke, stroke);
+ addRect(x, y, width, height, stroke, stroke);
} else {
- addRect(x, y, w, 720, stroke, stroke);
- addRect(x, y, 720, h, stroke, stroke);
- addRect(x + w - 720, y, 720, h, stroke, stroke);
- addRect(x, y - h + 720, w, 720, stroke, stroke);
+ addRect(x, y, width, 720, stroke, stroke);
+ addRect(x, y, 720, height, stroke, stroke);
+ addRect(x + width - 720, y, 720, height, stroke, stroke);
+ addRect(x, y - height + 720, width, 720, stroke, stroke);
}
}
@@ -228,13 +236,14 @@
* @param fill the fill color/gradient
* @param stroke the stroke color/gradient
*/
- protected void addRect(final int x, final int y, final int w, int h,
+ protected void addRect(final int x, final int y, final int w, final int h,
final Color stroke, final Color fill) {
if ((w == 0) || (h == 0)) {
return;
}
- if (h < 0) {
- h *= -1;
+ int height = h;
+ if (height < 0) {
+ height *= -1;
}
final int row = (int) ((this.pageHeight - (y / 100)) * 100
@@ -247,8 +256,8 @@
final int fillshade = (int) (100 - ((0.3f * fill.getRed()
+ 0.59f * fill.getGreen() + 0.11f * fill.getBlue()) * 100f));
getLogger().debug("TXTRenderer.addRect(" + x + ", " + y + ", "
- + w + ", " + h + ", " + stroke + ", " + fill + ") fillshade="
- + fillshade);
+ + w + ", " + height + ", " + stroke + ", " + fill
+ + ") fillshade=" + fillshade);
char fillchar = ' ';
if (fillshade >= 75) {
fillchar = '#';
@@ -262,16 +271,16 @@
if (fillchar != ' ') {
final StringBuffer linefill = new StringBuffer();
final int sw = (int) (w * this.xFactor);
- final int sh = (int) (h * this.yFactor);
+ final int sh = (int) (height * this.yFactor);
if (sw == 0 || sh == 0) {
if (fillshade >= 50) {
- if (h > w) {
+ if (height > w) {
fillchar = '|';
} else {
fillchar = '-';
}
} else {
- if (h > w) {
+ if (height > w) {
fillchar = ':';
} else {
fillchar = '.';
@@ -306,9 +315,9 @@
for (int countr = 0; countr < sw; countr++) {
linefill.append(hlinechar);
}
- final int sh = (int) (h * this.yFactor);
+ final int sh = (int) (height * this.yFactor);
- if (w > h) {
+ if (w > height) {
for (int countr = 1; countr < (sh - 1); countr++) {
addStr(row + countr, col, String.valueOf(vlinechar),
false);
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-10-02 23:57:40 UTC (rev 8269)
+++ trunk/foray/foray-text/src/java/org/foray/text/line/LineBreaker.java 2006-10-03 01:54:03 UTC (rev 8270)
@@ -192,17 +192,18 @@
protected abstract int addLineContent(LineContent contentItem, int start,
int end, LineOutput output) throws TextException;
- public int getCharWidth(final LineText lineText, int codePoint) {
+ public int getCharWidth(final LineText lineText, final int codePoint) {
final FontUse fontUse = lineText.inlinePrimaryFont();
final Font font = fontUse.getFont();
int fontSize = lineText.inlineFontSize();
+ int codePointToUse = codePoint;
if (lineText.inlineIsFauxSmallCaps()
&& isLowerCase(codePoint)) {
fontSize = lineText.inlineFauxSmallCapsFontSize();
- codePoint = java.lang.Character.toUpperCase((char) codePoint);
+ codePointToUse = java.lang.Character.toUpperCase((char) codePoint);
}
- fontUse.registerCharUsed(codePoint);
- return font.width(codePoint, fontSize)
+ fontUse.registerCharUsed(codePointToUse);
+ return font.width(codePointToUse, fontSize)
+ lineText.inlineLetterSpacingOptimum();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|