[FOray-commit] SF.net SVN: foray: [7930] trunk/foray/foray-render/src/java/org/foray/ render
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2006-09-06 01:11:44
|
Revision: 7930
http://svn.sourceforge.net/foray/?rev=7930&view=rev
Author: victormote
Date: 2006-09-05 18:11:32 -0700 (Tue, 05 Sep 2006)
Log Message:
-----------
Use "this" modifier for all instance or class variables.
Modified Paths:
--------------
trunk/foray/foray-render/src/java/org/foray/render/ps/ASCII85OutputStream.java
trunk/foray/foray-render/src/java/org/foray/render/ps/PSFont.java
trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java
trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/ps/RunLengthEncodeOutputStream.java
trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/svg/SVGUtilities.java
trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java
trunk/foray/foray-render/src/java/org/foray/render/txt/TXTStream.java
trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java
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-09-06 00:28:17 UTC (rev 7929)
+++ trunk/foray/foray-render/src/java/org/foray/render/ps/ASCII85OutputStream.java 2006-09-06 01:11:32 UTC (rev 7930)
@@ -42,15 +42,18 @@
implements Finalizable {
private static final int ZERO = 0x7A; //"z"
- private static final byte[] ZERO_ARRAY = {(byte)ZERO};
+ private static final byte[] ZERO_ARRAY = {(byte) ASCII85OutputStream.ZERO};
private static final int START = 0x21; //"!"
private static final int EOL = 0x0A; //"\n"
private static final byte[] EOD = {0x7E, 0x3E}; //"~>"
private static final long base85_4 = 85;
- private static final long base85_3 = base85_4 * base85_4;
- private static final long base85_2 = base85_3 * base85_4;
- private static final long base85_1 = base85_2 * base85_4;
+ private static final long base85_3 = ASCII85OutputStream.base85_4
+ * ASCII85OutputStream.base85_4;
+ private static final long base85_2 = ASCII85OutputStream.base85_3
+ * ASCII85OutputStream.base85_4;
+ private static final long base85_1 = ASCII85OutputStream.base85_2
+ * ASCII85OutputStream.base85_4;
private static final boolean DEBUG = false;
@@ -66,21 +69,21 @@
public void write(final int b) throws IOException {
- if (pos == 0) {
- buffer += (b << 24) & 0xff000000L;
- } else if (pos == 1) {
- buffer += (b << 16) & 0xff0000L;
- } else if (pos == 2) {
- buffer += (b << 8) & 0xff00L;
+ if (this.pos == 0) {
+ this.buffer += (b << 24) & 0xff000000L;
+ } else if (this.pos == 1) {
+ this.buffer += (b << 16) & 0xff0000L;
+ } else if (this.pos == 2) {
+ this.buffer += (b << 8) & 0xff00L;
} else {
- buffer += b & 0xffL;
+ this.buffer += b & 0xffL;
}
- pos++;
+ this.pos++;
- if (pos > 3) {
- checkedWrite(convertWord(buffer));
- buffer = 0;
- pos = 0;
+ if (this.pos > 3) {
+ checkedWrite(convertWord(this.buffer));
+ this.buffer = 0;
+ this.pos = 0;
}
}
@@ -103,22 +106,24 @@
private void checkedWrite(final byte[] buf, final int len,
final boolean nosplit) throws IOException {
- if (posinline + len > 80) {
- final int firstpart = (nosplit ? 0 : len - (posinline + len - 80));
+ if (this.posinline + len > 80) {
+ final int firstpart = (nosplit ? 0 : len - (this.posinline + len
+ - 80));
if (firstpart > 0) {
out.write(buf, 0, firstpart);
}
- out.write(EOL); bw++;
+ out.write(ASCII85OutputStream.EOL);
+ this.bw++;
final int rest = len - firstpart;
if (rest > 0) {
out.write(buf, firstpart, rest);
}
- posinline = rest;
+ this.posinline = rest;
} else {
out.write(buf, 0, len);
- posinline += len;
+ this.posinline += len;
}
- bw += len;
+ this.bw += len;
}
@@ -135,32 +140,41 @@
word = word & 0xffffffff;
if (word == 0) {
- return ZERO_ARRAY;
+ return ASCII85OutputStream.ZERO_ARRAY;
}
if (word < 0) {
word = -word;
}
- final byte c1 = (byte)((word / base85_1) & 0xFF);
- final byte c2 = (byte)(((word - (c1 * base85_1)) / base85_2) & 0xFF);
+ final byte c1 = (byte)((word / ASCII85OutputStream.base85_1) & 0xFF);
+ final byte c2 = (byte)(((word - (c1 * ASCII85OutputStream.base85_1))
+ / ASCII85OutputStream.base85_2) & 0xFF);
final byte c3 =
- (byte)(((word - (c1 * base85_1) - (c2 * base85_2)) / base85_3)
+ (byte)(((word - (c1 * ASCII85OutputStream.base85_1)
+ - (c2 * ASCII85OutputStream.base85_2))
+ / ASCII85OutputStream.base85_3)
& 0xFF);
final byte c4 =
- (byte)(((word - (c1 * base85_1) - (c2 * base85_2)
- - (c3 * base85_3)) / base85_4)
+ (byte)(((word - (c1 * ASCII85OutputStream.base85_1)
+ - (c2 * ASCII85OutputStream.base85_2)
+ - (c3 * ASCII85OutputStream.base85_3))
+ / ASCII85OutputStream.base85_4)
& 0xFF);
final byte c5 =
- (byte)(((word - (c1 * base85_1) - (c2 * base85_2)
- - (c3 * base85_3) - (c4 * base85_4)))
+ (byte)(((word - (c1 * ASCII85OutputStream.base85_1)
+ - (c2 * ASCII85OutputStream.base85_2)
+ - (c3 * ASCII85OutputStream.base85_3)
+ - (c4 * ASCII85OutputStream.base85_4)))
& 0xFF);
final byte[] ret = {
- (byte)(c1 + START), (byte)(c2 + START),
- (byte)(c3 + START), (byte)(c4 + START),
- (byte)(c5 + START)
+ (byte)(c1 + ASCII85OutputStream.START),
+ (byte)(c2 + ASCII85OutputStream.START),
+ (byte)(c3 + ASCII85OutputStream.START),
+ (byte)(c4 + ASCII85OutputStream.START),
+ (byte)(c5 + ASCII85OutputStream.START)
};
- if (DEBUG) {
+ if (ASCII85OutputStream.DEBUG) {
for (int i = 0; i < ret.length; i++) {
if (ret[i] < 33 || ret[i] > 117) {
throw new IOException("ASCII85 Filter: Illegal char value "
@@ -176,8 +190,8 @@
// with n leftover bytes, we append 0 bytes to make a full group of 4
// then convert like normal (except not applying the special zero rule)
// and write out the first n+1 bytes from the result
- if (pos > 0) {
- final int rest = pos;
+ if (this.pos > 0) {
+ final int rest = this.pos;
/*
byte[] lastdata = new byte[4];
int i = 0;
@@ -197,8 +211,8 @@
byte[] conv;
// special rule for handling zeros at the end
- if (buffer != 0) {
- conv = convertWord(buffer);
+ if (this.buffer != 0) {
+ conv = convertWord(this.buffer);
} else {
conv = new byte[5];
for (int j = 0; j < 5; j++) {
@@ -209,7 +223,7 @@
checkedWrite(conv, rest + 1);
}
// finally write the two character end of data marker
- checkedWrite(EOD, true);
+ checkedWrite(ASCII85OutputStream.EOD, true);
flush();
if (out instanceof Finalizable) {
Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSFont.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/ps/PSFont.java 2006-09-06 00:28:17 UTC (rev 7929)
+++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSFont.java 2006-09-06 01:11:32 UTC (rev 7930)
@@ -67,7 +67,7 @@
* @return Returns the fsFont.
*/
public FontUse getFontUse() {
- return fontUse;
+ return this.fontUse;
}
}
Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java 2006-09-06 00:28:17 UTC (rev 7929)
+++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java 2006-09-06 01:11:32 UTC (rev 7930)
@@ -90,7 +90,7 @@
{
final BufferedImage bi = new BufferedImage(1, 1,
BufferedImage.TYPE_INT_ARGB);
- fmg = bi.createGraphics();
+ this.fmg = bi.createGraphics();
}
/**
@@ -101,7 +101,7 @@
public PSGraphics2D(final boolean textAsShapes, final PSRenderer ren,
final String font, final int size, final int xpos, final int ypos) {
super(textAsShapes);
- psRenderer = ren;
+ this.psRenderer = ren;
}
public PSGraphics2D(final boolean textAsShapes) {
@@ -213,15 +213,15 @@
final AffineTransform at = getTransform();
final double[] matrix = new double[6];
at.getMatrix(matrix);
- psRenderer.write("gsave");
+ this.psRenderer.write("gsave");
final Shape imclip = getClip();
writeClip(imclip);
- psRenderer.write("1000 -1000 scale");
+ this.psRenderer.write("1000 -1000 scale");
// psRenderer.write("" + matrix[0] + " " + matrix[1] +
// " " + matrix[2] + " " + matrix[3] + " " +
// matrix[4] + " " + matrix[5] + " cm\n");
- psRenderer.renderBitmap(graphic, x, -y, width, height);
- psRenderer.write("grestore");
+ this.psRenderer.renderBitmap(graphic, x, -y, width, height);
+ this.psRenderer.write("grestore");
} catch (final Exception e) {
e.printStackTrace();
}
@@ -299,7 +299,7 @@
* @see java.awt.Component#getGraphics
*/
public void dispose() {
- psRenderer = null;
+ this.psRenderer = null;
}
/**
@@ -318,24 +318,24 @@
* @see AbstractGraphics2D#setComposite
*/
public void draw(final Shape s) {
- psRenderer.write("gsave");
+ this.psRenderer.write("gsave");
final Shape imclip = getClip();
writeClip(imclip);
final Color c = getColor();
- psRenderer.write(c.getRed() + " " + c.getGreen() + " " + c.getBlue()
- + " setrgbcolor");
+ this.psRenderer.write(c.getRed() + " " + c.getGreen() + " "
+ + c.getBlue() + " setrgbcolor");
applyPaint(getPaint(), false);
applyStroke(getStroke());
- psRenderer.write("newpath");
+ this.psRenderer.write("newpath");
final PathIterator iter = s.getPathIterator(getTransform());
while (!iter.isDone()) {
final double vals[] = new double[6];
final int type = iter.currentSegment(vals);
switch (type) {
case PathIterator.SEG_CUBICTO:
- psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ this.psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ PSReal.doubleOut(1000 * vals[1]) + " "
+ PSReal.doubleOut(1000 * vals[2]) + " "
+ PSReal.doubleOut(1000 * vals[3]) + " "
@@ -344,12 +344,12 @@
+ " curveto");
break;
case PathIterator.SEG_LINETO:
- psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ this.psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ PSReal.doubleOut(1000 * vals[1])
+ " lineto");
break;
case PathIterator.SEG_MOVETO:
- psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ this.psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ PSReal.doubleOut(1000 * vals[1])
+ " M");
break;
@@ -360,7 +360,7 @@
// (1000 * PDFNumber.doubleOut(vals[3])) + " y\n");
break;
case PathIterator.SEG_CLOSE:
- psRenderer.write("closepath");
+ this.psRenderer.write("closepath");
break;
default:
break;
@@ -368,18 +368,18 @@
iter.next();
}
doDrawing(false, true, false);
- psRenderer.write("grestore");
+ this.psRenderer.write("grestore");
}
protected void writeClip(final Shape s) {
final PathIterator iter = s.getPathIterator(getTransform());
- psRenderer.write("newpath");
+ this.psRenderer.write("newpath");
while (!iter.isDone()) {
final double vals[] = new double[6];
final int type = iter.currentSegment(vals);
switch (type) {
case PathIterator.SEG_CUBICTO:
- psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ this.psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ PSReal.doubleOut(1000 * vals[1]) + " "
+ PSReal.doubleOut(1000 * vals[2]) + " "
+ PSReal.doubleOut(1000 * vals[3]) + " "
@@ -388,12 +388,12 @@
+ " curveto");
break;
case PathIterator.SEG_LINETO:
- psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ this.psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ PSReal.doubleOut(1000 * vals[1])
+ " lineto");
break;
case PathIterator.SEG_MOVETO:
- psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ this.psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ PSReal.doubleOut(1000 * vals[1])
+ " M");
break;
@@ -404,7 +404,7 @@
// 1000 * PDFNumber.doubleOut(vals[3]) + " y\n");
break;
case PathIterator.SEG_CLOSE:
- psRenderer.write("closepath");
+ this.psRenderer.write("closepath");
break;
default:
break;
@@ -412,7 +412,7 @@
iter.next();
}
// clip area
- psRenderer.write("clippath");
+ this.psRenderer.write("clippath");
}
protected void applyPaint(final Paint paint, final boolean fill) {
@@ -461,48 +461,48 @@
final float[] da = bs.getDashArray();
if (da != null) {
- psRenderer.write("[");
+ this.psRenderer.write("[");
for (int count = 0; count < da.length; count++) {
- psRenderer.write("" + (1000 * (int)da[count]));
+ this.psRenderer.write("" + (1000 * (int)da[count]));
if (count < da.length - 1) {
- psRenderer.write(" ");
+ this.psRenderer.write(" ");
}
}
- psRenderer.write("] ");
+ this.psRenderer.write("] ");
final float offset = bs.getDashPhase();
- psRenderer.write((1000 * (int)offset) + " setdash");
+ this.psRenderer.write((1000 * (int)offset) + " setdash");
}
final int ec = bs.getEndCap();
switch (ec) {
case BasicStroke.CAP_BUTT:
- psRenderer.write(0 + " setlinecap");
+ this.psRenderer.write(0 + " setlinecap");
break;
case BasicStroke.CAP_ROUND:
- psRenderer.write(1 + " setlinecap");
+ this.psRenderer.write(1 + " setlinecap");
break;
case BasicStroke.CAP_SQUARE:
- psRenderer.write(2 + " setlinecap");
+ this.psRenderer.write(2 + " setlinecap");
break;
}
final int lj = bs.getLineJoin();
switch (lj) {
case BasicStroke.JOIN_MITER:
- psRenderer.write(0 + " setlinejoin");
+ this.psRenderer.write(0 + " setlinejoin");
break;
case BasicStroke.JOIN_ROUND:
- psRenderer.write(1 + " setlinejoin");
+ this.psRenderer.write(1 + " setlinejoin");
break;
case BasicStroke.JOIN_BEVEL:
- psRenderer.write(2 + " setlinejoin");
+ this.psRenderer.write(2 + " setlinejoin");
break;
}
final float lw = bs.getLineWidth();
- psRenderer.write(PSReal.doubleOut(1000 * lw)
+ this.psRenderer.write(PSReal.doubleOut(1000 * lw)
+ " setlinewidth");
final float ml = bs.getMiterLimit();
- psRenderer.write(PSReal.doubleOut(1000 * ml)
+ this.psRenderer.write(PSReal.doubleOut(1000 * ml)
+ " setmiterlimit");
}
}
@@ -591,19 +591,19 @@
* @see AbstractGraphics2D#setClip(java.awt.Shape)
*/
public void drawString(final String s, final float x, final float y) {
- psRenderer.write("BT");
+ this.psRenderer.write("BT");
final Shape imclip = getClip();
writeClip(imclip);
final Color c = getColor();
- psRenderer.write(c.getRed() + " " + c.getGreen() + " " + c.getBlue()
- + " setrgbcolor");
+ this.psRenderer.write(c.getRed() + " " + c.getGreen() + " "
+ + c.getBlue() + " setrgbcolor");
final AffineTransform trans = getTransform();
trans.translate(x, y);
final double[] vals = new double[6];
trans.getMatrix(vals);
- psRenderer.write(PSReal.doubleOut(vals[0]) + " "
+ this.psRenderer.write(PSReal.doubleOut(vals[0]) + " "
+ PSReal.doubleOut(vals[1]) + " "
+ PSReal.doubleOut(vals[2]) + " "
+ PSReal.doubleOut(vals[3]) + " "
@@ -611,7 +611,7 @@
+ PSReal.doubleOut(vals[5]) + " "
+ PSReal.doubleOut(vals[6]) + " Tm [" + s + "]");
- psRenderer.write("ET");
+ this.psRenderer.write("ET");
}
/**
@@ -639,12 +639,13 @@
*/
public void drawString(final AttributedCharacterIterator iterator,
final float x, final float y) {
- psRenderer.getLogger().error("drawString(AttributedCharacterIterator)");
- psRenderer.write("BT");
+ this.psRenderer.getLogger().error(
+ "drawString(AttributedCharacterIterator)");
+ this.psRenderer.write("BT");
final Shape imclip = getClip();
writeClip(imclip);
- psRenderer.write(PSColor.toPS(getColor(), true, "\n"));
- psRenderer.write(PSColor.toPS(getBackground(), true, "\n"));
+ this.psRenderer.write(PSColor.toPS(getColor(), true, "\n"));
+ this.psRenderer.write(PSColor.toPS(getBackground(), true, "\n"));
final AffineTransform trans = getTransform();
trans.translate(x, y);
@@ -654,7 +655,7 @@
for (char ch = iterator.first(); ch != CharacterIterator.DONE;
ch = iterator.next()) {
- psRenderer.write(PSReal.doubleOut(vals[0]) + " "
+ this.psRenderer.write(PSReal.doubleOut(vals[0]) + " "
+ PSReal.doubleOut(vals[1]) + " "
+ PSReal.doubleOut(vals[2]) + " "
+ PSReal.doubleOut(vals[3]) + " "
@@ -664,7 +665,7 @@
+ "]");
}
- psRenderer.write("ET");
+ this.psRenderer.write("ET");
}
/**
@@ -682,23 +683,23 @@
* @see AbstractGraphics2D#setClip(java.awt.Shape)
*/
public void fill(final Shape s) {
- psRenderer.write("gsave");
+ this.psRenderer.write("gsave");
final Shape imclip = getClip();
writeClip(imclip);
final Color c = getColor();
- psRenderer.write(c.getRed() + " " + c.getGreen() + " " + c.getBlue()
- + " setrgbcolor");
+ this.psRenderer.write(c.getRed() + " " + c.getGreen() + " "
+ + c.getBlue() + " setrgbcolor");
applyPaint(getPaint(), true);
- psRenderer.write("newpath");
+ this.psRenderer.write("newpath");
final PathIterator iter = s.getPathIterator(getTransform());
while (!iter.isDone()) {
final double vals[] = new double[6];
final int type = iter.currentSegment(vals);
switch (type) {
case PathIterator.SEG_CUBICTO:
- psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ this.psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ PSReal.doubleOut(1000 * vals[1]) + " "
+ PSReal.doubleOut(1000 * vals[2]) + " "
+ PSReal.doubleOut(1000 * vals[3]) + " "
@@ -707,12 +708,12 @@
+ " curveto");
break;
case PathIterator.SEG_LINETO:
- psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ this.psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ PSReal.doubleOut(1000 * vals[1])
+ " lineto");
break;
case PathIterator.SEG_MOVETO:
- psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ this.psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " "
+ PSReal.doubleOut(1000 * vals[1])
+ " M");
break;
@@ -723,7 +724,7 @@
// 1000 * PDFNumber.doubleOut(vals[3]) + " y\n");
break;
case PathIterator.SEG_CLOSE:
- psRenderer.write("closepath");
+ this.psRenderer.write("closepath");
break;
default:
break;
@@ -732,7 +733,7 @@
}
doDrawing(true, false,
iter.getWindingRule() == PathIterator.WIND_EVEN_ODD);
- psRenderer.write("grestore");
+ this.psRenderer.write("grestore");
}
protected void doDrawing(final boolean fill, final boolean stroke,
@@ -740,20 +741,20 @@
if (fill) {
if (stroke) {
if (!nonzero) {
- psRenderer.write("stroke");
+ this.psRenderer.write("stroke");
} else {
- psRenderer.write("stroke");
+ this.psRenderer.write("stroke");
}
} else {
if (!nonzero) {
- psRenderer.write("fill");
+ this.psRenderer.write("fill");
} else {
- psRenderer.write("fill");
+ this.psRenderer.write("fill");
}
}
} else {
// if(stroke)
- psRenderer.write("stroke");
+ this.psRenderer.write("stroke");
}
}
@@ -775,7 +776,7 @@
* @see java.awt.Graphics#getFontMetrics()
*/
public FontMetrics getFontMetrics(final Font f) {
- return fmg.getFontMetrics(f);
+ return this.fmg.getFontMetrics(f);
}
/**
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-09-06 00:28:17 UTC (rev 7929)
+++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2006-09-06 01:11:32 UTC (rev 7930)
@@ -185,12 +185,12 @@
*/
protected void write(final String cmd) {
try {
- out.write(cmd);
+ this.out.write(cmd);
} catch (final IOException e) {
- if (!ioTrouble) {
+ if (! this.ioTrouble) {
e.printStackTrace();
}
- ioTrouble = true;
+ this.ioTrouble = true;
}
}
@@ -199,12 +199,12 @@
*/
protected void writeRaw(final String cmd) {
try {
- out.writeRaw(cmd);
+ this.out.writeRaw(cmd);
} catch (final IOException e) {
- if (!ioTrouble) {
+ if (! this.ioTrouble) {
e.printStackTrace();
}
- ioTrouble = true;
+ this.ioTrouble = true;
}
}
@@ -503,8 +503,8 @@
write(sx * at.getScaleX() + " " + sy * at.getScaleY() + " scale");
final PSGraphics2D graphics = new PSGraphics2D(false, this,
- currentPSFont.getName(),
- currentFontSize, x, y);
+ this.currentPSFont.getName(),
+ this.currentFontSize, x, y);
graphics.setGraphicContext(new GraphicContext());
try {
root.paint(graphics);
@@ -577,7 +577,7 @@
public void renderEPS(final EPSGraphic img, final int x, final int y,
final int w, final int h) {
try {
- out.writeByteArr(epsToPostScript(img, x, y, w, h));
+ this.out.writeByteArr(epsToPostScript(img, x, y, w, h));
} catch (final Exception e) {
e.printStackTrace();
getLogger().error("PSRenderer.renderImageArea(): Error rendering "
@@ -728,10 +728,10 @@
out.flush();
}
} catch (final IOException e) {
- if (!ioTrouble) {
+ if (! this.ioTrouble) {
e.printStackTrace();
}
- ioTrouble = true;
+ this.ioTrouble = true;
}
write("");
@@ -843,11 +843,12 @@
if (psFont == null) {
return;
}
- if ((currentPSFont != psFont) || (currentFontSize != size)) {
+ if ((this.currentPSFont != psFont)
+ || (this.currentFontSize != size)) {
final String sizeString = String.valueOf(Math.round(size / 1000));
write(psFont.getName() + " " + sizeString + " F");
- currentPSFont = psFont;
- currentFontSize = size;
+ this.currentPSFont = psFont;
+ this.currentFontSize = size;
}
}
@@ -1045,10 +1046,10 @@
}
private void writeSetup() {
- if (setupWritten) {
+ if (this.setupWritten) {
return;
}
- setupWritten = true;
+ this.setupWritten = true;
write("%%BeginSetup");
writeProcs();
writeFontDict();
Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/RunLengthEncodeOutputStream.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/ps/RunLengthEncodeOutputStream.java 2006-09-06 00:28:17 UTC (rev 7929)
+++ trunk/foray/foray-render/src/java/org/foray/render/ps/RunLengthEncodeOutputStream.java 2006-09-06 01:11:32 UTC (rev 7930)
@@ -74,77 +74,82 @@
* output stream has been closed.
*/
public void write(final byte b) throws IOException {
- runBuffer[runCount] = b;
+ this.runBuffer[this.runCount] = b;
- switch (runCount) {
+ switch (this.runCount) {
case 0:
- runCount = 0;
- isSequence = NOT_IDENTIFY_SEQUENCE;
- runCount++;
+ this.runCount = 0;
+ this.isSequence = NOT_IDENTIFY_SEQUENCE;
+ this.runCount++;
break;
case 1:
- if (runBuffer[runCount] != runBuffer[runCount - 1]) {
- isSequence = NOT_IN_SEQUENCE;
+ if (this.runBuffer[this.runCount]
+ != this.runBuffer[this.runCount - 1]) {
+ this.isSequence = NOT_IN_SEQUENCE;
}
- runCount++;
+ this.runCount++;
break;
case 2:
- if (runBuffer[runCount] != runBuffer[runCount - 1]) {
- isSequence = NOT_IN_SEQUENCE;
+ if (this.runBuffer[this.runCount]
+ != this.runBuffer[this.runCount - 1]) {
+ this.isSequence = NOT_IN_SEQUENCE;
} else {
- if (isSequence == NOT_IN_SEQUENCE) {
- isSequence = START_SEQUENCE;
+ if (this.isSequence == NOT_IN_SEQUENCE) {
+ this.isSequence = START_SEQUENCE;
} else {
isSequence = IN_SEQUENCE;
}
}
- runCount++;
+ this.runCount++;
break;
case MAX_SEQUENCE_COUNT:
- if (isSequence == IN_SEQUENCE) {
+ if (this.isSequence == IN_SEQUENCE) {
out.write(BYTE_MAX - (MAX_SEQUENCE_COUNT - 1));
- out.write(runBuffer[runCount - 1]);
- runBuffer[0] = runBuffer[runCount];
- runCount = 1;
+ out.write(this.runBuffer[this.runCount - 1]);
+ this.runBuffer[0] = this.runBuffer[this.runCount];
+ this.runCount = 1;
} else {
out.write(MAX_SEQUENCE_COUNT);
- out.write(runBuffer, 0, runCount + 1);
- runCount = 0;
+ out.write(this.runBuffer, 0, this.runCount + 1);
+ this.runCount = 0;
}
- isSequence = NOT_IDENTIFY_SEQUENCE;
+ this.isSequence = NOT_IDENTIFY_SEQUENCE;
break;
default:
- switch (isSequence) {
+ switch (this.isSequence) {
case IN_SEQUENCE:
- if (runBuffer[runCount] != runBuffer[runCount - 1]) {
- out.write(BYTE_MAX - (runCount - 1));
- out.write(runBuffer[runCount - 1]);
- runBuffer[0] = runBuffer[runCount];
- runCount = 1;
- isSequence = NOT_IDENTIFY_SEQUENCE;
+ if (this.runBuffer[this.runCount]
+ != this.runBuffer[this.runCount - 1]) {
+ out.write(BYTE_MAX - (this.runCount - 1));
+ out.write(this.runBuffer[this.runCount - 1]);
+ this.runBuffer[0] = this.runBuffer[this.runCount];
+ this.runCount = 1;
+ this.isSequence = NOT_IDENTIFY_SEQUENCE;
break;
}
- runCount++;
+ this.runCount++;
break;
case NOT_IN_SEQUENCE:
- if (runBuffer[runCount] == runBuffer[runCount - 1]) {
- isSequence = START_SEQUENCE;
+ if (this.runBuffer[this.runCount]
+ == this.runBuffer[this.runCount - 1]) {
+ this.isSequence = START_SEQUENCE;
}
- runCount++;
+ this.runCount++;
break;
case START_SEQUENCE:
- if (runBuffer[runCount] == runBuffer[runCount - 1]) {
- out.write(runCount - 3);
- out.write(runBuffer, 0, runCount - 2);
- runBuffer[0] = runBuffer[runCount];
- runBuffer[1] = runBuffer[runCount];
- runBuffer[2] = runBuffer[runCount];
- runCount = 3;
- isSequence = IN_SEQUENCE;
+ if (this.runBuffer[this.runCount]
+ == this.runBuffer[this.runCount - 1]) {
+ out.write(this.runCount - 3);
+ out.write(this.runBuffer, 0, this.runCount - 2);
+ this.runBuffer[0] = this.runBuffer[this.runCount];
+ this.runBuffer[1] = this.runBuffer[this.runCount];
+ this.runBuffer[2] = this.runBuffer[this.runCount];
+ this.runCount = 3;
+ this.isSequence = IN_SEQUENCE;
break;
}
- isSequence = NOT_IN_SEQUENCE;
- runCount++;
+ this.isSequence = NOT_IN_SEQUENCE;
+ this.runCount++;
break;
}
}
@@ -191,14 +196,14 @@
*/
public void finalizeStream()
throws IOException {
- switch (isSequence) {
+ switch (this.isSequence) {
case IN_SEQUENCE:
- out.write(BYTE_MAX - (runCount - 1));
- out.write(runBuffer[runCount - 1]);
+ out.write(BYTE_MAX - (this.runCount - 1));
+ out.write(this.runBuffer[this.runCount - 1]);
break;
default:
- out.write(runCount - 1);
- out.write(runBuffer, 0, runCount);
+ out.write(this.runCount - 1);
+ out.write(this.runBuffer, 0, this.runCount);
}
out.write(END_OF_DATA);
Modified: trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2006-09-06 00:28:17 UTC (rev 7929)
+++ trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2006-09-06 01:11:32 UTC (rev 7930)
@@ -93,15 +93,16 @@
protected void drawLine(final int x1, final int y1, final int x2,
final int y2, final int th, final int ruleStyle,
final Color strokeColor) {
- final Element line = SVGUtilities.createLine(svgDocument, x1 / 1000f,
- pageHeight - (y1 / 1000f), x2 / 1000f,
- pageHeight - (y2 / 1000f));
+ final Element line = SVGUtilities.createLine(this.svgDocument,
+ x1 / 1000f,
+ this.pageHeight - (y1 / 1000f), x2 / 1000f,
+ this.pageHeight - (y2 / 1000f));
line.setAttributeNS(null, "style", "stroke-width:"
+ (Math.abs(th) / 1000f) + ";stroke:rgb("
+ strokeColor.getRed() + ","
+ strokeColor.getGreen() + ","
+ strokeColor.getBlue() + ")");
- currentPageG.appendChild(line);
+ this.currentPageG.appendChild(line);
}
/**
@@ -126,11 +127,12 @@
*/
protected void addRect(final int x, final int y, final int w, final int h,
final float r, final float g, final float b) {
- final Element rect = SVGUtilities.createRect(svgDocument, x / 1000f,
- pageHeight - (y / 1000f), w / 1000f, h / 1000f);
+ final Element rect = SVGUtilities.createRect(this.svgDocument,
+ x / 1000f,
+ this.pageHeight - (y / 1000f), w / 1000f, h / 1000f);
rect.setAttributeNS(null, "style", "stroke:rgb(" + ((int)(255 * r))
+ "," + ((int)(255 * g)) + "," + ((int)(255 * b)) + ")");
- currentPageG.appendChild(rect);
+ this.currentPageG.appendChild(rect);
}
/**
@@ -150,13 +152,14 @@
protected void addRect(final int x, final int y, final int w, final int h,
final float r, final float g, final float b, final float fr,
final float fg, final float fb) {
- final Element rect = SVGUtilities.createRect(svgDocument, x / 1000f,
- pageHeight - (y / 1000f), w / 1000f, h / 1000f);
+ final Element rect = SVGUtilities.createRect(this.svgDocument,
+ x / 1000f,
+ this.pageHeight - (y / 1000f), w / 1000f, h / 1000f);
rect.setAttributeNS(null, "style", "stroke:rgb(" + ((int)(255 * r))
+ "," + ((int)(255 * g)) + "," + ((int)(255 * b))
+ ");fill:rgb(" + ((int)(255 * fr)) + "," + ((int)(255 * fg))
+ "," + ((int)(255 * fb)) + ")");
- currentPageG.appendChild(rect);
+ this.currentPageG.appendChild(rect);
}
/**
@@ -171,19 +174,21 @@
protected void addRect(final int x, final int y, final int w, final int h,
final boolean drawAsOutline) {
final int startx = (x + 500) / 1000;
- final int starty = pageHeight - ((y + 500) / 1000);
+ final int starty = this.pageHeight - ((y + 500) / 1000);
final int endx = (x + w + 500) / 1000;
- final int endy = pageHeight - ((y + h + 500) / 1000);
+ final int endy = this.pageHeight - ((y + h + 500) / 1000);
if (drawAsOutline) {
- final Element rect = SVGUtilities.createRect(svgDocument, startx,
+ final Element rect = SVGUtilities.createRect(this.svgDocument,
+ startx,
starty, endx - startx, endy - starty);
rect.setAttributeNS(null, "style", "fill:none");
- currentPageG.appendChild(rect);
+ this.currentPageG.appendChild(rect);
} else {
- final Element rect = SVGUtilities.createRect(svgDocument, startx,
+ final Element rect = SVGUtilities.createRect(this.svgDocument,
+ startx,
starty, endx - startx, starty - endy);
rect.setAttributeNS(null, "style", "stroke:none");
- currentPageG.appendChild(rect);
+ this.currentPageG.appendChild(rect);
}
}
@@ -196,70 +201,77 @@
}
protected void drawFrame() {
- final int width = pageWidth;
- final int height = pageHeight;
- final Element rect = SVGUtilities.createRect(svgDocument, 0, 0, width,
- height);
+ final int width = this.pageWidth;
+ final int height = this.pageHeight;
+ final Element rect = SVGUtilities.createRect(this.svgDocument, 0, 0,
+ width, height);
rect.setAttributeNS(null, "style", "fill:none;stroke:black");
- currentPageG.appendChild(rect);
+ this.currentPageG.appendChild(rect);
}
public void render(final PageArea page) throws IOException {
- pageNumber++;
- final int lastWidth = pageWidth;
- final int lastHeight = pageHeight;
+ this.pageNumber++;
+ final int lastWidth = this.pageWidth;
+ final int lastHeight = this.pageHeight;
- pageWidth = (int) Math.ceil(toPoints(page.getWidth()));
- pageHeight = (int) Math.ceil(toPoints(page.getHeight()));
+ this.pageWidth = (int) Math.ceil(toPoints(page.getWidth()));
+ this.pageHeight = (int) Math.ceil(toPoints(page.getHeight()));
- if(lastLink != null && currentPageG != null) {
- lastLink.setAttributeNS(null, "xlink:href", "#svgView(viewBox(0, "
- + (totalHeight) + ", " + pageWidth + ", " + pageHeight
+ if (this.lastLink != null
+ && this.currentPageG != null) {
+ this.lastLink.setAttributeNS(null, "xlink:href",
+ "#svgView(viewBox(0, "
+ + (this.totalHeight) + ", " + this.pageWidth + ", "
+ + this.pageHeight
+ "))");
- currentPageG.appendChild(lastLink);
+ this.currentPageG.appendChild(this.lastLink);
}
- totalHeight += pageHeight;
- if(totalWidth < pageWidth) {
- totalWidth = pageWidth;
+ this.totalHeight += this.pageHeight;
+ if (this.totalWidth < this.pageWidth) {
+ this.totalWidth = this.pageWidth;
}
- currentPageG = SVGUtilities.createG(svgDocument);
- currentPageG.setAttributeNS(null, "id", /*title + */"Page-"
- + pageNumber);
- currentPageG.setAttributeNS(null, "style",
+ this.currentPageG = SVGUtilities.createG(this.svgDocument);
+ this.currentPageG.setAttributeNS(null, "id", /*title + */"Page-"
+ + this.pageNumber);
+ this.currentPageG.setAttributeNS(null, "style",
"font-family:sanserif;font-size:12");
- svgRoot.appendChild(currentPageG);
+ this.svgRoot.appendChild(this.currentPageG);
drawFrame();
renderRegions(page);
- currentPageG.setAttributeNS(null, "transform", "translate(0,"
- + (totalHeight - pageHeight) + ")");
+ this.currentPageG.setAttributeNS(null, "transform", "translate(0,"
+ + (this.totalHeight - this.pageHeight) + ")");
- final Element lastPageLink = svgDocument.createElementNS(svgNS, "a");
- if(lastLink != null) {
+ final Element lastPageLink = this.svgDocument.createElementNS(
+ SVGRenderer.svgNS, "a");
+ if (this.lastLink != null) {
lastPageLink.setAttributeNS(null, "xlink:href",
- "#svgView(viewBox(0, " + (totalHeight - pageHeight
+ "#svgView(viewBox(0, " + (this.totalHeight - this.pageHeight
- lastHeight) + ", " + lastWidth + ", "
+ lastHeight + "))");
} else {
lastPageLink.setAttributeNS(null, "xlink:href",
- "#svgView(viewBox(0, " + (totalHeight - pageHeight)
- + ", " + pageWidth + ", " + pageHeight + "))");
+ "#svgView(viewBox(0, "
+ + (this.totalHeight - this.pageHeight)
+ + ", " + this.pageWidth + ", " + this.pageHeight + "))");
}
- currentPageG.appendChild(lastPageLink);
- Element rect = SVGUtilities.createRect(svgDocument, 0, 0, pageWidth / 2,
- pageHeight);
+ this.currentPageG.appendChild(lastPageLink);
+ Element rect = SVGUtilities.createRect(this.svgDocument, 0, 0,
+ this.pageWidth / 2,
+ this.pageHeight);
rect.setAttributeNS(null, "style", "fill:blue;visibility:hidden");
lastPageLink.appendChild(rect);
- lastLink = svgDocument.createElementNS(svgNS, "a");
- rect = SVGUtilities.createRect(svgDocument, pageWidth / 2, 0,
- pageWidth / 2, pageHeight);
+ this.lastLink = this.svgDocument.createElementNS(SVGRenderer.svgNS,
+ "a");
+ rect = SVGUtilities.createRect(this.svgDocument, this.pageWidth / 2, 0,
+ this.pageWidth / 2, this.pageHeight);
rect.setAttributeNS(null, "style", "fill:blue;visibility:hidden");
- lastLink.appendChild(rect);
+ this.lastLink.appendChild(rect);
/*
* if (page.hasLinks()) {
@@ -348,7 +360,7 @@
try {
final SVGDocument svg = ((SVGGraphic) img).getSVGDocument();
renderSVGDocument(svg, toPoints(x),
- pageHeight - toPoints(y));
+ this.pageHeight - toPoints(y));
} catch (final GraphicException e) {}
// } else {
@@ -489,7 +501,7 @@
public void render(final SVGArea area) {
final float x = toPoints(area.rrOriginX());
- final float y = pageHeight - toPoints(area.rrOriginY());
+ final float y = this.pageHeight - toPoints(area.rrOriginY());
final Document doc = area.getSVGDocument();
renderSVGDocument(doc, x, y);
}
@@ -497,21 +509,23 @@
protected void renderSVGDocument(final Document doc, final float x,
final float y) {
final SVGSVGElement svg = ((SVGDocument)doc).getRootElement();
- final Element view = svgDocument.createElementNS(svgNS, "svg");
- final Node newsvg = svgDocument.importNode(svg, true);
+ final Element view = this.svgDocument.createElementNS(SVGRenderer.svgNS,
+ "svg");
+ final Node newsvg = this.svgDocument.importNode(svg, true);
//view.setAttributeNS(null, "viewBox", "0 0 ");
view.setAttributeNS(null, "x", "" + x);
view.setAttributeNS(null, "y", "" + y);
// this fixes a problem where the xmlns is repeated sometimes
final Element ele = (Element)newsvg;
- ele.setAttributeNS(XMLSupport.XMLNS_NAMESPACE_URI, "xmlns", svgNS);
+ ele.setAttributeNS(XMLSupport.XMLNS_NAMESPACE_URI, "xmlns",
+ SVGRenderer.svgNS);
if(ele.hasAttributeNS(null, "xmlns")) {
ele.removeAttributeNS(null, "xmlns");
}
view.appendChild(newsvg);
- currentPageG.appendChild(view);
+ this.currentPageG.appendChild(view);
}
public void render(final ForeignObjectArea area) {
@@ -521,22 +535,22 @@
public void startOutput() throws IOException {
final DOMImplementation impl =
SVGDOMImplementation.getDOMImplementation();
- svgDocument = impl.createDocument(svgNS, "svg", null);
+ this.svgDocument = impl.createDocument(SVGRenderer.svgNS, "svg", null);
final ProcessingInstruction pi =
- svgDocument.createProcessingInstruction(
+ this.svgDocument.createProcessingInstruction(
"xml",
" version=\"1.0\" encoding=\"ISO-8859-1\"");
- svgRoot = svgDocument.getDocumentElement();
- svgDocument.insertBefore(pi, svgRoot);
+ this.svgRoot = this.svgDocument.getDocumentElement();
+ this.svgDocument.insertBefore(pi, this.svgRoot);
}
public void stopOutput() throws IOException {
- svgRoot.setAttributeNS(null, "width", "" + totalWidth);
- svgRoot.setAttributeNS(null, "height", "" + totalHeight);
+ this.svgRoot.setAttributeNS(null, "width", "" + this.totalWidth);
+ this.svgRoot.setAttributeNS(null, "height", "" + this.totalHeight);
// svgRoot.setAttributeNS(null, "viewBox", "0 0 " + pageWidth + " "
// + pageHeight);
final SVGTranscoder svgT = new SVGTranscoder();
- final TranscoderInput input = new TranscoderInput(svgDocument);
+ final TranscoderInput input = new TranscoderInput(this.svgDocument);
final OutputStreamWriter osw = new OutputStreamWriter(
this.getOutputStream());
final TranscoderOutput output = new TranscoderOutput(osw);
@@ -548,15 +562,15 @@
}
this.getOutputStream().flush();
- svgDocument = null;
- svgRoot = null;
- currentPageG = null;
- lastLink = null;
+ this.svgDocument = null;
+ this.svgRoot = null;
+ this.currentPageG = null;
+ this.lastLink = null;
- totalWidth = 0;
- totalHeight = 0;
+ this.totalWidth = 0;
+ this.totalHeight = 0;
- pageNumber = 0;
+ this.pageNumber = 0;
}
/**
Modified: trunk/foray/foray-render/src/java/org/foray/render/svg/SVGUtilities.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/svg/SVGUtilities.java 2006-09-06 00:28:17 UTC (rev 7929)
+++ trunk/foray/foray-render/src/java/org/foray/render/svg/SVGUtilities.java 2006-09-06 01:11:32 UTC (rev 7930)
@@ -48,7 +48,8 @@
final float height) {
final DOMImplementation impl =
SVGDOMImplementation.getDOMImplementation();
- final Document doc = impl.createDocument(svgNS, "svg", null);
+ final Document doc = impl.createDocument(SVGUtilities.svgNS, "svg",
+ null);
final Element svgRoot = doc.getDocumentElement();
svgRoot.setAttributeNS(null, "width", "" + width);
@@ -94,7 +95,7 @@
*/
public static final Element createLine(final Document doc, final float x,
final float y, final float x2, final float y2) {
- final Element ellipse = doc.createElementNS(svgNS, "line");
+ final Element ellipse = doc.createElementNS(SVGUtilities.svgNS, "line");
ellipse.setAttributeNS(null, "x1", "" + x);
ellipse.setAttributeNS(null, "x2", "" + x2);
ellipse.setAttributeNS(null, "y1", "" + y);
@@ -107,7 +108,8 @@
*/
public static final Element createEllipse(final Document doc,
final float cx, final float cy, final float rx, final float ry) {
- final Element ellipse = doc.createElementNS(svgNS, "ellipse");
+ final Element ellipse = doc.createElementNS(SVGUtilities.svgNS,
+ "ellipse");
ellipse.setAttributeNS(null, "cx", "" + cx);
ellipse.setAttributeNS(null, "rx", "" + rx);
ellipse.setAttributeNS(null, "cy", "" + cy);
@@ -120,7 +122,7 @@
*/
public static final Element createPath(final Document doc,
final String str) {
- final Element path = doc.createElementNS(svgNS, "path");
+ final Element path = doc.createElementNS(SVGUtilities.svgNS, "path");
path.setAttributeNS(null, "d", str);
return path;
}
@@ -130,7 +132,8 @@
*/
public static final Element createText(final Document doc, final float x,
final float y, final String str) {
- final Element textGraph = doc.createElementNS(svgNS, "text");
+ final Element textGraph = doc.createElementNS(SVGUtilities.svgNS,
+ "text");
textGraph.setAttributeNS(null, "x", "" + x);
textGraph.setAttributeNS(null, "y", "" + y);
final Text text = doc.createTextNode(str);
@@ -143,7 +146,7 @@
*/
public static final Element createRect(final Document doc, final float x,
final float y, final float width, final float height) {
- final Element border = doc.createElementNS(svgNS, "rect");
+ final Element border = doc.createElementNS(SVGUtilities.svgNS, "rect");
border.setAttributeNS(null, "x", "" + x);
border.setAttributeNS(null, "y", "" + y);
border.setAttributeNS(null, "width", "" + width);
@@ -155,7 +158,7 @@
* Create an SVG G.
*/
public static final Element createG(final Document doc) {
- final Element border = doc.createElementNS(svgNS, "g");
+ final Element border = doc.createElementNS(SVGUtilities.svgNS, "g");
return border;
}
@@ -164,7 +167,8 @@
*/
public static final Element createClip(final Document doc,
final Element els, final String id) {
- final Element border = doc.createElementNS(svgNS, "clipPath");
+ final Element border = doc.createElementNS(SVGUtilities.svgNS,
+ "clipPath");
border.setAttributeNS(null, "id", id);
border.appendChild(els);
return border;
@@ -172,7 +176,7 @@
public static final Element createImage(final Document doc,
final String ref, final float width, final float height) {
- final Element border = doc.createElementNS(svgNS, "image");
+ final Element border = doc.createElementNS(SVGUtilities.svgNS, "image");
border.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href",
ref);
border.setAttributeNS(null, "width", "" + width);
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-09-06 00:28:17 UTC (rev 7929)
+++ trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java 2006-09-06 01:11:32 UTC (rev 7930)
@@ -77,8 +77,8 @@
private StringBuffer decoData[];
private float textCPI = 16.67f;
private float textLPI = 8;
- private int maxX = (int)(8.5f * textCPI + 1);
- private int maxY = (int)(11f * textLPI + 1);
+ private int maxX = (int)(8.5f * this.textCPI + 1);
+ private int maxY = (int)(11f * this.textLPI + 1);
private float xFactor;
private float yFactor;
@@ -98,11 +98,11 @@
}
void addStr(int row, int col, String str, final boolean ischar) {
- if (debug) {
+ if (this.debug) {
getLogger().info("TXTRenderer.addStr(" + row + ", " + col
+ ", \"" + str + "\", " + ischar + ")");
}
- if (suppressGraphics &&!ischar) {
+ if (this.suppressGraphics &&!ischar) {
return;
}
StringBuffer sb;
@@ -110,20 +110,20 @@
row = 0;
}
if (ischar) {
- sb = charData[row];
+ sb = this.charData[row];
} else {
- sb = decoData[row];
+ sb = this.decoData[row];
}
if (sb == null) {
sb = new StringBuffer();
}
- if ((col + str.length()) > maxX) {
- col = maxX - str.length();
+ if ((col + str.length()) > this.maxX) {
+ col = this.maxX - str.length();
}
if (col < 0) {
col = 0;
- if (str.length() > maxX) {
- str = str.substring(0, maxX);
+ if (str.length() > this.maxX) {
+ str = str.substring(0, this.maxX);
}
}
// Pad to col
@@ -142,9 +142,9 @@
}
if (ischar) {
- charData[row] = sb;
+ this.charData[row] = sb;
} else {
- decoData[row] = sb;
+ this.decoData[row] = sb;
}
}
@@ -233,8 +233,9 @@
h *= -1;
}
- final int row = (int)((pageHeight - (y / 100)) * 100 * yFactor);
- final int col = (int)(x * xFactor);
+ final int row = (int)((this.pageHeight - (y / 100)) * 100
+ * this.yFactor);
+ final int col = (int)(x * this.xFactor);
final int lineshade = (int)(100 - ((0.3f * stroke.getRed()
+ 0.59f * stroke.getGreen() + 0.11f * stroke.getBlue())
@@ -256,8 +257,8 @@
if (fillchar != ' ') {
final StringBuffer linefill = new StringBuffer();
- final int sw = (int)(w * xFactor);
- final int sh = (int)(h * yFactor);
+ final int sw = (int)(w * this.xFactor);
+ final int sh = (int)(h * this.yFactor);
if (sw == 0 || sh == 0) {
if (fillshade >= 50) {
if (h > w) {
@@ -297,11 +298,11 @@
hlinechar = '.';
}
final StringBuffer linefill = new StringBuffer();
- final int sw = (int)(w * xFactor);
+ final int sw = (int)(w * this.xFactor);
for (int countr = 0; countr < sw; countr++) {
linefill.append(hlinechar);
}
- final int sh = (int)(h * yFactor);
+ final int sh = (int)(h * this.yFactor);
if (w > h) {
for (int countr = 1; countr < (sh - 1); countr++) {
@@ -348,20 +349,22 @@
getLogger().debug("TXTRenderer.printBMP(" + img + ", " + x
+ ", " + y + ", " + w + ", " + h + ")");
addRect(x, y, w, h, new Color(1f, 1f, 1f), new Color(0f, 0f, 0f));
- final int nameh = (int)(h * yFactor / 2);
+ final int nameh = (int)(h * this.yFactor / 2);
if (nameh > 0) {
- final int namew = (int)(w * xFactor);
+ final int namew = (int)(w * this.xFactor);
if (namew > 4) {
final String iname = img.getURL().toString();
if (iname.length() >= namew) {
- addStr((int)((pageHeight - (y / 100)) * 100 * yFactor)
- + nameh, (int)(x * xFactor),
- iname.substring(iname.length() - namew),
- true);
+ addStr((int)((this.pageHeight - (y / 100)) * 100
+ * this.yFactor)
+ + nameh, (int)(x * this.xFactor),
+ iname.substring(iname.length() - namew),
+ true);
} else {
- addStr((int)((pageHeight - (y / 100)) * 100 * yFactor)
- + nameh, (int)(x * xFactor
+ addStr((int)((this.pageHeight - (y / 100)) * 100
+ * this.yFactor)
+ + nameh, (int)(x * this.xFactor
+ (namew - iname.length())
/ 2), iname, true);
}
@@ -502,7 +505,7 @@
public void startOutput() throws IOException {
getLogger().info("rendering areas to TEXT");
- currentStream = new TXTStream(this.getOutputStream());
+ this.currentStream = new TXTStream(this.getOutputStream());
String encoding;
if (this.getOptions() != null) {
encoding = this.getOptions().optionTXTEncoding();
@@ -511,14 +514,14 @@
} catch (final UnsupportedEncodingException uee) {
getLogger().warn("Encoding '" + encoding
+ "' is not supported, so defaulted to "
- + DEFAULT_ENCODING);
- encoding = DEFAULT_ENCODING;
+ + TXTRenderer.DEFAULT_ENCODING);
+ encoding = TXTRenderer.DEFAULT_ENCODING;
}
} else {
- encoding = DEFAULT_ENCODING;
+ encoding = TXTRenderer.DEFAULT_ENCODING;
}
- currentStream.setEncoding(encoding);
- firstPage=true;
+ this.currentStream.setEncoding(encoding);
+ this.firstPage=true;
}
public void stopOutput() throws IOException {
@@ -527,10 +530,10 @@
}
public void render(final PageArea page) {
- if (firstPage) {
- firstPage = false;
+ if (this.firstPage) {
+ this.firstPage = false;
} else {
- currentStream.add(pageEnding);
+ this.currentStream.add(this.pageEnding);
}
this.getLogger().debug("TXTRenderer.renderPage() page.getHeight() = "
+ page.getHeight());
@@ -589,7 +592,7 @@
this.currentStream.add(this.lineEnding);
}
}
- currentStream.add(lineEnding);
+ this.currentStream.add(this.lineEnding);
}
public void resetTextCursor() {
Modified: trunk/foray/foray-render/src/java/org/foray/render/txt/TXTStream.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/txt/TXTStream.java 2006-09-06 00:28:17 UTC (rev 7929)
+++ trunk/foray/foray-render/src/java/org/foray/render/txt/TXTStream.java 2006-09-06 01:11:32 UTC (rev 7930)
@@ -36,24 +36,24 @@
private String encoding;
public TXTStream(final OutputStream os) {
- out = os;
+ this.out = os;
}
public void add(final String str) {
- if (!doOutput) {
+ if (! this.doOutput) {
return;
}
try {
- final byte buff[] = str.getBytes(encoding);
- out.write(buff);
+ final byte buff[] = str.getBytes(this.encoding);
+ this.out.write(buff);
} catch (final IOException e) {
throw new RuntimeException(e.toString());
}
}
public void setDoOutput(final boolean doout) {
- doOutput = doout;
+ this.doOutput = doout;
}
public void setEncoding(final String encoding) {
Modified: trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java
===================================================================
--- trunk/foray/foray-ren...
[truncated message content] |