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
<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}] ----------------"/>
</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>
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();
Document svgDoc = null;
float width;
float height;
+ boolean converted;
public PlanElement(FONode parent) {
super(parent);
}
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);
doc = svgDoc;
}
+ } catch(Throwable t) {
+ log.error("Could not convert Plan to SVG", t);
+ width = 0;
+ height = 0;
+ }
}
}
public String getDocumentNamespace() {
+ if(svgDoc == null) {
+ return PlanElementMapping.URI;
+ }
return "http://www.w3.org/2000/svg";
}
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;
foObjs = new HashMap();
foObjs.put("plan", new PE());
foObjs.put(DEFAULT, new PlanMaker());
+
+ XMLReader.setConverter(URI, new PlanConverter());
}
}
}
}
+ 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;
+
+ }
+ }
+
}