1 18 package org.apache.batik.swing; 19 20 import org.apache.batik.test.svg.JSVGRenderingAccuracyTest; 21 import org.apache.batik.util.SVGConstants; 22 import org.apache.batik.dom.GenericDOMImplementation; 23 24 import org.w3c.dom.Document ; 25 import org.w3c.dom.DOMImplementation ; 26 import org.w3c.dom.Element ; 27 28 38 public class SetSVGDocumentTest extends JSVGRenderingAccuracyTest { 39 public SetSVGDocumentTest() { 40 } 41 protected String [] breakSVGFile(String svgFile){ 42 if(svgFile == null) { 43 throw new IllegalArgumentException (svgFile); 44 } 45 46 String [] ret = new String [3]; 47 ret[0] = "test-resources/org/apache/batik/test/svg/"; 48 ret[1] = "SetSVGDocumentTest"; 49 ret[2] = ".svg"; 50 return ret; 51 } 52 53 54 public boolean canvasInit(JSVGCanvas canvas) { 55 DOMImplementation impl = 56 GenericDOMImplementation.getDOMImplementation(); 57 Document doc = impl.createDocument(SVGConstants.SVG_NAMESPACE_URI, 58 SVGConstants.SVG_SVG_TAG, null); 59 Element e = doc.createElementNS(SVGConstants.SVG_NAMESPACE_URI, 60 SVGConstants.SVG_RECT_TAG); 61 e.setAttribute("x", "10"); 62 e.setAttribute("y", "10"); 63 e.setAttribute("width", "100"); 64 e.setAttribute("height", "50"); 65 e.setAttribute("fill", "crimson"); 66 doc.getDocumentElement().appendChild(e); 67 68 e = doc.createElementNS(SVGConstants.SVG_NAMESPACE_URI, 69 SVGConstants.SVG_CIRCLE_TAG); 70 e.setAttribute("cx", "55"); 71 e.setAttribute("cy", "35"); 72 e.setAttribute("r", "30"); 73 e.setAttribute("fill", "gold"); 74 doc.getDocumentElement().appendChild(e); 75 76 canvas.setDocument(doc); 77 return false; } 79 80 public boolean canvasUpdated(JSVGCanvas canvas) { 81 return true; 82 } 83 } 84 | Popular Tags |