1 16 17 package org.apache.batik.test.svg; 18 19 import org.w3c.dom.Document ; 20 import org.w3c.dom.Element ; 21 22 import org.apache.batik.util.SVGConstants; 23 import org.apache.batik.util.XMLConstants; 24 25 26 33 public class SVGTextContentRenderingAccuracyTest 34 extends ParametrizedRenderingAccuracyTest { 35 36 protected String script; protected String onload; protected String parameter; 40 public void setScript(String script){ 41 this.script = script; 42 } 43 44 public void setOnLoadFunction(String onload){ 45 this.onload = onload; 46 } 47 48 public void setParameter(String parameter){ 49 this.parameter = parameter; 50 } 51 52 protected Document manipulateSVGDocument(Document doc) { 53 54 Element root = doc.getDocumentElement(); 55 String function; 56 if ( parameter == null ){ 57 function = onload+"()"; 58 } 59 else{ 60 function = onload+"("+parameter+")"; 61 } 62 root.setAttributeNS(null,"onload",function); 63 64 Element scriptElement = doc.createElementNS 65 (SVGConstants.SVG_NAMESPACE_URI,SVGConstants.SVG_SCRIPT_TAG); 66 67 scriptElement.setAttributeNS 68 (XMLConstants.XLINK_NAMESPACE_URI,SVGConstants.SVG_HREF_ATTRIBUTE, 69 script); 70 71 root.appendChild(scriptElement); 72 73 return doc; 74 } 75 76 } 77 | Popular Tags |