KickJava   Java API By Example, From Geeks To Geeks.

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


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

18 package org.apache.batik.test.svg;
19
20 import java.io.File JavaDoc;
21
22 /**
23  * Base class for tests which take an additional parameter in addition
24  * to the SVG file.
25  *
26  * @author <a HREF="mailto:vincent.hardy@sun.com">Vincent Hardy</a>
27  * @version $Id: ParametrizedRenderingAccuracyTest.java,v 1.6 2004/08/18 07:17:02 vhardy Exp $
28  */

29 public class ParametrizedRenderingAccuracyTest
30     extends SamplesRenderingTest {
31     public static final char PARAMETER_SEPARATOR = '-';
32
33     /**
34      * Parameter which was passed appended to the SVG file
35      */

36     protected String JavaDoc parameter;
37
38     /**
39      * Constructor.
40      */

41     public ParametrizedRenderingAccuracyTest(){
42         super();
43     }
44
45     public char getParameterSeparator(){
46         return PARAMETER_SEPARATOR;
47     }
48
49     public void setId(String JavaDoc id){
50         this.id = id;
51
52         String JavaDoc svgFile = id;
53
54         int n = svgFile.lastIndexOf(getParameterSeparator());
55         if(n == -1 || n+1 >= svgFile.length() ){
56             throw new IllegalArgumentException JavaDoc(id);
57         }
58
59         parameter = svgFile.substring(n+1, svgFile.length());
60         svgFile = svgFile.substring(0, n);
61
62         String JavaDoc[] dirNfile = breakSVGFile(svgFile);
63
64         setConfig(buildSVGURL(dirNfile[0], dirNfile[1], dirNfile[2]),
65                   buildRefImgURL(dirNfile[0], dirNfile[1]));
66
67         setVariationURL(buildVariationURL(dirNfile[0], dirNfile[1]));
68         setSaveVariation(new File JavaDoc(buildSaveVariationFile(dirNfile[0], dirNfile[1])));
69         setCandidateReference(new File JavaDoc(buildCandidateReferenceFile(dirNfile[0], dirNfile[1])));
70     }
71
72     /**
73      * Gives a chance to the subclass to control the construction
74      * of the reference PNG file from the svgFile name
75      * The refImgURL is built as:
76      * getRefImagePrefix() + svgDir + getRefImageSuffix() + svgFile
77      */

78     protected String JavaDoc buildRefImgURL(String JavaDoc svgDir, String JavaDoc svgFile){
79         return getRefImagePrefix() + svgDir + getRefImageSuffix() + svgFile + parameter + PNG_EXTENSION;
80     }
81
82     /**
83      * Gives a chance to the subclass to control the construction
84      * of the variation URL, which is built as:
85      * getVariationPrefix() + svgDir + getVariationSuffix() + svgFile + parameter + PNG_EXTENSION
86      */

87     public String JavaDoc buildVariationURL(String JavaDoc svgDir, String JavaDoc svgFile){
88         return getVariationPrefix() + svgDir + getVariationSuffix() + svgFile + parameter + PNG_EXTENSION;
89     }
90
91     /**
92      * Gives a chance to the subclass to control the construction
93      * of the saveVariation URL, which is built as:
94      * getSaveVariationPrefix() + svgDir + getSaveVariationSuffix() + svgFile + parameter + PNG_EXTENSION
95      */

96     public String JavaDoc buildSaveVariationFile(String JavaDoc svgDir, String JavaDoc svgFile){
97         return getSaveVariationPrefix() + svgDir + getSaveVariationSuffix() + svgFile + parameter + PNG_EXTENSION;
98     }
99
100     /**
101      * Gives a chance to the subclass to control the construction
102      * of the candidateReference URL, which is built as:
103      * getSaveVariationPrefix() + svgDir + getSaveVariationSuffix() + svgFile + parameter + PNG_EXTENSION
104      */

105     public String JavaDoc buildCandidateReferenceFile(String JavaDoc svgDir, String JavaDoc svgFile){
106         return getCandidateReferencePrefix() + svgDir + getCandidateReferenceSuffix() + svgFile + parameter + PNG_EXTENSION;
107     }
108
109 }
110
Popular Tags