diff options
Diffstat (limited to 'src/org/apache/fop/render')
-rw-r--r-- | src/org/apache/fop/render/PrintRenderer.java | 150 | ||||
-rw-r--r-- | src/org/apache/fop/render/Renderer.java | 8 | ||||
-rw-r--r-- | src/org/apache/fop/render/awt/AWTRenderer.java | 83 | ||||
-rw-r--r-- | src/org/apache/fop/render/mif/MIFRenderer.java | 22 | ||||
-rwxr-xr-x | src/org/apache/fop/render/pcl/PCLRenderer.java | 47 | ||||
-rw-r--r-- | src/org/apache/fop/render/pdf/PDFRenderer.java | 52 | ||||
-rw-r--r-- | src/org/apache/fop/render/ps/PSRenderer.java | 29 | ||||
-rwxr-xr-x | src/org/apache/fop/render/txt/TXTRenderer.java | 56 | ||||
-rw-r--r-- | src/org/apache/fop/render/xml/XMLRenderer.java | 21 |
9 files changed, 245 insertions, 223 deletions
diff --git a/src/org/apache/fop/render/PrintRenderer.java b/src/org/apache/fop/render/PrintRenderer.java index 6c67420e6..f1afcde91 100644 --- a/src/org/apache/fop/render/PrintRenderer.java +++ b/src/org/apache/fop/render/PrintRenderer.java @@ -140,7 +140,7 @@ public abstract class PrintRenderer implements Renderer { * @param g the green component * @param b the blue component */ - protected abstract void addLine(int x1, int y1, int x2, int y2, int th, + protected abstract void addLine(int x1, int y1, int x2, int y2, int th, PDFPathPaint stroke); /** @@ -156,7 +156,7 @@ public abstract class PrintRenderer implements Renderer { * @param g the green component * @param b the blue component */ - protected abstract void addLine(int x1, int y1, int x2, int y2, int th, + protected abstract void addLine(int x1, int y1, int x2, int y2, int th, int rs, PDFPathPaint stroke); /** @@ -168,7 +168,7 @@ public abstract class PrintRenderer implements Renderer { * @param h the height in millipoints * @param stroke the stroke color/gradient */ - protected abstract void addRect(int x, int y, int w, int h, + protected abstract void addRect(int x, int y, int w, int h, PDFPathPaint stroke); /** @@ -181,7 +181,7 @@ public abstract class PrintRenderer implements Renderer { * @param fill the fill color/gradient * @param stroke the stroke color/gradient */ - protected abstract void addRect(int x, int y, int w, int h, + protected abstract void addRect(int x, int y, int w, int h, PDFPathPaint stroke, PDFPathPaint fill); /** @@ -195,10 +195,10 @@ public abstract class PrintRenderer implements Renderer { * @param h the height in millipoints * @param fill the fill color/gradient */ - protected void addFilledRect(int x, int y, int w, int h, + protected void addFilledRect(int x, int y, int w, int h, PDFPathPaint fill) { addRect(x, y, w, h, fill, fill); - } + } /** * render area container @@ -218,13 +218,13 @@ public abstract class PrintRenderer implements Renderer { this.currentYPosition -= area.getYPosition(); this.currentAreaContainerXPosition += area.getXPosition(); } else if (area.getPosition() == Position.STATIC) { - this.currentYPosition -= area.getPaddingTop() + this.currentYPosition -= area.getPaddingTop() + area.getBorderTopWidth(); /* * this.currentAreaContainerXPosition += * area.getPaddingLeft() + area.getBorderLeftWidth(); */ - } + } this.currentXPosition = this.currentAreaContainerXPosition; doFrame(area); @@ -233,13 +233,13 @@ public abstract class PrintRenderer implements Renderer { while (e.hasMoreElements()) { Box b = (Box)e.nextElement(); b.render(this); - } + } // Restore previous origin this.currentYPosition = saveY; this.currentAreaContainerXPosition = saveX; if (area.getPosition() == Position.STATIC) { this.currentYPosition -= area.getHeight(); - } + } /** * ** @@ -250,7 +250,7 @@ public abstract class PrintRenderer implements Renderer { * this.currentYPosition -= area.getHeight(); * ** */ - } + } public void renderBodyAreaContainer(BodyAreaContainer area) { int saveY = this.currentYPosition; @@ -263,7 +263,7 @@ public abstract class PrintRenderer implements Renderer { } else if (area.getPosition() == Position.RELATIVE) { this.currentYPosition -= area.getYPosition(); this.currentAreaContainerXPosition += area.getXPosition(); - } + } this.currentXPosition = this.currentAreaContainerXPosition; int w, h; @@ -277,7 +277,7 @@ public abstract class PrintRenderer implements Renderer { // but I do if ((bg != null) && (bg.alpha() == 0)) { this.addRect(rx, ry, w, -h, new PDFColor(bg), new PDFColor(bg)); - } + } // floats & footnotes stuff renderAreaContainer(area.getBeforeFloatReferenceArea()); @@ -288,7 +288,8 @@ public abstract class PrintRenderer implements Renderer { while (e.hasMoreElements()) { Box b = (Box)e.nextElement(); b.render(this); // span areas - } + } + if (area.getPosition() != Position.STATIC) { this.currentYPosition = saveY; @@ -296,15 +297,16 @@ public abstract class PrintRenderer implements Renderer { } else this.currentYPosition -= area.getHeight(); - } + } public void renderSpanArea(SpanArea area) { Enumeration e = area.getChildren().elements(); while (e.hasMoreElements()) { Box b = (Box)e.nextElement(); b.render(this); // column areas - } - } + } + + } private void doFrame(Area area) { int w, h; @@ -325,7 +327,7 @@ public abstract class PrintRenderer implements Renderer { // but I do if ((bg != null) && (bg.alpha() == 0)) { this.addFilledRect(rx, ry, w, -h, new PDFColor(bg)); - } + } // rx = rx - area.getBorderLeftWidth(); // ry = ry + area.getBorderTopWidth(); @@ -359,18 +361,18 @@ public abstract class PrintRenderer implements Renderer { int bottom = area.getBorderBottomWidth(); // If style is solid, use filled rectangles if (top != 0) - addFilledRect(rx, ry, w, top, + addFilledRect(rx, ry, w, top, new PDFColor(bp.getBorderColor(BorderAndPadding.TOP))); if (left != 0) - addFilledRect(rx - left, ry - h - bottom, left, h + top + bottom, + addFilledRect(rx - left, ry - h - bottom, left, h + top + bottom, new PDFColor(bp.getBorderColor(BorderAndPadding.LEFT))); if (right != 0) - addFilledRect(rx + w, ry - h - bottom, right, h + top + bottom, + addFilledRect(rx + w, ry - h - bottom, right, h + top + bottom, new PDFColor(bp.getBorderColor(BorderAndPadding.RIGHT))); if (bottom != 0) - addFilledRect(rx, ry - h - bottom, w, bottom, + addFilledRect(rx, ry - h - bottom, w, bottom, new PDFColor(bp.getBorderColor(BorderAndPadding.BOTTOM))); - } + } /** @@ -381,17 +383,17 @@ public abstract class PrintRenderer implements Renderer { public void renderBlockArea(BlockArea area) { // KLease: Temporary test to fix block positioning // Offset ypos by padding and border widths - this.currentYPosition -= (area.getPaddingTop() + this.currentYPosition -= (area.getPaddingTop() + area.getBorderTopWidth()); doFrame(area); Enumeration e = area.getChildren().elements(); while (e.hasMoreElements()) { Box b = (Box)e.nextElement(); b.render(this); - } - this.currentYPosition -= (area.getPaddingBottom() + } + this.currentYPosition -= (area.getPaddingBottom() + area.getBorderBottomWidth()); - } + } /** * render display space @@ -401,7 +403,7 @@ public abstract class PrintRenderer implements Renderer { public void renderDisplaySpace(DisplaySpace space) { int d = space.getSize(); this.currentYPosition -= d; - } + } /** * render image area @@ -429,39 +431,39 @@ public abstract class PrintRenderer implements Renderer { */ public abstract void renderWordArea(WordArea area); - protected void addWordLines(WordArea area, int rx, int bl, int size, + protected void addWordLines(WordArea area, int rx, int bl, int size, PDFColor theAreaColor) { if (area.getUnderlined()) { int yPos = bl - size / 10; - addLine(rx, yPos, rx + area.getContentWidth(), yPos, size / 14, + addLine(rx, yPos, rx + area.getContentWidth(), yPos, size / 14, theAreaColor); // save position for underlining a following InlineSpace prevUnderlineXEndPos = rx + area.getContentWidth(); prevUnderlineYEndPos = yPos; prevUnderlineSize = size / 14; prevUnderlineColor = theAreaColor; - } + } if (area.getOverlined()) { int yPos = bl + area.getFontState().getAscender() + size / 10; - addLine(rx, yPos, rx + area.getContentWidth(), yPos, size / 14, + addLine(rx, yPos, rx + area.getContentWidth(), yPos, size / 14, theAreaColor); prevOverlineXEndPos = rx + area.getContentWidth(); prevOverlineYEndPos = yPos; prevOverlineSize = size / 14; prevOverlineColor = theAreaColor; - } + } if (area.getLineThrough()) { int yPos = bl + area.getFontState().getAscender() * 3 / 8; - addLine(rx, yPos, rx + area.getContentWidth(), yPos, size / 14, + addLine(rx, yPos, rx + area.getContentWidth(), yPos, size / 14, theAreaColor); prevLineThroughXEndPos = rx + area.getContentWidth(); prevLineThroughYEndPos = yPos; prevLineThroughSize = size / 14; prevLineThroughColor = theAreaColor; - } - } + } + } /** * render inline space @@ -472,29 +474,29 @@ public abstract class PrintRenderer implements Renderer { this.currentXPosition += space.getSize(); if (space.getUnderlined()) { if (prevUnderlineColor != null) { - addLine(prevUnderlineXEndPos, prevUnderlineYEndPos, - prevUnderlineXEndPos + space.getSize(), - prevUnderlineYEndPos, prevUnderlineSize, + addLine(prevUnderlineXEndPos, prevUnderlineYEndPos, + prevUnderlineXEndPos + space.getSize(), + prevUnderlineYEndPos, prevUnderlineSize, prevUnderlineColor); - } - } + } + } if (space.getOverlined()) { if (prevOverlineColor != null) { - addLine(prevOverlineXEndPos, prevOverlineYEndPos, - prevOverlineXEndPos + space.getSize(), - prevOverlineYEndPos, prevOverlineSize, + addLine(prevOverlineXEndPos, prevOverlineYEndPos, + prevOverlineXEndPos + space.getSize(), + prevOverlineYEndPos, prevOverlineSize, prevOverlineColor); - } - } + } + } if (space.getLineThrough()) { if (prevLineThroughColor != null) { - addLine(prevLineThroughXEndPos, prevLineThroughYEndPos, - prevLineThroughXEndPos + space.getSize(), - prevLineThroughYEndPos, prevLineThroughSize, + addLine(prevLineThroughXEndPos, prevLineThroughYEndPos, + prevLineThroughXEndPos + space.getSize(), + prevLineThroughYEndPos, prevLineThroughSize, prevLineThroughColor); - } - } - } + } + } + } /** * render line area @@ -520,13 +522,13 @@ public abstract class PrintRenderer implements Renderer { this.currentYPosition = ry - ia.getYOffset(); } else { this.currentYPosition = ry - area.getPlacementOffset(); - } + } b.render(this); - } + } this.currentYPosition = ry - h; this.currentXPosition = rx; - } + } /** * render page @@ -553,37 +555,37 @@ public abstract class PrintRenderer implements Renderer { if (th != 0) { switch (st) { case org.apache.fop.fo.properties.RuleStyle.DOUBLE: - addLine(rx, ry, rx + w, ry, th / 3, st, - new PDFColor(area.getRed(), area.getGreen(), + addLine(rx, ry, rx + w, ry, th / 3, st, + new PDFColor(area.getRed(), area.getGreen(), area.getBlue())); - addLine(rx, ry + (2 * th / 3), rx + w, ry + (2 * th / 3), - th / 3, st, - new PDFColor(area.getRed(), area.getGreen(), + addLine(rx, ry + (2 * th / 3), rx + w, ry + (2 * th / 3), + th / 3, st, + new PDFColor(area.getRed(), area.getGreen(), area.getBlue())); break; case org.apache.fop.fo.properties.RuleStyle.GROOVE: - addLine(rx, ry, rx + w, ry, th / 2, st, - new PDFColor(area.getRed(), area.getGreen(), + addLine(rx, ry, rx + w, ry, th / 2, st, + new PDFColor(area.getRed(), area.getGreen(), area.getBlue())); - addLine(rx, ry + (th / 2), rx + w, ry + (th / 2), th / 2, st, + addLine(rx, ry + (th / 2), rx + w, ry + (th / 2), th / 2, st, new PDFColor(255, 255, 255)); break; case org.apache.fop.fo.properties.RuleStyle.RIDGE: - addLine(rx, ry, rx + w, ry, th / 2, st, + addLine(rx, ry, rx + w, ry, th / 2, st, new PDFColor(255, 255, 255)); - addLine(rx, ry + (th / 2), rx + w, ry + (th / 2), th / 2, st, - new PDFColor(area.getRed(), area.getGreen(), + addLine(rx, ry + (th / 2), rx + w, ry + (th / 2), th / 2, st, + new PDFColor(area.getRed(), area.getGreen(), area.getBlue())); break; default: - addLine(rx, ry, rx + w, ry, th, st, - new PDFColor(area.getRed(), area.getGreen(), + addLine(rx, ry, rx + w, ry, th, st, + new PDFColor(area.getRed(), area.getGreen(), area.getBlue())); } this.currentXPosition += area.getContentWidth(); this.currentYPosition += th; - } - } + } + } /** * set up the font info @@ -593,16 +595,14 @@ public abstract class PrintRenderer implements Renderer { public void setupFontInfo(FontInfo fontInfo) { this.fontInfo = fontInfo; FontSetup.setup(fontInfo); - } - + } + /** Default start renderer method. This would normally be overridden. (mark-fop@inomial.com). */ public void startRenderer(OutputStream outputStream) - throws IOException - { - } + throws IOException {} /** Default stop renderer method. This would normally be overridden. (mark-fop@inomial.com). diff --git a/src/org/apache/fop/render/Renderer.java b/src/org/apache/fop/render/Renderer.java index c28ffc923..f9bc5946d 100644 --- a/src/org/apache/fop/render/Renderer.java +++ b/src/org/apache/fop/render/Renderer.java @@ -91,7 +91,7 @@ public interface Renderer { */ //public void render(AreaTree areaTree, OutputStream stream) throws IOException, FOPException; public void render(Page page, OutputStream stream) - throws IOException, FOPException; + throws IOException, FOPException; /** * render the given area container @@ -159,9 +159,9 @@ public interface Renderer { public void renderLeaderArea(LeaderArea area); public void startRenderer(OutputStream outputStream) - throws IOException; - + throws IOException; + public void stopRenderer(OutputStream outputStream) - throws IOException; + throws IOException; } diff --git a/src/org/apache/fop/render/awt/AWTRenderer.java b/src/org/apache/fop/render/awt/AWTRenderer.java index 57595eb47..29bef196b 100644 --- a/src/org/apache/fop/render/awt/AWTRenderer.java +++ b/src/org/apache/fop/render/awt/AWTRenderer.java @@ -74,7 +74,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable { protected Color saveColor = null; protected IDReferences idReferences = null; - + /** * Image Object and Graphics Object. The Graphics Object is the Graphics * object that is contained withing the Image Object. @@ -189,10 +189,10 @@ public class AWTRenderer implements Renderer, Printable, Pageable { int y = y1; int height, width; if (x1 == x2) // vertical line - { + { height = y2 - y1; if (height > 0) // y coordinates are reversed between fo and AWT - { + { height = -height; y = y2; } @@ -202,7 +202,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable { x -= width; } } else // horizontal line - { + { width = x2 - x1; if (width < 0) { width = -width; @@ -210,7 +210,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable { } height = th; if (height > 0) // y coordinates are reversed between fo and AWT - { + { height = -height; y -= height; } @@ -239,6 +239,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable { // changed by aml/rlc to use helper function that // corrects for integer roundoff, and to remove 3D effect + protected void addRect(int x, int y, int w, int h, float r, float g, float b) { graphics.setColor(new Color(r, g, b)); @@ -335,33 +336,31 @@ public class AWTRenderer implements Renderer, Printable, Pageable { } public void removePage(int page) { - pageList.removeElementAt(page); + pageList.removeElementAt(page); } - public void render(int aPageNumber) - { - if(aPageNumber >= pageList.size()) - return; - - try{ - render((Page) pageList.elementAt(aPageNumber)); - } catch(IOException e){ - e.printStackTrace(); - // This exception can't occur because we are not dealing with - // any files - } + public void render(int aPageNumber) { + if(aPageNumber >= pageList.size()) + return; + + try { + render((Page) pageList.elementAt(aPageNumber)); + } catch(IOException e) { + e.printStackTrace(); + // This exception can't occur because we are not dealing with + // any files + } + } public void render(Page page, OutputStream stream) - throws IOException - { - pageList.addElement(page); + throws IOException { + pageList.addElement(page); } public void render(Page page) - throws IOException - { - idReferences = page.getIDReferences(); + throws IOException { + idReferences = page.getIDReferences(); pageWidth = (int)((float)page.getWidth() / 1000f + .5); pageHeight = (int)((float)page.getHeight() / 1000f + .5); @@ -464,6 +463,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable { (org.apache.fop.layout.Box)e.nextElement(); b.render(this); // span areas } + } // empty for now @@ -474,6 +474,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable { (org.apache.fop.layout.Box)e.nextElement(); b.render(this); // column areas } + } private void doFrame(org.apache.fop.layout.Area area) { @@ -528,9 +529,9 @@ public class AWTRenderer implements Renderer, Printable, Pageable { borderColor = bp.getBorderColor(BorderAndPadding.RIGHT); addLine(rx + w, ry, rx + w, ry - h, // area.getBorderRightWidth(), borderColor.red(), // corrected aml/rlc - -area.getBorderRightWidth(), borderColor.red(), - borderColor.green(), - borderColor.blue()); + -area.getBorderRightWidth(), borderColor.red(), + borderColor.green(), + borderColor.blue()); } if (area.getBorderBottomWidth() != 0) { @@ -611,7 +612,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable { java.awt.Font f = graphics.getFont(); java.awt.Font smallFont = new java.awt.Font(f.getFontName(), - f.getStyle(), 8); + f.getStyle(), 8); graphics.setFont(smallFont); @@ -630,6 +631,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable { SVGDocument svg = ((SVGImage)img).getSVGDocument(); renderSVGDocument(svg, (int)x, (int)y); } catch (FopImageException e) {} + } else { String urlString = img.getURL(); @@ -657,6 +659,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable { // cannot normally occur because, if URL is wrong, constructing FopImage // will already have failed earlier on } + } } @@ -881,6 +884,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable { // defined in Renderer Interface } + public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException { if (pageIndex >= pageList.size()) @@ -902,7 +906,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable { } public PageFormat getPageFormat(int pageIndex) - throws IndexOutOfBoundsException { + throws IndexOutOfBoundsException { if (pageIndex >= pageList.size()) return null; @@ -929,7 +933,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable { } public Printable getPrintable(int pageIndex) - throws IndexOutOfBoundsException { + throws IndexOutOfBoundsException { return this; } @@ -1060,12 +1064,14 @@ public class AWTRenderer implements Renderer, Printable, Pageable { // application.openLink(uri); } + public Point getClientAreaLocationOnScreen() { return new Point(0, 0); } public void setSVGCursor(java.awt.Cursor cursor) {} + public AffineTransform getTransform() { return currentTransform; } @@ -1088,17 +1094,16 @@ public class AWTRenderer implements Renderer, Printable, Pageable { public void registerExtension(BridgeExtension be) {} + } - + public void startRenderer(OutputStream outputStream) - throws IOException - { - } - + throws IOException {} + + public void stopRenderer(OutputStream outputStream) - throws IOException - { - render(0); + throws IOException { + render(0); } - + } diff --git a/src/org/apache/fop/render/mif/MIFRenderer.java b/src/org/apache/fop/render/mif/MIFRenderer.java index 567d59359..154c73dc7 100644 --- a/src/org/apache/fop/render/mif/MIFRenderer.java +++ b/src/org/apache/fop/render/mif/MIFRenderer.java @@ -113,6 +113,7 @@ public class MIFRenderer implements Renderer { */ public void setProducer(String producer) {} + public void renderAreaContainer(AreaContainer area) { if (area.foCreator != null @@ -228,6 +229,7 @@ public class MIFRenderer implements Renderer { b.render(this); // span areas } + if (area.getPosition() != Position.STATIC) { this.currentYPosition = saveY; this.currentAreaContainerXPosition = saveX; @@ -302,6 +304,7 @@ public class MIFRenderer implements Renderer { Box b = (Box)e.nextElement(); b.render(this); // column areas } + } /** @@ -338,6 +341,7 @@ public class MIFRenderer implements Renderer { */ public void renderForeignObjectArea(ForeignObjectArea area) {} + public void renderWordArea(WordArea area) { String s; s = area.getText(); @@ -482,25 +486,23 @@ public class MIFRenderer implements Renderer { normally be overridden. (mark-fop@inomial.com). */ public void startRenderer(OutputStream outputStream) - throws IOException - { - MessageHandler.logln("rendering areas to MIF"); + throws IOException { + MessageHandler.logln("rendering areas to MIF"); } - + /** Default stop renderer method. This would normally be overridden. (mark-fop@inomial.com) */ public void stopRenderer(OutputStream outputStream) - throws IOException - { - MessageHandler.logln("writing out MIF"); - this.mifDoc.output(outputStream); - outputStream.flush(); + throws IOException { + MessageHandler.logln("writing out MIF"); + this.mifDoc.output(outputStream); + outputStream.flush(); } public void render(Page page, OutputStream outputStream) { - this.renderPage(page); + this.renderPage(page); } } diff --git a/src/org/apache/fop/render/pcl/PCLRenderer.java b/src/org/apache/fop/render/pcl/PCLRenderer.java index 9ccd4f39f..2b1dbbb1a 100755 --- a/src/org/apache/fop/render/pcl/PCLRenderer.java +++ b/src/org/apache/fop/render/pcl/PCLRenderer.java @@ -81,7 +81,7 @@ public class PCLRenderer extends PrintRenderer { * @param producer string indicating application producing PCL */ public void setProducer(String producer) {} - + /** * add a line to the current stream * @@ -286,7 +286,7 @@ public class PCLRenderer extends PrintRenderer { resolution = 75; if (debug) System.out.println("PCLRenderer.printBMP() iscolor = " + iscolor); - // Setup for graphics + // Setup for graphics currentStream.add("\033*t" + resolution + "R\033*r0F\033*r1A"); // Transfer graphics data @@ -300,7 +300,7 @@ public class PCLRenderer extends PrintRenderer { indx = iy * iw; if (iscolor) indx *= 3; - // currentStream.add("\033*b" + bytewidth + "W"); + // currentStream.add("\033*b" + bytewidth + "W"); for (ix = 0; ix < iw; ix++) { if (iscolor) { cr = imgmap[indx++] & 0xFF; @@ -477,6 +477,7 @@ public class PCLRenderer extends PrintRenderer { // currentStream.add("Q\n"); } + public void setFont(String name, float size) { int fontcode = 0; if (name.length() > 1 && name.charAt(0) == 'F') { @@ -490,61 +491,75 @@ public class PCLRenderer extends PrintRenderer { case 1: // F1 = Helvetica // currentStream.add("\033(8U\033(s1p" + (size / 1000) + "v0s0b24580T"); // Arial is more common among PCL5 printers than Helvetica - so use Arial + currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v0s0b16602T"); break; case 2: // F2 = Helvetica Oblique + currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v1s0b16602T"); break; case 3: // F3 = Helvetica Bold + currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v0s3b16602T"); break; case 4: // F4 = Helvetica Bold Oblique + currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v1s3b16602T"); break; case 5: // F5 = Times Roman // currentStream.add("\033(8U\033(s1p" + (size / 1000) + "v0s0b25093T"); // Times New is more common among PCL5 printers than Times - so use Times New + currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v0s0b16901T"); break; case 6: // F6 = Times Italic + currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v1s0b16901T"); break; case 7: // F7 = Times Bold + currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v0s3b16901T"); break; case 8: // F8 = Times Bold Italic + currentStream.add("\033(0N\033(s1p" + (size / 1000) + "v1s3b16901T"); break; case 9: // F9 = Courier + currentStream.add("\033(0N\033(s0p" + (120.01f / (size / 1000.00f)) + "h0s0b4099T"); break; case 10: // F10 = Courier Oblique + currentStream.add("\033(0N\033(s0p" + (120.01f / (size / 1000.00f)) + "h1s0b4099T"); break; case 11: // F11 = Courier Bold + currentStream.add("\033(0N\033(s0p" + (120.01f / (size / 1000.00f)) + "h0s3b4099T"); break; case 12: // F12 = Courier Bold Oblique + currentStream.add("\033(0N\033(s0p" + (120.01f / (size / 1000.00f)) + "h1s3b4099T"); break; case 13: // F13 = Symbol + currentStream.add("\033(19M\033(s1p" + (size / 1000) + "v0s0b16686T"); // currentStream.add("\033(9U\033(s1p" + (size / 1000) + "v0s0b25093T"); // ECMA Latin 1 Symbol Set in Times Roman??? break; case 14: // F14 = Zapf Dingbats + currentStream.add("\033(14L\033(s1p" + (size / 1000) + "v0s0b45101T"); break; @@ -629,8 +644,8 @@ public class PCLRenderer extends PrintRenderer { System.out.println("PCLRenderer.renderPage() paperheight=" + paperheight + " divisions=" + divisions); - // Set top margin. - // float fullmargin = 0; + // Set top margin. + // float fullmargin = 0; if (divisions > 0) fullmargin = paperheight * curdiv / divisions; if (topmargin > 0) @@ -638,9 +653,9 @@ public class PCLRenderer extends PrintRenderer { if (debug) System.out.println("PCLRenderer.renderPage() curdiv=" + curdiv + " fullmargin=" + fullmargin); - // if ( fullmargin > 0 ) - // currentStream.add("\033&l" + (fullmargin / 15f) + "c1e8C"); - // this.currentYPosition = fullmargin * 100; + // if ( fullmargin > 0 ) + // currentStream.add("\033&l" + (fullmargin / 15f) + "c1e8C"); + // this.currentYPosition = fullmargin * 100; if (paperheight > 0) pageHeight = (paperheight / divisions) + fullmargin; @@ -676,7 +691,7 @@ public class PCLRenderer extends PrintRenderer { if (end != null) renderAreaContainer(end); - // End page. + // End page. if (++curdiv == divisions || divisions == -1) { curdiv = 0; currentStream.add("\f"); @@ -709,8 +724,8 @@ public class PCLRenderer extends PrintRenderer { */ } public void startRenderer(OutputStream outputStream) - throws IOException - { MessageHandler.logln("rendering areas to PCL"); + throws IOException { + MessageHandler.logln("rendering areas to PCL"); currentStream = new PCLStream(outputStream); // Set orientation. @@ -726,19 +741,17 @@ public class PCLRenderer extends PrintRenderer { // Reset the margins. currentStream.add("\033" + "9\033&l0E"); } - + public void stopRenderer(OutputStream outputStream) - throws IOException - { + throws IOException { MessageHandler.logln("writing out PCL"); outputStream.flush(); } public void render(Page page, OutputStream outputStream) - throws IOException - { + throws IOException { idReferences = page.getIDReferences(); - this.renderPage(page); + this.renderPage(page); } } diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index 4554ff7e5..70e74a0c6 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -146,17 +146,15 @@ public class PDFRenderer extends PrintRenderer { } public void startRenderer(OutputStream stream) - throws IOException - { - pdfDoc.outputHeader(stream); + throws IOException { + pdfDoc.outputHeader(stream); } public void stopRenderer(OutputStream stream) - throws IOException - { - pdfDoc.outputTrailer(stream); + throws IOException { + pdfDoc.outputTrailer(stream); } - + /** * add a line to the current stream * @@ -280,6 +278,7 @@ public class PDFRenderer extends PrintRenderer { renderSVGDocument(svg, (int)x, (int)y, area.getFontState()); currentStream.add("Q\nBT\n"); } catch (FopImageException e) {} + } else { int xObjectNum = this.pdfDoc.addImage(img); closeText(); @@ -410,10 +409,10 @@ public class PDFRenderer extends PrintRenderer { ctx.putBridge(aBridge); GraphicsNode root; PDFGraphics2D graphics = new PDFGraphics2D(true, fs, pdfDoc, - currentFontName, - currentFontSize, - currentXPosition, - currentYPosition); + currentFontName, + currentFontSize, + currentXPosition, + currentYPosition); graphics.setGraphicContext(new org.apache.batik.ext.awt.g2d.GraphicContext()); graphics.setRenderingHints(rc.getRenderingHints()); aBridge.setPDFGraphics2D(graphics); @@ -490,7 +489,7 @@ public class PDFRenderer extends PrintRenderer { (Font)area.getFontState().getFontInfo().getFonts().get(name); if (f instanceof CIDFont) useMultiByte = true; - // String startText = useMultiByte ? "<FEFF" : "("; + // String startText = useMultiByte ? "<FEFF" : "("; String startText = useMultiByte ? "<" : "("; String endText = useMultiByte ? "> " : ") "; @@ -628,6 +627,7 @@ public class PDFRenderer extends PrintRenderer { // This should never fail } + for (int i = 0; i < uniBytes.length; i++) { int b = (uniBytes[i] < 0) ? (int)(256 + uniBytes[i]) : (int)uniBytes[i]; @@ -671,21 +671,20 @@ public class PDFRenderer extends PrintRenderer { } public void render(Page page, OutputStream outputStream) - throws FOPException, IOException - { - // MessageHandler.logln("rendering single page to PDF"); - this.idReferences = page.getIDReferences(); - this.pdfResources = this.pdfDoc.getResources(); - this.pdfDoc.setIDReferences(idReferences); - this.renderPage(page); + throws FOPException, IOException { + // MessageHandler.logln("rendering single page to PDF"); + this.idReferences = page.getIDReferences(); + this.pdfResources = this.pdfDoc.getResources(); + this.pdfDoc.setIDReferences(idReferences); + this.renderPage(page); - FontSetup.addToResources(this.pdfDoc, fontInfo); + FontSetup.addToResources(this.pdfDoc, fontInfo); - // TODO: this needs to be implemented - renderRootExtensions(page); + // TODO: this needs to be implemented + renderRootExtensions(page); - // MessageHandler.logln("writing out PDF"); - this.pdfDoc.output(outputStream); + // MessageHandler.logln("writing out PDF"); + this.pdfDoc.output(outputStream); } /** @@ -749,7 +748,7 @@ public class PDFRenderer extends PrintRenderer { while (f.hasMoreElements()) { LinkedRectangle lrect = (LinkedRectangle)f.nextElement(); currentAnnotList.addLink(this.pdfDoc.makeLink(lrect.getRectangle(), - dest, linkType)); + dest, linkType)); } } } else { @@ -901,12 +900,14 @@ public class PDFRenderer extends PrintRenderer { // application.openLink(uri); } + public Point getClientAreaLocationOnScreen() { return new Point(0, 0); } public void setSVGCursor(java.awt.Cursor cursor) {} + public AffineTransform getTransform() { return currentTransform; } @@ -929,5 +930,6 @@ public class PDFRenderer extends PrintRenderer { public void registerExtension(BridgeExtension be) {} + } } diff --git a/src/org/apache/fop/render/ps/PSRenderer.java b/src/org/apache/fop/render/ps/PSRenderer.java index bbbe0e748..f0476bee8 100644 --- a/src/org/apache/fop/render/ps/PSRenderer.java +++ b/src/org/apache/fop/render/ps/PSRenderer.java @@ -437,10 +437,10 @@ public class PSRenderer implements Renderer { BridgeContext ctx = new BridgeContext(userAgent, rc); GraphicsNode root; PSGraphics2D graphics = new PSGraphics2D(false, area.getFontState(), - this, currentFontName, - currentFontSize, - currentXPosition, - currentYPosition); + this, currentFontName, + currentFontSize, + currentXPosition, + currentYPosition); graphics.setGraphicContext(new org.apache.batik.ext.awt.g2d.GraphicContext()); graphics.setRenderingHints(rc.getRenderingHints()); try { @@ -452,6 +452,7 @@ public class PSRenderer implements Renderer { // e.printStackTrace(); } + write("grestore"); comment("% --- SVG Area end"); @@ -747,6 +748,7 @@ public class PSRenderer implements Renderer { switch (area.getLeaderPattern()) { case LeaderPattern.SPACE: // NOP + break; case LeaderPattern.RULE: if (area.getRuleStyle() == RuleStyle.NONE) @@ -993,12 +995,14 @@ public class PSRenderer implements Renderer { // application.openLink(uri); } + public Point getClientAreaLocationOnScreen() { return new Point(0, 0); } public void setSVGCursor(java.awt.Cursor cursor) {} + public AffineTransform getTransform() { return currentTransform; } @@ -1021,17 +1025,17 @@ public class PSRenderer implements Renderer { public void registerExtension(BridgeExtension be) {} + } /** Default start renderer method. This would normally be overridden. (mark-fop@inomial.com). - */ + */ public void startRenderer(OutputStream outputStream) - throws IOException - { + throws IOException { MessageHandler.logln("rendering areas to PostScript"); - + this.out = new PSStream(outputStream); write("%!PS-Adobe-3.0"); write("%%Creator: "+this.producer); @@ -1047,14 +1051,13 @@ public class PSRenderer implements Renderer { write("%%EndSetup"); write("FOPFonts begin"); } - + /** Default stop renderer method. This would normally be overridden. (mark-fop@inomial.com). */ public void stopRenderer(OutputStream outputStream) - throws IOException - { + throws IOException { write("%%Trailer"); write("%%EOF"); this.out.flush(); @@ -1062,6 +1065,6 @@ public class PSRenderer implements Renderer { } public void render(Page page, OutputStream outputStream) { - this.renderPage(page); - } + this.renderPage(page); + } } diff --git a/src/org/apache/fop/render/txt/TXTRenderer.java b/src/org/apache/fop/render/txt/TXTRenderer.java index 11b9f31f9..b173ab03c 100755 --- a/src/org/apache/fop/render/txt/TXTRenderer.java +++ b/src/org/apache/fop/render/txt/TXTRenderer.java @@ -96,6 +96,7 @@ public class TXTRenderer extends PrintRenderer { */ public void setProducer(String producer) {} + void addStr(int row, int col, String str, boolean ischar) { if (debug) System.out.println("TXTRenderer.addStr(" + row + ", " + col @@ -734,6 +735,7 @@ public class TXTRenderer extends PrintRenderer { PDFColor fc, PDFColor sc, float sw, boolean close) {} + boolean printBMP(FopImage img, int x, int y, int w, int h) throws FopImageException { if (debug) @@ -750,13 +752,13 @@ public class TXTRenderer extends PrintRenderer { if (iname.length() >= namew) addStr((int)((pageHeight - (y / 100)) * 100 * yFactor) + nameh, (int)(x * xFactor), - iname.substring(iname.length() - namew), - true); + iname.substring(iname.length() - namew), + true); else addStr((int)((pageHeight - (y / 100)) * 100 * yFactor) + nameh, (int)(x * xFactor + (namew - iname.length()) - / 2), iname, true); + / 2), iname, true); } } @@ -868,6 +870,7 @@ public class TXTRenderer extends PrintRenderer { // this.currentYPosition -= area.getEffectiveHeight(); } + void renderSVG(FontState fontState, SVGSVGElement svg, int x, int y) { /* * SVG - Not yet implemented @@ -1607,7 +1610,7 @@ public class TXTRenderer extends PrintRenderer { if (end != null) renderAreaContainer(end); - // Write out the buffers. + // Write out the buffers. for (int row = 0; row <= maxY; row++) { StringBuffer cr = charData[row]; StringBuffer dr = decoData[row]; @@ -1673,35 +1676,32 @@ public class TXTRenderer extends PrintRenderer { */ } public void startRenderer(OutputStream outputStream) - throws IOException - { - MessageHandler.logln("rendering areas to TEXT"); - currentStream = new PCLStream(outputStream); - firstPage=true; + throws IOException { + MessageHandler.logln("rendering areas to TEXT"); + currentStream = new PCLStream(outputStream); + firstPage=true; } - - /** - * In Mark's patch, this is endRenderer - * However, I couldn't see how it builds that way, so - * i changed it. - Steve gears@apache.org - */ + + /** + * In Mark's patch, this is endRenderer + * However, I couldn't see how it builds that way, so + * i changed it. - Steve gears@apache.org + */ public void stopRenderer(OutputStream outputStream) - throws IOException - { + throws IOException { MessageHandler.logln("writing out TEXT"); outputStream.flush(); } - public void render(Page page, OutputStream outputStream) - { - idReferences = page.getIDReferences(); - - if ( firstPage ) - firstPage = false; - else - currentStream.add(pageEnding); - this.renderPage(page); - currentStream.add(lineEnding); - } + public void render(Page page, OutputStream outputStream) { + idReferences = page.getIDReferences(); + + if ( firstPage ) + firstPage = false; + else + currentStream.add(pageEnding); + this.renderPage(page); + currentStream.add(lineEnding); + } } diff --git a/src/org/apache/fop/render/xml/XMLRenderer.java b/src/org/apache/fop/render/xml/XMLRenderer.java index 6aeca10fd..487d2c59c 100644 --- a/src/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/org/apache/fop/render/xml/XMLRenderer.java @@ -70,12 +70,11 @@ public class XMLRenderer implements Renderer { this.producer = producer; } - + public void render(Page page, OutputStream outputStream) - throws IOException - { - this.renderPage(page); - } + throws IOException { + this.renderPage(page); + } /** * write out spaces to make indent @@ -427,30 +426,28 @@ public class XMLRenderer implements Renderer { private boolean isCoarseXml() { return ((Boolean)options.get("fineDetail")).booleanValue(); } - + /** Default start renderer method. This would normally be overridden. (mark-fop@inomial.com). */ public void startRenderer(OutputStream outputStream) - throws IOException - { + throws IOException { MessageHandler.logln("rendering areas to XML"); this.writer = new PrintWriter(outputStream); this.writer.write( "<?xml version=\"1.0\"?>\n<!-- produced by " + this.producer + " -->\n"); writeStartTag("<AreaTree>"); } - + /** Default stop renderer method. This would normally be overridden. (mark-fop@inomial.com). */ public void stopRenderer(OutputStream outputStream) - throws IOException - { + throws IOException { writeEndTag("</AreaTree>"); this.writer.flush(); MessageHandler.errorln("written out XML"); - } + } } |