diff options
author | Keiron Liddle <keiron@apache.org> | 2001-05-17 07:48:06 +0000 |
---|---|---|
committer | Keiron Liddle <keiron@apache.org> | 2001-05-17 07:48:06 +0000 |
commit | c824ede99cb449252823876b6224f6ed75e799cd (patch) | |
tree | 771770e0d8604c5511de0249b4072817fc483736 /src/org/apache/fop/svg/PDFDocumentGraphics2D.java | |
parent | f89f05c27124377ec9497b30d4d75874a2bec67b (diff) | |
download | xmlgraphics-fop-c824ede99cb449252823876b6224f6ed75e799cd.tar.gz xmlgraphics-fop-c824ede99cb449252823876b6224f6ed75e799cd.zip |
FOP now uses Batik to render svg
This is handled for awt - using batik to render to a graphic
and pdf.
Pdf still requires better image support.
The elements and properties are generated from the svgelements.xml
document.
The version of batik is 17/05/2001 cvs.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194250 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/svg/PDFDocumentGraphics2D.java')
-rw-r--r-- | src/org/apache/fop/svg/PDFDocumentGraphics2D.java | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/src/org/apache/fop/svg/PDFDocumentGraphics2D.java b/src/org/apache/fop/svg/PDFDocumentGraphics2D.java new file mode 100644 index 000000000..37bc930fd --- /dev/null +++ b/src/org/apache/fop/svg/PDFDocumentGraphics2D.java @@ -0,0 +1,120 @@ +/***************************************************************************** + * Copyright (C) The Apache Software Foundation. All rights reserved. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * + *****************************************************************************/ + +package org.apache.fop.svg; + +import org.apache.fop.pdf.*; +import org.apache.fop.layout.*; +import org.apache.fop.fonts.*; +import org.apache.fop.render.pdf.*; +import org.apache.fop.image.*; +import org.apache.fop.datatypes.ColorSpace; + +import org.apache.batik.ext.awt.g2d.*; + +import java.text.AttributedCharacterIterator; +import java.awt.*; +import java.awt.Font; +import java.awt.Image; +import java.awt.image.*; +import java.awt.font.*; +import java.awt.geom.*; +import java.awt.image.renderable.*; +import java.io.*; + +import java.util.Map; + +/** + * This concrete implementation of <tt>AbstractGraphics2D</tt> is a + * simple help to programmers to get started with their own + * implementation of <tt>Graphics2D</tt>. + * <tt>DefaultGraphics2D</tt> implements all the abstract methods + * is <tt>AbstractGraphics2D</tt> and makes it easy to start + * implementing a <tt>Graphic2D</tt> piece-meal. + * + * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a> + * @version $Id$ + * @see org.apache.batik.ext.awt.g2d.AbstractGraphics2D + */ +public class PDFDocumentGraphics2D extends PDFGraphics2D { + OutputStream stream; + + PDFStream pdfStream; + int width; + int height; + + /** + * Create a new PDFGraphics2D with the given pdf document info. + * This is used to create a Graphics object for use inside an already + * existing document. + * Maybe this could be handled as a subclass (PDFDocumentGraphics2d) + */ + public PDFDocumentGraphics2D(boolean textAsShapes, OutputStream stream, int width, int height) + { + super(textAsShapes); + standalone = true; + this.stream = stream; + this.pdfDoc = new PDFDocument(); + this.pdfDoc.setProducer("FOP SVG Renderer"); + pdfStream = this.pdfDoc.makeStream(); + this.width = width; + this.height = height; + + currentFontName = ""; + currentFontSize = 0; + currentYPosition = 0; + currentXPosition = 0; +// fontState = fs; + + currentStream.write("1 0 0 -1 0 " + height + " cm\n"); + + // end part + /* + FontSetup.addToResources(this.pdfDoc, fontInfo); + */ + + } + + public void finish() throws IOException + { + pdfStream.add(getString()); + PDFResources pdfResources = this.pdfDoc.getResources(); + PDFPage currentPage = this.pdfDoc.makePage(pdfResources, pdfStream, + width, + height, null); + this.pdfDoc.output(stream); + + } + + public String getString() { + return currentStream.toString(); + } + + public void setGraphicContext(GraphicContext c) + { + gc = c; + } + + /** + * This constructor supports the create method + */ + public PDFDocumentGraphics2D(PDFDocumentGraphics2D g){ + super(g); + } + + /** + * Creates a new <code>Graphics</code> object that is + * a copy of this <code>Graphics</code> object. + * @return a new graphics context that is a copy of + * this graphics context. + */ + public Graphics create(){ + return new PDFDocumentGraphics2D(this); + } + +} |