1 17 18 19 20 package org.apache.fop.plan; 21 22 import org.apache.fop.fo.FONode; 23 import org.apache.fop.fo.ElementMapping; 24 import org.apache.fop.image.analyser.XMLReader; 25 import org.apache.fop.image.FopImage; 26 import org.w3c.dom.DOMImplementation ; 27 import org.w3c.dom.Document ; 28 29 32 public class PlanElementMapping extends ElementMapping { 33 34 35 public static final String NAMESPACE = "http://xmlgraphics.apache.org/fop/plan"; 36 37 38 public PlanElementMapping() { 39 this.namespaceURI = NAMESPACE; 40 } 41 42 43 public DOMImplementation getDOMImplementation() { 44 return getDefaultDOMImplementation(); 45 } 46 47 48 protected void initialize() { 49 if (foObjs == null) { 50 foObjs = new java.util.HashMap (); 51 foObjs.put("plan", new PE()); 52 foObjs.put(DEFAULT, new PlanMaker()); 53 54 XMLReader.setConverter(this.namespaceURI, new PlanConverter()); 55 } 56 } 57 58 static class PlanMaker extends ElementMapping.Maker { 59 public FONode make(FONode parent) { 60 return new PlanObj(parent); 61 } 62 } 63 64 static class PE extends ElementMapping.Maker { 65 public FONode make(FONode parent) { 66 return new PlanElement(parent); 67 } 68 } 69 70 static class PlanConverter implements XMLReader.Converter { 71 public FopImage.ImageInfo convert(Document doc) { 72 try { 73 PlanRenderer pr = new PlanRenderer(); 74 pr.setFontInfo("Helvetica", 12); 75 FopImage.ImageInfo info = new FopImage.ImageInfo(); 76 info.data = pr.createSVGDocument(doc); 77 info.width = (int)pr.getWidth(); 78 info.height = (int)pr.getHeight(); 79 info.mimeType = "image/svg+xml"; 80 info.str = "http://www.w3.org/2000/svg"; 81 82 return info; 83 } catch (Throwable t) { 84 85 } 86 return null; 87 } 88 } 89 90 } 91 | Popular Tags |