1 17 18 19 20 package org.apache.fop.plan; 21 22 import java.awt.geom.Point2D ; 23 24 import org.apache.fop.apps.FOPException; 25 import org.apache.fop.fo.FONode; 26 import org.apache.fop.fo.PropertyList; 27 28 import org.w3c.dom.Document ; 29 import org.xml.sax.Attributes ; 30 import org.xml.sax.Locator ; 31 32 35 public class PlanElement extends PlanObj { 36 37 private Document svgDoc = null; 38 private float width; 39 private float height; 40 private boolean converted; 41 42 45 public PlanElement(FONode parent) { 46 super(parent); 47 } 48 49 52 public void processNode(String elementName, Locator locator, 53 Attributes attlist, PropertyList propertyList) 54 throws FOPException { 55 super.processNode(elementName, locator, attlist, propertyList); 56 createBasicDocument(); 57 } 58 59 62 public void convertToSVG() { 63 try { 64 if (!converted) { 65 converted = true; 66 PlanRenderer pr = new PlanRenderer(); 67 pr.setFontInfo("Helvetica", 12); 68 svgDoc = pr.createSVGDocument(doc); 69 width = pr.getWidth(); 70 height = pr.getHeight(); 71 72 doc = svgDoc; 73 } 74 } catch (Throwable t) { 75 getLogger().error("Could not convert Plan to SVG", t); 76 width = 0; 77 height = 0; 78 } 79 80 } 81 82 85 public Document getDOMDocument() { 86 convertToSVG(); 87 return doc; 88 } 89 90 91 public String getNamespaceURI() { 92 if (svgDoc == null) { 93 return PlanElementMapping.NAMESPACE; 94 } 95 return "http://www.w3.org/2000/svg"; 96 } 97 98 101 public Point2D getDimension(Point2D view) { 102 convertToSVG(); 103 return new Point2D.Float (width, height); 104 } 105 } 106 107 | Popular Tags |