diff options
author | William Victor Mote <vmote@apache.org> | 2003-08-14 07:42:59 +0000 |
---|---|---|
committer | William Victor Mote <vmote@apache.org> | 2003-08-14 07:42:59 +0000 |
commit | 1041ea8c48bebd72fe8544906fbff40f43ca70e0 (patch) | |
tree | efce02ef7a3f813f17c5d0af69cd590cf4474582 /src/java/org/apache/fop/render/ps | |
parent | dfadcfe581e7da20c26d08325efa5b40ce63e837 (diff) | |
download | xmlgraphics-fop-1041ea8c48bebd72fe8544906fbff40f43ca70e0.tar.gz xmlgraphics-fop-1041ea8c48bebd72fe8544906fbff40f43ca70e0.zip |
1. create control package
2. move layout.FontInfo to control.Document
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196798 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/ps')
8 files changed, 168 insertions, 164 deletions
diff --git a/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java b/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java index 7ab57905f..c48fe82aa 100644 --- a/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java +++ b/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java @@ -62,7 +62,7 @@ import java.io.IOException; //FOP import org.apache.fop.render.pdf.FontSetup; -import org.apache.fop.layout.FontInfo; +import org.apache.fop.control.Document; /** * This class is a wrapper for the <tt>PSGraphics2D</tt> that @@ -94,7 +94,7 @@ public class PSDocumentGraphics2D extends PSGraphics2D { super(textAsShapes); if (!textAsShapes) { - fontInfo = new FontInfo(); + fontInfo = new Document(); FontSetup.setup(fontInfo, null); //FontState fontState = new FontState("Helvetica", "normal", // FontInfo.NORMAL, 12, 0); @@ -187,7 +187,7 @@ public class PSDocumentGraphics2D extends PSGraphics2D { * Get the font info for this PostScript document. * @return the font information */ - public FontInfo getFontInfo() { + public Document getFontInfo() { return fontInfo; } diff --git a/src/java/org/apache/fop/render/ps/PSGraphics2D.java b/src/java/org/apache/fop/render/ps/PSGraphics2D.java index e5d26327a..068d6272e 100644 --- a/src/java/org/apache/fop/render/ps/PSGraphics2D.java +++ b/src/java/org/apache/fop/render/ps/PSGraphics2D.java @@ -3,34 +3,34 @@ * ============================================================================ * The Apache Software License, Version 1.1 * ============================================================================ - * + * * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. The end-user documentation included with the redistribution, if any, must * include the following acknowledgment: "This product includes software * developed by the Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, if * and wherever such third-party acknowledgments normally appear. - * + * * 4. The names "FOP" and "Apache Software Foundation" must not be used to * endorse or promote products derived from this software without prior * written permission. For written permission, please contact * apache@apache.org. - * + * * 5. Products derived from this software may not be called "Apache", nor may * "Apache" appear in their name, without prior written permission of the * Apache Software Foundation. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -42,12 +42,12 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ============================================================================ - * + * * This software consists of voluntary contributions made by many individuals * on behalf of the Apache Software Foundation and was originally created by * James Tauber <jtauber@jtauber.com>. For more information on the Apache * Software Foundation, please see <http://www.apache.org/>. - */ + */ package org.apache.fop.render.ps; //Java @@ -83,7 +83,7 @@ import java.awt.image.renderable.RenderableImage; import java.io.IOException; // FOP -import org.apache.fop.layout.FontInfo; +import org.apache.fop.control.Document; import org.apache.fop.layout.FontState; // Batik @@ -114,10 +114,10 @@ public class PSGraphics2D extends AbstractGraphics2D { /** Currently valid FontState */ protected FontState fontState; - + /** Overriding FontState */ protected FontState overrideFontState = null; - + /** * the current (internal) font name */ @@ -144,7 +144,7 @@ public class PSGraphics2D extends AbstractGraphics2D { protected Color currentColour = new Color(0, 0, 0); /** FontInfo containing all available fonts */ - protected FontInfo fontInfo; + protected Document fontInfo; /** * Create a new Graphics2D that generates PostScript code. @@ -521,13 +521,13 @@ public class PSGraphics2D extends AbstractGraphics2D { Shape imclip = getClip(); writeClip(imclip); Color c = getColor(); - gen.writeln(gen.formatDouble(c.getRed() / 255.0) + " " - + gen.formatDouble(c.getGreen() / 255.0) + " " + gen.writeln(gen.formatDouble(c.getRed() / 255.0) + " " + + gen.formatDouble(c.getGreen() / 255.0) + " " + gen.formatDouble(c.getBlue() / 255.0) + " setrgbcolor"); - + applyPaint(getPaint(), false); applyStroke(getStroke()); - + gen.writeln("newpath"); PathIterator iter = s.getPathIterator(getTransform()); while (!iter.isDone()) { @@ -554,9 +554,9 @@ public class PSGraphics2D extends AbstractGraphics2D { + " M"); break; case PathIterator.SEG_QUADTO: - gen.writeln(gen.formatDouble(1000 * vals[0]) + " " - + gen.formatDouble(1000 * vals[1]) + " " - + gen.formatDouble(1000 * vals[2]) + " " + gen.writeln(gen.formatDouble(1000 * vals[0]) + " " + + gen.formatDouble(1000 * vals[1]) + " " + + gen.formatDouble(1000 * vals[2]) + " " + gen.formatDouble(1000 * vals[3]) + " QUADTO "); break; case PathIterator.SEG_CLOSE: @@ -606,9 +606,9 @@ public class PSGraphics2D extends AbstractGraphics2D { + " M"); break; case PathIterator.SEG_QUADTO: - gen.writeln(gen.formatDouble(1000 * vals[0]) + " " - + gen.formatDouble(1000 * vals[1]) + " " - + gen.formatDouble(1000 * vals[2]) + " " + gen.writeln(gen.formatDouble(1000 * vals[0]) + " " + + gen.formatDouble(1000 * vals[1]) + " " + + gen.formatDouble(1000 * vals[2]) + " " + gen.formatDouble(1000 * vals[3]) + " QUADTO "); break; case PathIterator.SEG_CLOSE: @@ -689,7 +689,7 @@ public class PSGraphics2D extends AbstractGraphics2D { try { if (stroke instanceof BasicStroke) { BasicStroke bs = (BasicStroke)stroke; - + float[] da = bs.getDashArray(); if (da != null) { gen.writeln("["); @@ -715,7 +715,7 @@ public class PSGraphics2D extends AbstractGraphics2D { gen.writeln(2 + " setlinecap"); break; } - + int lj = bs.getLineJoin(); switch (lj) { case BasicStroke.JOIN_MITER: @@ -730,7 +730,7 @@ public class PSGraphics2D extends AbstractGraphics2D { } float lw = bs.getLineWidth(); gen.writeln(gen.formatDouble(1000 * lw) + " setlinewidth"); - + float ml = bs.getMiterLimit(); gen.writeln(gen.formatDouble(1000 * ml) + " setmiterlimit"); } @@ -834,7 +834,7 @@ public class PSGraphics2D extends AbstractGraphics2D { int siz = gFont.getSize(); String style = gFont.isItalic() ? "italic" : "normal"; String weight = gFont.isBold() ? "bold" : "normal"; - + //try { //fontState = new FontState(n, fontState.getFontMetrics(),siz); //} catch (org.apache.fop.apps.FOPException fope) { @@ -847,10 +847,10 @@ public class PSGraphics2D extends AbstractGraphics2D { Shape imclip = getClip(); writeClip(imclip); Color c = getColor(); - gen.writeln(c.getRed() / 255.0 + " " - + c.getGreen() / 255.0 + " " + gen.writeln(c.getRed() / 255.0 + " " + + c.getGreen() / 255.0 + " " + c.getBlue() / 255.0 + " setrgbcolor"); - + AffineTransform trans = getTransform(); trans.translate(x, y); double[] vals = new double[6]; @@ -859,10 +859,10 @@ public class PSGraphics2D extends AbstractGraphics2D { + gen.formatDouble(1000 * vals[5]) + " moveto "); //String fontWeight = fontState.getFontWeight(); StringBuffer sb = new StringBuffer(); - + int l = s.length(); - if ((currentFontName != fontState.getFontName()) + if ((currentFontName != fontState.getFontName()) || (currentFontSize != fontState.getFontSize())) { gen.writeln(fontState.getFontName() + " " + fontState.getFontSize() + " F"); currentFontName = fontState.getFontName(); @@ -886,7 +886,7 @@ public class PSGraphics2D extends AbstractGraphics2D { psString = " (" + sb.toString() + ") " + " t "; gen.writeln(" 1.0 -1.0 scale"); - gen.writeln(psString); + gen.writeln(psString); gen.writeln(" 1.0 -1.0 scale"); } catch (IOException ioe) { handleIOException(ioe); @@ -922,7 +922,7 @@ public class PSGraphics2D extends AbstractGraphics2D { float y) { try { System.err.println("drawString(AttributedCharacterIterator)"); - + gen.writeln("BT"); Shape imclip = getClip(); writeClip(imclip); @@ -932,16 +932,16 @@ public class PSGraphics2D extends AbstractGraphics2D { c = getBackground(); Color col = new Color(c.getRed(), c.getGreen(), c.getBlue()); //gen.writeln(col.getColorSpaceOut(false)); - + AffineTransform trans = getTransform(); trans.translate(x, y); double[] vals = new double[6]; trans.getMatrix(vals); - + for (char ch = iterator.first(); ch != CharacterIterator.DONE; ch = iterator.next()) { //Map attr = iterator.getAttributes(); - + gen.writeln(gen.formatDouble(vals[0]) + " " + gen.formatDouble(vals[1]) + " " + gen.formatDouble(vals[2]) + " " @@ -951,7 +951,7 @@ public class PSGraphics2D extends AbstractGraphics2D { + gen.formatDouble(vals[6]) + " Tm [" + ch + "]"); } - + gen.writeln("ET"); } catch (IOException ioe) { handleIOException(ioe); @@ -982,9 +982,9 @@ public class PSGraphics2D extends AbstractGraphics2D { gen.writeln(gen.formatDouble(c.getRed() / 255.0) + " " + gen.formatDouble(c.getGreen() / 255.0) + " " + gen.formatDouble(c.getBlue() / 255.0) + " setrgbcolor"); - + applyPaint(getPaint(), true); - + gen.writeln("newpath"); PathIterator iter = s.getPathIterator(getTransform()); while (!iter.isDone()) { @@ -1011,9 +1011,9 @@ public class PSGraphics2D extends AbstractGraphics2D { + " M"); break; case PathIterator.SEG_QUADTO: - gen.writeln(gen.formatDouble(1000 * vals[0]) + " " - + gen.formatDouble(1000 * vals[1]) + " " - + gen.formatDouble(1000 * vals[2]) + " " + gen.writeln(gen.formatDouble(1000 * vals[0]) + " " + + gen.formatDouble(1000 * vals[1]) + " " + + gen.formatDouble(1000 * vals[2]) + " " + gen.formatDouble(1000 * vals[3]) + " QUADTO "); break; case PathIterator.SEG_CLOSE: @@ -1039,7 +1039,7 @@ public class PSGraphics2D extends AbstractGraphics2D { * @param nonzero ??? * @exception IOException In case of an I/O problem */ - protected void doDrawing(boolean fill, boolean stroke, boolean nonzero) + protected void doDrawing(boolean fill, boolean stroke, boolean nonzero) throws IOException { if (fill) { if (stroke) { @@ -1091,7 +1091,7 @@ public class PSGraphics2D extends AbstractGraphics2D { public void setOverrideFontState(FontState infont) { overrideFontState = infont; } - + /** * Gets the font metrics for the specified font. * @return the font metrics for the specified font. diff --git a/src/java/org/apache/fop/render/ps/PSProcSets.java b/src/java/org/apache/fop/render/ps/PSProcSets.java index 870490446..dadfaae19 100644 --- a/src/java/org/apache/fop/render/ps/PSProcSets.java +++ b/src/java/org/apache/fop/render/ps/PSProcSets.java @@ -56,7 +56,7 @@ import java.util.Map; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.Glyphs; -import org.apache.fop.layout.FontInfo; +import org.apache.fop.control.Document; /** * This class defines the basic resources (procsets) used by FOP's PostScript @@ -209,7 +209,7 @@ public final class PSProcSets { * @param fontInfo available fonts * @throws IOException in case of an I/O problem */ - public static void writeFontDict(PSGenerator gen, FontInfo fontInfo) + public static void writeFontDict(PSGenerator gen, Document fontInfo) throws IOException { gen.writeln("%%BeginResource: procset FOPFonts"); gen.writeln("%%Title: Font setup (shortcuts) for this file"); diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java index 191f46ee3..180bb766f 100644 --- a/src/java/org/apache/fop/render/ps/PSRenderer.java +++ b/src/java/org/apache/fop/render/ps/PSRenderer.java @@ -3,34 +3,34 @@ * ============================================================================ * The Apache Software License, Version 1.1 * ============================================================================ - * + * * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. The end-user documentation included with the redistribution, if any, must * include the following acknowledgment: "This product includes software * developed by the Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, if * and wherever such third-party acknowledgments normally appear. - * + * * 4. The names "FOP" and "Apache Software Foundation" must not be used to * endorse or promote products derived from this software without prior * written permission. For written permission, please contact * apache@apache.org. - * + * * 5. Products derived from this software may not be called "Apache", nor may * "Apache" appear in their name, without prior written permission of the * Apache Software Foundation. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -42,12 +42,12 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ============================================================================ - * + * * This software consists of voluntary contributions made by many individuals * on behalf of the Apache Software Foundation and was originally created by * James Tauber <jtauber@jtauber.com>. For more information on the Apache * Software Foundation, please see <http://www.apache.org/>. - */ + */ package org.apache.fop.render.ps; // Java @@ -73,7 +73,7 @@ import org.apache.fop.area.inline.Word; import org.apache.fop.datatypes.ColorType; import org.apache.fop.fo.FOUserAgent; import org.apache.fop.fonts.Font; -import org.apache.fop.layout.FontInfo; +import org.apache.fop.control.Document; import org.apache.fop.render.AbstractRenderer; import org.apache.fop.render.RendererContext; @@ -81,7 +81,9 @@ import org.apache.fop.image.FopImage; import org.apache.fop.image.ImageFactory; import org.apache.fop.traits.BorderProps; -import org.w3c.dom.Document; +/* org.w3c.dom.Document is not imported to avoid conflict with + org.apache.fop.control.Document */ + /** * Renderer that renders to PostScript. * <br> @@ -96,7 +98,7 @@ import org.w3c.dom.Document; * <br> * The PS renderer operates in millipoints as the layout engine. Since PostScript * initially uses points, scaling is applied as needed. - * + * * @author <a href="mailto:fop-dev@xml.apache.org">Apache XML FOP Development Team</a> * @author <a href="mailto:jeremias@apache.org">Jeremias Maerki</a> * @version $Id: PSRenderer.java,v 1.31 2003/03/11 08:42:24 jeremias Exp $ @@ -122,7 +124,7 @@ public class PSRenderer extends AbstractRenderer { private float currGreen; private float currBlue; - private FontInfo fontInfo; + private Document fontInfo; /** * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration) @@ -131,7 +133,7 @@ public class PSRenderer extends AbstractRenderer { super.configure(cfg); this.autoRotateLandscape = cfg.getChild("auto-rotate-landscape").getValueAsBoolean(false); } - + /** * @see org.apache.fop.render.Renderer#setUserAgent(FOUserAgent) */ @@ -201,7 +203,7 @@ public class PSRenderer extends AbstractRenderer { handleIOTrouble(ioe); } } - + /** Restores the last graphics state of the rendering engine. */ public void restoreGraphicsState() { try { @@ -211,12 +213,12 @@ public class PSRenderer extends AbstractRenderer { handleIOTrouble(ioe); } } - + /** Indicates the beginning of a text object. */ protected void beginTextObject() { writeln("BT"); } - + /** Indicates the end of a text object. */ protected void endTextObject() { writeln("ET"); @@ -232,7 +234,7 @@ public class PSRenderer extends AbstractRenderer { * @param f F part */ protected void concatMatrix(double a, double b, - double c, double d, + double c, double d, double e, double f) { try { gen.concatMatrix(a, b, c, d, e, f); @@ -240,7 +242,7 @@ public class PSRenderer extends AbstractRenderer { handleIOTrouble(ioe); } } - + /** * Concats the transformations matrix. * @param matrix Matrix to use @@ -252,13 +254,13 @@ public class PSRenderer extends AbstractRenderer { handleIOTrouble(ioe); } } - + /** * Set up the font info * * @param fontInfo the font info object to set up */ - public void setupFontInfo(FontInfo fontInfo) { + public void setupFontInfo(Document fontInfo) { /* use PDF's font setup to get PDF metrics */ org.apache.fop.render.pdf.FontSetup.setup(fontInfo, null); this.fontInfo = fontInfo; @@ -338,22 +340,22 @@ public class PSRenderer extends AbstractRenderer { //Setup for PostScript generation this.gen = new PSGenerator(outputStream); this.currentPageNumber = 0; - + //PostScript Header writeln(DSCConstants.PS_ADOBE_30); gen.writeDSCComment(DSCConstants.CREATOR, new String[] {"FOP " + this.producer}); gen.writeDSCComment(DSCConstants.CREATION_DATE, new Object[] {new java.util.Date()}); gen.writeDSCComment(DSCConstants.PAGES, new Object[] {PSGenerator.ATEND}); gen.writeDSCComment(DSCConstants.END_COMMENTS); - + //Defaults gen.writeDSCComment(DSCConstants.BEGIN_DEFAULTS); gen.writeDSCComment(DSCConstants.END_DEFAULTS); - + //Prolog gen.writeDSCComment(DSCConstants.BEGIN_PROLOG); gen.writeDSCComment(DSCConstants.END_PROLOG); - + //Setup gen.writeDSCComment(DSCConstants.BEGIN_SETUP); PSProcSets.writeFOPStdProcSet(gen); @@ -379,9 +381,9 @@ public class PSRenderer extends AbstractRenderer { public void renderPage(PageViewport page) throws IOException, FOPException { getLogger().debug("renderPage(): " + page); - + this.currentPageNumber++; - gen.writeDSCComment(DSCConstants.PAGE, new Object[] + gen.writeDSCComment(DSCConstants.PAGE, new Object[] {page.getPageNumber(), new Integer(this.currentPageNumber)}); final Integer zero = new Integer(0); @@ -416,22 +418,22 @@ public class PSRenderer extends AbstractRenderer { new Double(pspageheight)}); if (this.autoRotateLandscape) { gen.writeDSCComment(DSCConstants.PAGE_ORIENTATION, "Portrait"); - } + } } - gen.writeDSCComment(DSCConstants.BEGIN_PAGE_SETUP); + gen.writeDSCComment(DSCConstants.BEGIN_PAGE_SETUP); if (rotate) { gen.writeln(Math.round(pspageheight) + " 0 translate"); gen.writeln("90 rotate"); } gen.writeln("0.001 0.001 scale"); concatMatrix(1, 0, 0, -1, 0, pageheight); - - gen.writeDSCComment(DSCConstants.END_PAGE_SETUP); - + + gen.writeDSCComment(DSCConstants.END_PAGE_SETUP); + //Process page super.renderPage(page); - - writeln("showpage"); + + writeln("showpage"); gen.writeDSCComment(DSCConstants.PAGE_TRAILER); gen.writeDSCComment(DSCConstants.END_PAGE); } @@ -446,7 +448,7 @@ public class PSRenderer extends AbstractRenderer { protected void paintText(int rx, int bl, String text, Font font) { saveGraphicsState(); writeln("1 0 0 -1 " + rx + " " + bl + " Tm"); - + int initialSize = text.length(); initialSize += initialSize / 2; StringBuffer sb = new StringBuffer(initialSize); @@ -470,19 +472,19 @@ public class PSRenderer extends AbstractRenderer { // This assumes that *all* CIDFonts use a /ToUnicode mapping Font f = (Font)fontInfo.getFonts().get(fontname); - + //Determine position int rx = currentBlockIPPosition; int bl = currentBPPosition + area.getOffset(); useFont(fontname, fontsize); - + paintText(rx, bl, area.getWord(), f); /* String psString = null; if (area.getFontState().getLetterSpacing() > 0) { - //float f = area.getFontState().getLetterSpacing() + //float f = area.getFontState().getLetterSpacing() // * 1000 / this.currentFontSize; float f = area.getFontState().getLetterSpacing(); psString = (new StringBuffer().append(f).append(" 0.0 (") @@ -620,7 +622,7 @@ public class PSRenderer extends AbstractRenderer { } currentFontName = saveFontName; } - + /** * @see org.apache.fop.render.AbstractRenderer#startVParea(CTM) */ @@ -628,15 +630,15 @@ public class PSRenderer extends AbstractRenderer { // Set the given CTM in the graphics state //currentState.push(); //currentState.setTransform(new AffineTransform(CTMHelper.toPDFArray(ctm))); - + saveGraphicsState(); // multiply with current CTM //writeln(CTMHelper.toPDFString(ctm) + " cm\n"); final double[] matrix = ctm.toArray(); concatMatrix(matrix); - + // Set clip? - beginTextObject(); + beginTextObject(); } /** @@ -695,7 +697,7 @@ public class PSRenderer extends AbstractRenderer { * @param height the height of the area */ protected void drawBackAndBorders(Area block, - float startx, float starty, + float startx, float starty, float width, float height) { // draw background then border @@ -821,10 +823,10 @@ public class PSRenderer extends AbstractRenderer { writeln(startx + " " + starty + " M "); writeln(endx + " " + endy + " lineto"); } - + private void updateColor(ColorType col, boolean fill, StringBuffer pdf) { - writeln(gen.formatDouble(col.getRed()) + " " - + gen.formatDouble(col.getGreen()) + " " + writeln(gen.formatDouble(col.getRed()) + " " + + gen.formatDouble(col.getGreen()) + " " + gen.formatDouble(col.getBlue()) + " setrgbcolor"); } @@ -832,7 +834,7 @@ public class PSRenderer extends AbstractRenderer { * @see org.apache.fop.render.AbstractRenderer#renderForeignObject(ForeignObject, Rectangle2D) */ public void renderForeignObject(ForeignObject fo, Rectangle2D pos) { - Document doc = fo.getDocument(); + org.w3c.dom.Document doc = fo.getDocument(); String ns = fo.getNameSpace(); renderDocument(doc, ns, pos); } @@ -843,7 +845,7 @@ public class PSRenderer extends AbstractRenderer { * @param ns Namespace for the XML document * @param pos Position for the generated graphic/image */ - public void renderDocument(Document doc, String ns, Rectangle2D pos) { + public void renderDocument(org.w3c.dom.Document doc, String ns, Rectangle2D pos) { RendererContext context; context = new RendererContext(MIME_TYPE); context.setUserAgent(userAgent); @@ -859,13 +861,13 @@ public class PSRenderer extends AbstractRenderer { context.setProperty(PSXMLHandler.PS_YPOS, new Integer(currentBPPosition + (int) pos.getY())); //context.setProperty("strokeSVGText", options.get("strokeSVGText")); - + /* context.setProperty(PDFXMLHandler.PDF_DOCUMENT, pdfDoc); context.setProperty(PDFXMLHandler.OUTPUT_STREAM, ostream); context.setProperty(PDFXMLHandler.PDF_STATE, currentState); context.setProperty(PDFXMLHandler.PDF_PAGE, currentPage); - context.setProperty(PDFXMLHandler.PDF_CONTEXT, + context.setProperty(PDFXMLHandler.PDF_CONTEXT, currentContext == null ? currentPage: currentContext); context.setProperty(PDFXMLHandler.PDF_CONTEXT, currentContext); context.setProperty(PDFXMLHandler.PDF_STREAM, currentStream); @@ -881,12 +883,12 @@ public class PSRenderer extends AbstractRenderer { new Integer((int) pos.getWidth())); context.setProperty(PDFXMLHandler.PDF_HEIGHT, new Integer((int) pos.getHeight())); - */ + */ userAgent.renderXML(context, doc, ns); } - + } diff --git a/src/java/org/apache/fop/render/ps/PSTextElementBridge.java b/src/java/org/apache/fop/render/ps/PSTextElementBridge.java index e7bc31fe8..d2db5233a 100644 --- a/src/java/org/apache/fop/render/ps/PSTextElementBridge.java +++ b/src/java/org/apache/fop/render/ps/PSTextElementBridge.java @@ -3,34 +3,34 @@ * ============================================================================ * The Apache Software License, Version 1.1 * ============================================================================ - * + * * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. The end-user documentation included with the redistribution, if any, must * include the following acknowledgment: "This product includes software * developed by the Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, if * and wherever such third-party acknowledgments normally appear. - * + * * 4. The names "FOP" and "Apache Software Foundation" must not be used to * endorse or promote products derived from this software without prior * written permission. For written permission, please contact * apache@apache.org. - * + * * 5. Products derived from this software may not be called "Apache", nor may * "Apache" appear in their name, without prior written permission of the * Apache Software Foundation. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -42,12 +42,12 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ============================================================================ - * + * * This software consists of voluntary contributions made by many individuals * on behalf of the Apache Software Foundation and was originally created by * James Tauber <jtauber@jtauber.com>. For more information on the Apache * Software Foundation, please see <http://www.apache.org/>. - */ + */ package org.apache.fop.render.ps; //import org.apache.batik.gvt.TextNode; @@ -56,7 +56,7 @@ import org.apache.batik.bridge.BridgeContext; //import org.apache.batik.bridge.TextUtilities; import org.apache.batik.gvt.GraphicsNode; -import org.apache.fop.layout.FontInfo; +import org.apache.fop.control.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -70,14 +70,14 @@ import org.w3c.dom.Node; * @version $Id: PSTextElementBridge.java,v 1.2 2003/03/07 09:46:30 jeremias Exp $ */ public class PSTextElementBridge extends SVGTextElementBridge { - + //private PSTextPainter textPainter; /** * Constructs a new bridge for the <text> element. * @param fi the font infomration */ - public PSTextElementBridge(FontInfo fi) { + public PSTextElementBridge(Document fi) { //textPainter = new PSTextPainter(fi); } @@ -127,7 +127,7 @@ public class PSTextElementBridge extends SVGTextElementBridge { } */ - + for (Node n = element.getFirstChild(); n != null; n = n.getNextSibling()) { diff --git a/src/java/org/apache/fop/render/ps/PSTextPainter.java b/src/java/org/apache/fop/render/ps/PSTextPainter.java index d24bedb0a..f357fa283 100644 --- a/src/java/org/apache/fop/render/ps/PSTextPainter.java +++ b/src/java/org/apache/fop/render/ps/PSTextPainter.java @@ -74,7 +74,7 @@ import org.apache.batik.gvt.renderer.StrokingTextPainter; import org.apache.fop.fonts.FontMetrics; import org.apache.fop.layout.FontState; -import org.apache.fop.layout.FontInfo; +import org.apache.fop.control.Document; /** * Renders the attributed character iterator of a <tt>TextNode</tt>. @@ -91,7 +91,7 @@ import org.apache.fop.layout.FontInfo; * @version $Id: PSTextPainter.java,v 1.15 2003/01/08 14:03:55 jeremias Exp $ */ public class PSTextPainter implements TextPainter { - private FontInfo fontInfo; + private Document fontInfo; /** * Use the stroking text painter to get the bounds and shape. @@ -104,7 +104,7 @@ public class PSTextPainter implements TextPainter { * Create a new PS text painter with the given font information. * @param fi the fint info */ - public PSTextPainter(FontInfo fi) { + public PSTextPainter(Document fi) { fontInfo = fi; } @@ -186,11 +186,11 @@ public class PSTextPainter implements TextPainter { String style = ((posture != null) && (posture.floatValue() > 0.0)) ? "italic" : "normal"; int weight = ((taWeight != null) - && (taWeight.floatValue() > 1.0)) ? FontInfo.BOLD - : FontInfo.NORMAL; + && (taWeight.floatValue() > 1.0)) ? Document.BOLD + : Document.NORMAL; FontState fontState = null; - FontInfo fi = fontInfo; + Document fi = fontInfo; boolean found = false; String fontFamily = null; if (gvtFonts != null) { @@ -215,7 +215,7 @@ public class PSTextPainter implements TextPainter { } if (!found) { String fname = - fontInfo.fontLookup("any", style, FontInfo.NORMAL); + fontInfo.fontLookup("any", style, Document.NORMAL); FontMetrics metrics = fontInfo.getMetricsFor(fname); int fsize = (int)(size.floatValue() * 1000); fontState = new FontState(fname, metrics, fsize); @@ -225,7 +225,7 @@ public class PSTextPainter implements TextPainter { } } int fStyle = Font.PLAIN; - if (weight == FontInfo.BOLD) { + if (weight == Document.BOLD) { if (style.equals("italic")) { fStyle = Font.BOLD | Font.ITALIC; } else { diff --git a/src/java/org/apache/fop/render/ps/PSTranscoder.java b/src/java/org/apache/fop/render/ps/PSTranscoder.java index ff23dc6eb..d5be860d3 100644 --- a/src/java/org/apache/fop/render/ps/PSTranscoder.java +++ b/src/java/org/apache/fop/render/ps/PSTranscoder.java @@ -3,34 +3,34 @@ * ============================================================================ * The Apache Software License, Version 1.1 * ============================================================================ - * + * * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. The end-user documentation included with the redistribution, if any, must * include the following acknowledgment: "This product includes software * developed by the Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, if * and wherever such third-party acknowledgments normally appear. - * + * * 4. The names "FOP" and "Apache Software Foundation" must not be used to * endorse or promote products derived from this software without prior * written permission. For written permission, please contact * apache@apache.org. - * + * * 5. Products derived from this software may not be called "Apache", nor may * "Apache" appear in their name, without prior written permission of the * Apache Software Foundation. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -42,12 +42,12 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ============================================================================ - * + * * This software consists of voluntary contributions made by many individuals * on behalf of the Apache Software Foundation and was originally created by * James Tauber <jtauber@jtauber.com>. For more information on the Apache * Software Foundation, please see <http://www.apache.org/>. - */ + */ package org.apache.fop.render.ps; @@ -160,7 +160,7 @@ public class PSTranscoder extends AbstractFOPTranscoder { //AffineTransform currentTransform = new AffineTransform(1, 0, 0, 1, 0, 0); //pdfAElementBridge.setCurrentTransform(currentTransform); //ctx.putBridge(pdfAElementBridge); - + //ctx.putBridge(new PSImageElementBridge()); GraphicsNode gvtRoot; try { @@ -245,13 +245,13 @@ public class PSTranscoder extends AbstractFOPTranscoder { try { graphics.setupDocument(output.getOutputStream(), w, h); graphics.setSVGDimension(docWidth, docHeight); - + if (hints.containsKey(ImageTranscoder.KEY_BACKGROUND_COLOR)) { graphics.setBackgroundColor((Color)hints.get(ImageTranscoder.KEY_BACKGROUND_COLOR)); } graphics.setGraphicContext(new org.apache.batik.ext.awt.g2d.GraphicContext()); graphics.setTransform(px); - + gvtRoot.paint(graphics); graphics.finish(); diff --git a/src/java/org/apache/fop/render/ps/PSXMLHandler.java b/src/java/org/apache/fop/render/ps/PSXMLHandler.java index 3b4ddcdd1..524d05cfa 100644 --- a/src/java/org/apache/fop/render/ps/PSXMLHandler.java +++ b/src/java/org/apache/fop/render/ps/PSXMLHandler.java @@ -3,34 +3,34 @@ * ============================================================================ * The Apache Software License, Version 1.1 * ============================================================================ - * + * * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. The end-user documentation included with the redistribution, if any, must * include the following acknowledgment: "This product includes software * developed by the Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, if * and wherever such third-party acknowledgments normally appear. - * + * * 4. The names "FOP" and "Apache Software Foundation" must not be used to * endorse or promote products derived from this software without prior * written permission. For written permission, please contact * apache@apache.org. - * + * * 5. Products derived from this software may not be called "Apache", nor may * "Apache" appear in their name, without prior written permission of the * Apache Software Foundation. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -42,12 +42,12 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ============================================================================ - * + * * This software consists of voluntary contributions made by many individuals * on behalf of the Apache Software Foundation and was originally created by * James Tauber <jtauber@jtauber.com>. For more information on the Apache * Software Foundation, please see <http://www.apache.org/>. - */ + */ package org.apache.fop.render.ps; // Java @@ -55,7 +55,8 @@ import java.awt.geom.AffineTransform; import java.io.IOException; // DOM -import org.w3c.dom.Document; +/* org.w3c.dom.Document is not imported to avoid conflict with + org.apache.fop.control.Document */ import org.w3c.dom.svg.SVGDocument; import org.w3c.dom.svg.SVGSVGElement; @@ -67,10 +68,10 @@ import org.apache.batik.gvt.GraphicsNode; import org.apache.batik.gvt.TextPainter; // FOP +import org.apache.fop.control.Document; import org.apache.fop.render.XMLHandler; import org.apache.fop.render.RendererContext; import org.apache.fop.svg.SVGUserAgent; -import org.apache.fop.layout.FontInfo; /** * PostScript XML handler. @@ -128,7 +129,7 @@ public class PSXMLHandler implements XMLHandler { * @param ns the namespace of the XML document * @throws Exception any sort of exception could be thrown and shuld be handled */ - public void handleXML(RendererContext context, Document doc, + public void handleXML(RendererContext context, org.w3c.dom.Document doc, String ns) throws Exception { PSInfo psi = getPSInfo(context); @@ -149,7 +150,7 @@ public class PSXMLHandler implements XMLHandler { public static PSInfo getPSInfo(RendererContext context) { PSInfo psi = new PSInfo(); psi.psGenerator = (PSGenerator)context.getProperty(PS_GENERATOR); - psi.fontInfo = (FontInfo)context.getProperty(PS_FONT_INFO); + psi.fontInfo = (org.apache.fop.control.Document)context.getProperty(PS_FONT_INFO); psi.width = ((Integer)context.getProperty(PS_WIDTH)).intValue(); psi.height = ((Integer)context.getProperty(PS_HEIGHT)).intValue(); psi.currentXPosition = ((Integer)context.getProperty(PS_XPOS)).intValue(); @@ -161,11 +162,11 @@ public class PSXMLHandler implements XMLHandler { * PostScript information structure for drawing the XML document. */ public static class PSInfo { - + /** see PS_GENERATOR */ private PSGenerator psGenerator; /** see PS_FONT_INFO */ - private FontInfo fontInfo; + private org.apache.fop.control.Document fontInfo; /** see PS_PAGE_WIDTH */ private int width; /** see PS_PAGE_HEIGHT */ @@ -194,7 +195,7 @@ public class PSXMLHandler implements XMLHandler { * Returns the fontInfo. * @return FontInfo */ - public FontInfo getFontInfo() { + public org.apache.fop.control.Document getFontInfo() { return fontInfo; } @@ -202,7 +203,7 @@ public class PSXMLHandler implements XMLHandler { * Sets the fontInfo. * @param fontInfo The fontInfo to set */ - public void setFontInfo(FontInfo fontInfo) { + public void setFontInfo(org.apache.fop.control.Document fontInfo) { this.fontInfo = fontInfo; } @@ -283,7 +284,8 @@ public class PSXMLHandler implements XMLHandler { * @param doc the svg document * @param psInfo the pdf information of the current context */ - protected void renderSVGDocument(RendererContext context, Document doc, PSInfo psInfo) { + protected void renderSVGDocument(RendererContext context, + org.w3c.dom.Document doc, PSInfo psInfo) { int xOffset = psInfo.currentXPosition; int yOffset = psInfo.currentYPosition; PSGenerator gen = psInfo.psGenerator; @@ -303,9 +305,9 @@ public class PSXMLHandler implements XMLHandler { transform.translate(xOffset / 1000f, yOffset / 1000f); //aBridge.setCurrentTransform(transform); //ctx.putBridge(aBridge); - + TextPainter textPainter = new PSTextPainter(psInfo.getFontInfo()); - ctx.setTextPainter(textPainter); + ctx.setTextPainter(textPainter); GraphicsNode root; try { root = builder.build(ctx, doc); @@ -336,16 +338,16 @@ public class PSXMLHandler implements XMLHandler { // and positive is down and to the right. (0,0) is where the // viewBox puts it. gen.concatMatrix(sx, 0, 0, sy, xOffset, yOffset); - + SVGSVGElement svg = ((SVGDocument)doc).getRootElement(); - AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg, + AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg, w / 1000f, h / 1000f); if (!at.isIdentity()) { double[] vals = new double[6]; at.getMatrix(vals); gen.concatMatrix(vals); } - + /* if (psInfo.pdfContext == null) { psInfo.pdfContext = psInfo.pdfPage; @@ -365,7 +367,7 @@ public class PSXMLHandler implements XMLHandler { context.getUserAgent().getLogger().error("SVG graphic could not be rendered: " + e.getMessage(), e); } - + psInfo.psGenerator.restoreGraphicsState(); //psInfo.pdfState.pop(); gen.writeln("%SVG graphic end ---"); |