[FOray-commit] SF.net SVN: foray: [9731] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-06-08 23:26:29
|
Revision: 9731
http://svn.sourceforge.net/foray/?rev=9731&view=rev
Author: victormote
Date: 2007-06-08 16:26:31 -0700 (Fri, 08 Jun 2007)
Log Message:
-----------
1. Implement new axsl method allowing the GraphicServer to write an SVG document to an output stream.
2. Use new GraphicServer capability to remove a Batik dependency.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java
trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2007-06-08 23:05:50 UTC (rev 9730)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2007-06-08 23:26:31 UTC (rev 9731)
@@ -47,6 +47,10 @@
import org.axsl.graphicR.SVGGraphic;
import org.apache.batik.dom.svg.SVGDOMImplementation;
+import org.apache.batik.transcoder.TranscoderException;
+import org.apache.batik.transcoder.TranscoderInput;
+import org.apache.batik.transcoder.TranscoderOutput;
+import org.apache.batik.transcoder.svg2svg.SVGTranscoder;
import org.apache.commons.logging.Log;
import org.w3c.dom.DOMImplementation;
@@ -56,6 +60,8 @@
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -293,4 +299,22 @@
return (SVGDocument) dom;
}
+ /**
+ * {@inheritDoc}
+ */
+ public void writeSvgDocument(final SVGDocument svgDocument,
+ final OutputStream outputStream) {
+ final SVGTranscoder svgT = new SVGTranscoder();
+ final TranscoderInput input = new TranscoderInput(svgDocument);
+ final OutputStreamWriter osw = new OutputStreamWriter(outputStream);
+ final TranscoderOutput output = new TranscoderOutput(osw);
+ try {
+ svgT.transcode(input, output);
+ } catch (final TranscoderException e) {
+ getLogger().error("could not write svg file :" + e.getMessage());
+ getLogger().error(e.getMessage());
+ }
+
+ }
+
}
Modified: trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2007-06-08 23:05:50 UTC (rev 9730)
+++ trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2007-06-08 23:26:31 UTC (rev 9731)
@@ -51,10 +51,6 @@
import org.axsl.graphicR.GraphicServer;
import org.axsl.graphicR.SVGGraphic;
-import org.apache.batik.transcoder.TranscoderException;
-import org.apache.batik.transcoder.TranscoderInput;
-import org.apache.batik.transcoder.TranscoderOutput;
-import org.apache.batik.transcoder.svg2svg.SVGTranscoder;
import org.apache.commons.logging.Log;
import org.w3c.dom.Document;
@@ -68,7 +64,6 @@
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
-import java.io.OutputStreamWriter;
/**
* A {@link Renderer} implementation that writes the document as SVG.
@@ -76,7 +71,7 @@
public class SVGRenderer extends Renderer {
/** The SVG document being created. */
- private Document svgDocument;
+ private SVGDocument svgDocument;
/** The root element of the SVG document. */
private Element svgRoot;
@@ -633,19 +628,8 @@
public void stopOutput() throws IOException {
this.svgRoot.setAttributeNS(null, "width", "" + this.totalWidth);
this.svgRoot.setAttributeNS(null, "height", "" + this.totalHeight);
-// svgRoot.setAttributeNS(null, "viewBox", "0 0 " + pageWidth + " "
-// + pageHeight);
- final SVGTranscoder svgT = new SVGTranscoder();
- final TranscoderInput input = new TranscoderInput(this.svgDocument);
- final OutputStreamWriter osw = new OutputStreamWriter(
+ this.graphicServer.writeSvgDocument(this.svgDocument,
this.getOutputStream());
- final TranscoderOutput output = new TranscoderOutput(osw);
- try {
- svgT.transcode(input, output);
- } catch (final TranscoderException e) {
- getLogger().error("could not write svg file :" + e.getMessage());
- getLogger().error(e.getMessage());
- }
this.getOutputStream().flush();
this.svgDocument = null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|