KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > test > svg > SVGTextContentRenderingAccuracyTest


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.batik.test.svg;
18
19 import org.w3c.dom.Document JavaDoc;
20 import org.w3c.dom.Element JavaDoc;
21
22 import org.apache.batik.util.SVGConstants;
23 import org.apache.batik.util.XMLConstants;
24
25
26 /**
27  * Checks for regressions in rendering of a document with a given
28  * alternate stylesheet.
29  *
30  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
31  * @version $Id: SVGTextContentRenderingAccuracyTest.java,v 1.4 2005/04/01 02:28:16 deweese Exp $
32  */

33 public class SVGTextContentRenderingAccuracyTest
34     extends ParametrizedRenderingAccuracyTest {
35
36     protected String JavaDoc script; //null
37
protected String JavaDoc onload; //null
38
protected String JavaDoc parameter; //null
39

40     public void setScript(String JavaDoc script){
41         this.script = script;
42     }
43
44     public void setOnLoadFunction(String JavaDoc onload){
45         this.onload = onload;
46     }
47
48     public void setParameter(String JavaDoc parameter){
49         this.parameter = parameter;
50     }
51
52     protected Document JavaDoc manipulateSVGDocument(Document JavaDoc doc) {
53
54         Element JavaDoc root = doc.getDocumentElement();
55         String JavaDoc 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 JavaDoc 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