diff options
author | Keiron Liddle <keiron@apache.org> | 2002-03-08 10:12:30 +0000 |
---|---|---|
committer | Keiron Liddle <keiron@apache.org> | 2002-03-08 10:12:30 +0000 |
commit | 8f766d59eba2df9b0600b2fad11b098cb589a64f (patch) | |
tree | c73ee4a80f19aba9285bb9d84ff50940ea58b88d /contrib | |
parent | bf57376925f8f453b52ff920e0c5527cdb6a9a91 (diff) | |
download | xmlgraphics-fop-8f766d59eba2df9b0600b2fad11b098cb589a64f.tar.gz xmlgraphics-fop-8f766d59eba2df9b0600b2fad11b098cb589a64f.zip |
added external image handler
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194695 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/plan/build.sh | 2 | ||||
-rw-r--r-- | contrib/plan/build.xml | 2 | ||||
-rw-r--r-- | contrib/plan/docs/plan.fo | 7 | ||||
-rw-r--r-- | contrib/plan/src/org/apache/fop/plan/Main.java | 7 | ||||
-rw-r--r-- | contrib/plan/src/org/apache/fop/plan/PlanElement.java | 13 | ||||
-rw-r--r-- | contrib/plan/src/org/apache/fop/plan/PlanElementMapping.java | 25 |
6 files changed, 48 insertions, 8 deletions
diff --git a/contrib/plan/build.sh b/contrib/plan/build.sh index ad6ab4854..e8f0cae7e 100755 --- a/contrib/plan/build.sh +++ b/contrib/plan/build.sh @@ -12,7 +12,7 @@ if [ "$JAVA_HOME" = "" ] ; then exit 1 fi LIBDIR=../../lib -LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/classes.zip:$LIBDIR/ant.jar:$LIBDIR/batik.jar:$LIBDIR/buildtools.jar:$LIBDIR/xerces-1.4.3.jar:$LIBDIR/xalan-2.2D11.jar:../../build/fop.jar +LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/classes.zip:$LIBDIR/ant.jar:$LIBDIR/batik.jar:$LIBDIR/buildtools.jar:$LIBDIR/xerces-1.4.3.jar:$LIBDIR/xalan-2.2D11.jar:../../build/fop.jar:$LIBDIR/logkit-1.0.jar ANT_HOME=$LIBDIR echo diff --git a/contrib/plan/build.xml b/contrib/plan/build.xml index 367df26ed..656732c60 100644 --- a/contrib/plan/build.xml +++ b/contrib/plan/build.xml @@ -15,7 +15,7 @@ <property name="name" value="plan"/> <property name="version" value="0.1-CVS"/> <filter token="version" value="${version}"/> - <property name="year" value="2001"/> + <property name="year" value="2002"/> <echo message="------------------- ${Name} ${version} [${year}] ----------------"/> diff --git a/contrib/plan/docs/plan.fo b/contrib/plan/docs/plan.fo index 77f12737b..7a8cd1c50 100644 --- a/contrib/plan/docs/plan.fo +++ b/contrib/plan/docs/plan.fo @@ -101,6 +101,13 @@ All other options are set in the style attribute. </fo:block> + <fo:block> +A plan as an external graphic. + </fo:block> + + <fo:block> +<fo:external-graphic src="june.xml"/> + </fo:block> </fo:flow> </fo:page-sequence> </fo:root> diff --git a/contrib/plan/src/org/apache/fop/plan/Main.java b/contrib/plan/src/org/apache/fop/plan/Main.java index bfc60c418..965a4cc5e 100644 --- a/contrib/plan/src/org/apache/fop/plan/Main.java +++ b/contrib/plan/src/org/apache/fop/plan/Main.java @@ -48,15 +48,12 @@ public class Main { public Document createSVGDocument(InputStream is) { Document doc = null; - Element svgRoot = null; + Element root = null; try { - // DOMImplementation impl = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation(); - // String ns = GraphElementMapping.URI; - // doc = impl.createDocument(ns, "graph", null); doc = javax.xml.parsers.DocumentBuilderFactory.newInstance(). newDocumentBuilder().parse(is); - svgRoot = doc.getDocumentElement(); + root = doc.getDocumentElement(); } catch (Exception e) { e.printStackTrace(); diff --git a/contrib/plan/src/org/apache/fop/plan/PlanElement.java b/contrib/plan/src/org/apache/fop/plan/PlanElement.java index 3cfe450ac..f3e2f97b6 100644 --- a/contrib/plan/src/org/apache/fop/plan/PlanElement.java +++ b/contrib/plan/src/org/apache/fop/plan/PlanElement.java @@ -23,6 +23,7 @@ public class PlanElement extends PlanObj { Document svgDoc = null; float width; float height; + boolean converted; public PlanElement(FONode parent) { super(parent); @@ -34,7 +35,9 @@ public class PlanElement extends PlanObj { } public void convertToSVG() { - if(svgDoc == null && doc != null) { + try { + if(!converted) { + converted = true; PlanRenderer pr = new PlanRenderer(); pr.setFontInfo("Helvetica", 12); svgDoc = pr.createSVGDocument(doc); @@ -43,6 +46,11 @@ public class PlanElement extends PlanObj { doc = svgDoc; } + } catch(Throwable t) { + log.error("Could not convert Plan to SVG", t); + width = 0; + height = 0; + } } @@ -52,6 +60,9 @@ public class PlanElement extends PlanObj { } public String getDocumentNamespace() { + if(svgDoc == null) { + return PlanElementMapping.URI; + } return "http://www.w3.org/2000/svg"; } diff --git a/contrib/plan/src/org/apache/fop/plan/PlanElementMapping.java b/contrib/plan/src/org/apache/fop/plan/PlanElementMapping.java index b12569c04..91c5e5b99 100644 --- a/contrib/plan/src/org/apache/fop/plan/PlanElementMapping.java +++ b/contrib/plan/src/org/apache/fop/plan/PlanElementMapping.java @@ -7,6 +7,9 @@ package org.apache.fop.plan; import org.apache.fop.fo.*; +import org.apache.fop.image.analyser.XMLReader; +import org.apache.fop.image.FopImage; +import org.w3c.dom.Document; import java.util.HashMap; @@ -21,6 +24,8 @@ public class PlanElementMapping implements ElementMapping { foObjs = new HashMap(); foObjs.put("plan", new PE()); foObjs.put(DEFAULT, new PlanMaker()); + + XMLReader.setConverter(URI, new PlanConverter()); } } @@ -41,4 +46,24 @@ public class PlanElementMapping implements ElementMapping { } } + static class PlanConverter implements XMLReader.Converter { + public FopImage.ImageInfo convert(Document doc) { + try { + PlanRenderer pr = new PlanRenderer(); + pr.setFontInfo("Helvetica", 12); + FopImage.ImageInfo info = new FopImage.ImageInfo(); + info.data = pr.createSVGDocument(doc); + info.width = (int)pr.getWidth(); + info.height = (int)pr.getHeight(); + info.mimeType = "image/svg+xml"; + info.str = "http://www.w3.org/2000/svg"; + + return info; + } catch(Throwable t) { + } + return null; + + } + } + } |