arved 02/04/23 15:33:40 Modified: src/org/apache/fop/render/awt Tag: fop-0_20_2-maintain AWTRenderer.java src/org/apache/fop/render/mif Tag: fop-0_20_2-maintain MIFRenderer.java src/org/apache/fop/render/pcl Tag: fop-0_20_2-maintain PCLRenderer.java src/org/apache/fop/render/pdf Tag: fop-0_20_2-maintain PDFRenderer.java src/org/apache/fop/render/ps Tag: fop-0_20_2-maintain PSRenderer.java src/org/apache/fop/render/svg Tag: fop-0_20_2-maintain SVGRenderer.java src/org/apache/fop/render/txt Tag: fop-0_20_2-maintain TXTRenderer.java Log: support for background-image (all renderers)\nauthor: Michael Gratton Revision Changes Path No revision No revision 1.38.2.2 +41 -8 xml-fop/src/org/apache/fop/render/awt/AWTRenderer.java Index: AWTRenderer.java =================================================================== RCS file: /x1/home/cvs/xml-fop/src/org/apache/fop/render/awt/AWTRenderer.java,v retrieving revision 1.38.2.1 retrieving revision 1.38.2.2 diff -u -r1.38.2.1 -r1.38.2.2 --- AWTRenderer.java 11 Jan 2002 08:45:06 -0000 1.38.2.1 +++ AWTRenderer.java 23 Apr 2002 22:33:39 -0000 1.38.2.2 @@ -1,5 +1,5 @@ /* - * $Id: AWTRenderer.java,v 1.38.2.1 2002/01/11 08:45:06 keiron Exp $ + * $Id: AWTRenderer.java,v 1.38.2.2 2002/04/23 22:33:39 arved Exp $ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. @@ -412,19 +412,13 @@ h = area.getContentHeight(); int ry = this.currentYPosition; - ColorType bg = area.getBackgroundColor(); rx = rx - area.getPaddingLeft(); ry = ry + area.getPaddingTop(); w = w + area.getPaddingLeft() + area.getPaddingRight(); h = h + area.getPaddingTop() + area.getPaddingBottom(); - // I'm not sure I should have to check for bg being null - // but I do - if ((bg != null) && (bg.alpha() == 0)) { - this.addRect(rx, ry, w, -h, bg.red(), bg.green(), bg.blue(), - bg.red(), bg.green(), bg.blue()); - } + doBackground(area, rx, ry, w, h); rx = rx - area.getBorderLeftWidth(); ry = ry + area.getBorderTopWidth(); @@ -486,6 +480,45 @@ this.currentYPosition -= d; } + /** + * Renders an image, scaling it to the given width and height. + * If the scaled width and height is the same intrinsic size + * of the image, the image is not scaled. + * + * @param x the x position of left edge in millipoints + * @param y the y position of top edge in millipoints + * @param w the width in millipoints + * @param h the height in millipoints + * @param image the image to be rendered + * @param fs the font state to use when rendering text + * in non-bitmapped images. + */ + protected void drawImageScaled(int x, int y, int w, int h, + FopImage image, + FontState fs) { + // XXX: implement this + } + + /** + * Renders an image, clipping it as specified. + * + * @param x the x position of left edge in millipoints. + * @param y the y position of top edge in millipoints. + * @param clipX the left edge of the clip in millipoints + * @param clipY the top edge of the clip in millipoints + * @param clipW the clip width in millipoints + * @param clipH the clip height in millipoints + * @param fill the image to be rendered + * @param fs the font state to use when rendering text + * in non-bitmapped images. + */ + protected void drawImageClipped(int x, int y, + int clipX, int clipY, + int clipW, int clipH, + FopImage image, + FontState fs) { + // XXX: implement this + } // correct integer roundoff (aml/rlc) No revision No revision 1.11.2.1 +42 -13 xml-fop/src/org/apache/fop/render/mif/MIFRenderer.java Index: MIFRenderer.java =================================================================== RCS file: /x1/home/cvs/xml-fop/src/org/apache/fop/render/mif/MIFRenderer.java,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -r1.11 -r1.11.2.1 --- MIFRenderer.java 18 Sep 2001 13:06:07 -0000 1.11 +++ MIFRenderer.java 23 Apr 2002 22:33:39 -0000 1.11.2.1 @@ -1,5 +1,5 @@ /* - * $Id: MIFRenderer.java,v 1.11 2001/09/18 13:06:07 keiron Exp $ + * $Id: MIFRenderer.java,v 1.11.2.1 2002/04/23 22:33:39 arved Exp $ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. @@ -12,8 +12,6 @@ // FOP import org.apache.fop.render.Renderer; import org.apache.fop.render.AbstractRenderer; -import org.apache.fop.image.ImageArea; -import org.apache.fop.image.FopImage; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.properties.*; import org.apache.fop.fo.*; @@ -166,22 +164,13 @@ h = area.getContentHeight(); int ry = this.currentYPosition; - ColorType bg = area.getBackgroundColor(); rx = rx - area.getPaddingLeft(); ry = ry + area.getPaddingTop(); w = w + area.getPaddingLeft() + area.getPaddingRight(); h = h + area.getPaddingTop() + area.getPaddingBottom(); - /* - * // I'm not sure I should have to check for bg being null - * // but I do - * if ((bg != null) && (bg.alpha() == 0)) { - * this.addRect(rx, ry, w, -h, - * new PDFColor(bg), - * new PDFColor(bg)); - * } - */ + doBackground(area, rx, ry, w, h); rx = rx - area.getBorderLeftWidth(); ry = ry + area.getBorderTopWidth(); @@ -248,6 +237,46 @@ this.mifDoc.addToStream(s); this.currentXPosition += area.getContentWidth(); + } + + /** + * Renders an image, scaling it to the given width and height. + * If the scaled width and height is the same intrinsic size + * of the image, the image is not scaled. + * + * @param x the x position of left edge in millipoints + * @param y the y position of top edge in millipoints + * @param w the width in millipoints + * @param h the height in millipoints + * @param image the image to be rendered + * @param fs the font state to use when rendering text + * in non-bitmapped images. + */ + protected void drawImageScaled(int x, int y, int w, int h, + FopImage image, + FontState fs) { + // XXX: implement this + } + + /** + * Renders an image, clipping it as specified. + * + * @param x the x position of left edge in millipoints. + * @param y the y position of top edge in millipoints. + * @param clipX the left edge of the clip in millipoints + * @param clipY the top edge of the clip in millipoints + * @param clipW the clip width in millipoints + * @param clipH the clip height in millipoints + * @param fill the image to be rendered + * @param fs the font state to use when rendering text + * in non-bitmapped images. + */ + protected void drawImageClipped(int x, int y, + int clipX, int clipY, + int clipW, int clipH, + FopImage image, + FontState fs) { + // XXX: implement this } /** No revision No revision 1.13.2.1 +41 -3 xml-fop/src/org/apache/fop/render/pcl/PCLRenderer.java Index: PCLRenderer.java =================================================================== RCS file: /x1/home/cvs/xml-fop/src/org/apache/fop/render/pcl/PCLRenderer.java,v retrieving revision 1.13 retrieving revision 1.13.2.1 diff -u -r1.13 -r1.13.2.1 --- PCLRenderer.java 12 Oct 2001 21:36:45 -0000 1.13 +++ PCLRenderer.java 23 Apr 2002 22:33:39 -0000 1.13.2.1 @@ -1,5 +1,5 @@ /* - * $Id: PCLRenderer.java,v 1.13 2001/10/12 21:36:45 artw Exp $ + * $Id: PCLRenderer.java,v 1.13.2.1 2002/04/23 22:33:39 arved Exp $ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. @@ -9,8 +9,6 @@ // FOP import org.apache.fop.render.PrintRenderer; -import org.apache.fop.image.ImageArea; -import org.apache.fop.image.FopImage; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.properties.*; import org.apache.fop.datatypes.*; @@ -244,6 +242,46 @@ } // Reset pattern transparency mode. currentStream.add("\033*v0O"); + } + + /** + * Renders an image, scaling it to the given width and height. + * If the scaled width and height is the same intrinsic size + * of the image, the image is not scaled. + * + * @param x the x position of left edge in millipoints + * @param y the y position of top edge in millipoints + * @param w the width in millipoints + * @param h the height in millipoints + * @param image the image to be rendered + * @param fs the font state to use when rendering text + * in non-bitmapped images. + */ + protected void drawImageScaled(int x, int y, int w, int h, + FopImage image, + FontState fs) { + // XXX: implement this + } + + /** + * Renders an image, clipping it as specified. + * + * @param x the x position of left edge in millipoints. + * @param y the y position of top edge in millipoints. + * @param clipX the left edge of the clip in millipoints + * @param clipY the top edge of the clip in millipoints + * @param clipW the clip width in millipoints + * @param clipH the clip height in millipoints + * @param fill the image to be rendered + * @param fs the font state to use when rendering text + * in non-bitmapped images. + */ + protected void drawImageClipped(int x, int y, + int clipX, int clipY, + int clipW, int clipH, + FopImage image, + FontState fs) { + // XXX: implement this } boolean printBMP(FopImage img, int x, int y, int w, No revision No revision 1.91.2.2 +86 -38 xml-fop/src/org/apache/fop/render/pdf/PDFRenderer.java Index: PDFRenderer.java =================================================================== RCS file: /x1/home/cvs/xml-fop/src/org/apache/fop/render/pdf/PDFRenderer.java,v retrieving revision 1.91.2.1 retrieving revision 1.91.2.2 diff -u -r1.91.2.1 -r1.91.2.2 --- PDFRenderer.java 2 Dec 2001 22:17:30 -0000 1.91.2.1 +++ PDFRenderer.java 23 Apr 2002 22:33:39 -0000 1.91.2.2 @@ -1,5 +1,5 @@ /* - * $Id: PDFRenderer.java,v 1.91.2.1 2001/12/02 22:17:30 tore Exp $ + * $Id: PDFRenderer.java,v 1.91.2.2 2002/04/23 22:33:39 arved Exp $ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. @@ -9,8 +9,8 @@ // FOP import org.apache.fop.render.PrintRenderer; -import org.apache.fop.image.ImageArea; import org.apache.fop.image.FopImage; +import org.apache.fop.image.FopImageException; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.inline.*; @@ -268,43 +268,91 @@ } /** - * render image area to PDF - * - * @param area the image area to render - */ - public void renderImageArea(ImageArea area) { - // adapted from contribution by BoBoGi - int x = this.currentXPosition + area.getXOffset(); - int y = this.currentYPosition; - int w = area.getContentWidth(); - int h = area.getHeight(); - - this.currentYPosition -= h; - - FopImage img = area.getImage(); - if (img instanceof SVGImage) { - try { - closeText(); - - SVGDocument svg = ((SVGImage)img).getSVGDocument(); - currentStream.add("ET\nq\n"); - renderSVGDocument(svg, (int)x, (int)y, area.getFontState()); - currentStream.add("Q\nBT\n"); - } catch (FopImageException e) {} - - } else { - int xObjectNum = this.pdfDoc.addImage(img); - closeText(); - - currentStream.add("ET\nq\n" + (((float)w) / 1000f) + " 0 0 " - + (((float)h) / 1000f) + " " - + (((float)x) / 1000f) + " " - + (((float)(y - h)) / 1000f) + " cm\n" + "/Im" - + xObjectNum + " Do\nQ\nBT\n"); - } - this.currentXPosition += area.getContentWidth(); + * Renders an image, scaling it to the given width and height. + * If the scaled width and height is the same intrinsic size + * of the image, the image is not scaled. + * + * @param x the x position of left edge in millipoints + * @param y the y position of top edge in millipoints + * @param w the width in millipoints + * @param h the height in millipoints + * @param image the image to be rendered + * @param fs the font state to use when rendering text + * in non-bitmapped images. + */ + protected void drawImageScaled(int x, int y, int w, int h, + FopImage image, + FontState fs) { + if (image instanceof SVGImage) { + try { + closeText(); + + SVGDocument svg = ((SVGImage)image).getSVGDocument(); + currentStream.add("ET\nq\n"); + renderSVGDocument(svg, x, y, fs); + currentStream.add("Q\nBT\n"); + } catch (FopImageException e) {} + + } else { + int xObjectNum = this.pdfDoc.addImage(image); + closeText(); + currentStream.add("ET\nq\n" + (((float)w) / 1000f) + " 0 0 " + + (((float)h) / 1000f) + " " + + (((float)x) / 1000f) + " " + + (((float)y - h) / 1000f) + " cm\n" + "/Im" + + xObjectNum + " Do\nQ\nBT\n"); + } + } + + /** + * Renders an image, clipping it as specified. + * + * @param x the x position of left edge in millipoints. + * @param y the y position of top edge in millipoints. + * @param clipX the left edge of the clip in millipoints + * @param clipY the top edge of the clip in millipoints + * @param clipW the clip width in millipoints + * @param clipH the clip height in millipoints + * @param fill the image to be rendered + * @param fs the font state to use when rendering text + * in non-bitmapped images. + */ + protected void drawImageClipped(int x, int y, + int clipX, int clipY, + int clipW, int clipH, + FopImage image, + FontState fs) { + + PDFRectangle clip = new PDFRectangle(clipX / 1000, + clipY / 1000, + (clipX + clipW) / 1000, + (clipY + clipW) / 1000); + + if (image instanceof SVGImage) { + try { + closeText(); + + SVGDocument svg = ((SVGImage)image).getSVGDocument(); + currentStream.add("ET\nq\n"); + renderSVGDocument(svg, x, y, fs); + currentStream.add("Q\nBT\n"); + } catch (FopImageException e) {} + + } else { + int xObjectNum = this.pdfDoc.addImage(image); + closeText(); + currentStream.add("ET\nq\n" + + // image matrix + (((float)clipW) / 1000f) + " 0 0 " + + (((float)clipH) / 1000f) + " " + + (((float)x) / 1000f) + " " + + (((float)y - clipH) / 1000f) + " cm\n" + + "s\n" + + // the image itself + "/Im" + xObjectNum + " Do\nQ\nBT\n"); + } } - + /** * render a foreign object area */ No revision No revision 1.15.2.3 +48 -18 xml-fop/src/org/apache/fop/render/ps/PSRenderer.java Index: PSRenderer.java =================================================================== RCS file: /x1/home/cvs/xml-fop/src/org/apache/fop/render/ps/PSRenderer.java,v retrieving revision 1.15.2.2 retrieving revision 1.15.2.3 diff -u -r1.15.2.2 -r1.15.2.3 --- PSRenderer.java 17 Mar 2002 23:37:07 -0000 1.15.2.2 +++ PSRenderer.java 23 Apr 2002 22:33:40 -0000 1.15.2.3 @@ -1,5 +1,5 @@ /* - * $Id: PSRenderer.java,v 1.15.2.2 2002/03/17 23:37:07 chrisg Exp $ + * $Id: PSRenderer.java,v 1.15.2.3 2002/04/23 22:33:40 arved Exp $ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. @@ -13,8 +13,8 @@ import org.apache.fop.render.Renderer; import org.apache.fop.image.ImageArea; import org.apache.fop.image.FopImage; -import org.apache.fop.image.JpegImage; import org.apache.fop.image.FopImageException; +import org.apache.fop.image.JpegImage; import org.apache.fop.layout.*; import org.apache.fop.layout.inline.*; import org.apache.fop.datatypes.*; @@ -255,6 +255,11 @@ protected void addFilledRect(int x, int y, int w, int h, ColorType col) { + // XXX: cater for braindead, legacy -ve heights + if (h < 0) { + h = -h; + } + write("newpath"); write(x + " " + y + " M"); write(w + " 0 rlineto"); @@ -355,6 +360,46 @@ movetoCurrPosition(); } + /** + * Renders an image, scaling it to the given width and height. + * If the scaled width and height is the same intrinsic size + * of the image, the image is not scaled. + * + * @param x the x position of left edge in millipoints + * @param y the y position of top edge in millipoints + * @param w the width in millipoints + * @param h the height in millipoints + * @param image the image to be rendered + * @param fs the font state to use when rendering text + * in non-bitmapped images. + */ + protected void drawImageScaled(int x, int y, int w, int h, + FopImage image, + FontState fs) { + // XXX: implement this + } + + /** + * Renders an image, clipping it as specified. + * + * @param x the x position of left edge in millipoints. + * @param y the y position of top edge in millipoints. + * @param clipX the left edge of the clip in millipoints + * @param clipY the top edge of the clip in millipoints + * @param clipW the clip width in millipoints + * @param clipH the clip height in millipoints + * @param fill the image to be rendered + * @param fs the font state to use when rendering text + * in non-bitmapped images. + */ + protected void drawImageClipped(int x, int y, + int clipX, int clipY, + int clipW, int clipH, + FopImage image, + FontState fs) { + // XXX: implement this + } + public void renderEPS(FopImage img, int x, int y, int w, int h) { try { EPSImage eimg = (EPSImage)img; @@ -791,22 +836,7 @@ w = w + area.getBorderLeftWidth() + area.getBorderRightWidth(); h = h + area.getBorderTopWidth() + area.getBorderBottomWidth(); - // Create a textrect with these dimensions. - // The y co-ordinate is measured +ve downwards so subtract page-height - - ColorType bg = area.getBackgroundColor(); - if ((bg != null) && (bg.alpha() == 0)) { - write("newpath"); - write(rx + " " + ry + " M"); - write(w + " 0 rlineto"); - write("0 " + (-h) + " rlineto"); - write((-w) + " 0 rlineto"); - write("0 " + h + " rlineto"); - write("closepath"); - useColor(bg); - write("fill"); - } - + doBackground(area, rx, ry, w, h); if (area.getBorderTopWidth() != 0) { write("newpath"); No revision No revision 1.3.2.1 +42 -8 xml-fop/src/org/apache/fop/render/svg/SVGRenderer.java Index: SVGRenderer.java =================================================================== RCS file: /x1/home/cvs/xml-fop/src/org/apache/fop/render/svg/SVGRenderer.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- SVGRenderer.java 15 Oct 2001 07:01:14 -0000 1.3 +++ SVGRenderer.java 23 Apr 2002 22:33:40 -0000 1.3.2.1 @@ -1,5 +1,5 @@ /* - * $Id: SVGRenderer.java,v 1.3 2001/10/15 07:01:14 keiron Exp $ + * $Id: SVGRenderer.java,v 1.3.2.1 2002/04/23 22:33:40 arved Exp $ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. @@ -292,19 +292,13 @@ h = area.getContentHeight(); int ry = this.currentYPosition; - ColorType bg = area.getBackgroundColor(); rx = rx - area.getPaddingLeft(); ry = ry + area.getPaddingTop(); w = w + area.getPaddingLeft() + area.getPaddingRight(); h = h + area.getPaddingTop() + area.getPaddingBottom(); - // I'm not sure I should have to check for bg being null - // but I do - if ((bg != null) && (bg.alpha() == 0)) { - this.addRect(rx, ry, w, h, bg.red(), bg.green(), bg.blue(), - bg.red(), bg.green(), bg.blue()); - } + doBackground(area, rx, ry, w, h); rx = rx - area.getBorderLeftWidth(); ry = ry + area.getBorderTopWidth(); @@ -360,6 +354,46 @@ public void renderDisplaySpace(DisplaySpace space) { int d = space.getSize(); this.currentYPosition -= d; + } + + /** + * Renders an image, scaling it to the given width and height. + * If the scaled width and height is the same intrinsic size + * of the image, the image is not scaled. + * + * @param x the x position of left edge in millipoints + * @param y the y position of top edge in millipoints + * @param w the width in millipoints + * @param h the height in millipoints + * @param image the image to be rendered + * @param fs the font state to use when rendering text + * in non-bitmapped images. + */ + protected void drawImageScaled(int x, int y, int w, int h, + FopImage image, + FontState fs) { + // XXX: implement this + } + + /** + * Renders an image, clipping it as specified. + * + * @param x the x position of left edge in millipoints. + * @param y the y position of top edge in millipoints. + * @param clipX the left edge of the clip in millipoints + * @param clipY the top edge of the clip in millipoints + * @param clipW the clip width in millipoints + * @param clipH the clip height in millipoints + * @param fill the image to be rendered + * @param fs the font state to use when rendering text + * in non-bitmapped images. + */ + protected void drawImageClipped(int x, int y, + int clipX, int clipY, + int clipW, int clipH, + FopImage image, + FontState fs) { + // XXX: implement this } public void renderImageArea(ImageArea area) { No revision No revision 1.12.2.2 +42 -1 xml-fop/src/org/apache/fop/render/txt/TXTRenderer.java Index: TXTRenderer.java =================================================================== RCS file: /x1/home/cvs/xml-fop/src/org/apache/fop/render/txt/TXTRenderer.java,v retrieving revision 1.12.2.1 retrieving revision 1.12.2.2 diff -u -r1.12.2.1 -r1.12.2.2 --- TXTRenderer.java 31 Jan 2002 17:59:49 -0000 1.12.2.1 +++ TXTRenderer.java 23 Apr 2002 22:33:40 -0000 1.12.2.2 @@ -1,5 +1,5 @@ /* - * $Id: TXTRenderer.java,v 1.12.2.1 2002/01/31 17:59:49 artw Exp $ + * $Id: TXTRenderer.java,v 1.12.2.2 2002/04/23 22:33:40 arved Exp $ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. @@ -13,6 +13,8 @@ import org.apache.fop.render.pcl.*; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.properties.*; +import org.apache.fop.image.FopImage; +import org.apache.fop.image.FopImageException; import org.apache.fop.layout.*; import org.apache.fop.layout.inline.*; import org.apache.fop.datatypes.*; @@ -734,6 +736,45 @@ PDFColor fc, PDFColor sc, float sw, boolean close) {} + /** + * Renders an image, scaling it to the given width and height. + * If the scaled width and height is the same intrinsic size + * of the image, the image is not scaled. + * + * @param x the x position of left edge in millipoints + * @param y the y position of top edge in millipoints + * @param w the width in millipoints + * @param h the height in millipoints + * @param image the image to be rendered + * @param fs the font state to use when rendering text + * in non-bitmapped images. + */ + protected void drawImageScaled(int x, int y, int w, int h, + FopImage image, + FontState fs) { + // XXX: implement this + } + + /** + * Renders an image, clipping it as specified. + * + * @param x the x position of left edge in millipoints. + * @param y the y position of top edge in millipoints. + * @param clipX the left edge of the clip in millipoints + * @param clipY the top edge of the clip in millipoints + * @param clipW the clip width in millipoints + * @param clipH the clip height in millipoints + * @param fill the image to be rendered + * @param fs the font state to use when rendering text + * in non-bitmapped images. + */ + protected void drawImageClipped(int x, int y, + int clipX, int clipY, + int clipW, int clipH, + FopImage image, + FontState fs) { + // XXX: implement this + } boolean printBMP(FopImage img, int x, int y, int w, int h) throws FopImageException {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]