KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > svggen > SVGPaintDescriptor


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.svggen;
19
20 import java.util.HashMap JavaDoc;
21 import java.util.LinkedList JavaDoc;
22 import java.util.List JavaDoc;
23 import java.util.Map JavaDoc;
24
25 import org.w3c.dom.Element JavaDoc;
26
27 /**
28  * Used to represent an SVG Paint. This can be achieved with
29  * to values: an SVG paint value and an SVG opacity value
30  *
31  * @author <a HREF="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
32  * @version $Id: SVGPaintDescriptor.java,v 1.6 2004/08/18 07:15:08 vhardy Exp $
33  */

34 public class SVGPaintDescriptor implements SVGDescriptor, SVGSyntax{
35     private Element JavaDoc def;
36     private String JavaDoc paintValue;
37     private String JavaDoc opacityValue;
38
39     public SVGPaintDescriptor(String JavaDoc paintValue,
40                               String JavaDoc opacityValue){
41         this.paintValue = paintValue;
42         this.opacityValue = opacityValue;
43     }
44
45     public SVGPaintDescriptor(String JavaDoc paintValue,
46                               String JavaDoc opacityValue,
47                               Element JavaDoc def){
48         this(paintValue, opacityValue);
49         this.def = def;
50     }
51
52     public String JavaDoc getPaintValue(){
53         return paintValue;
54     }
55
56     public String JavaDoc getOpacityValue(){
57         return opacityValue;
58     }
59
60     public Element JavaDoc getDef(){
61         return def;
62     }
63
64     public Map JavaDoc getAttributeMap(Map JavaDoc attrMap){
65         if(attrMap == null)
66             attrMap = new HashMap JavaDoc();
67
68         attrMap.put(SVG_FILL_ATTRIBUTE, paintValue);
69         attrMap.put(SVG_STROKE_ATTRIBUTE, paintValue);
70         attrMap.put(SVG_FILL_OPACITY_ATTRIBUTE, opacityValue);
71         attrMap.put(SVG_STROKE_OPACITY_ATTRIBUTE, opacityValue);
72
73         return attrMap;
74     }
75
76     public List JavaDoc getDefinitionSet(List JavaDoc defSet){
77         if(defSet == null)
78             defSet = new LinkedList JavaDoc();
79
80         if(def != null)
81             defSet.add(def);
82
83         return defSet;
84     }
85 }
86
Popular Tags