KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Describes an SVG font
29  *
30  * @author <a HREF="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
31  * @version $Id: SVGFontDescriptor.java,v 1.8 2004/08/18 07:15:00 vhardy Exp $
32  * @see org.apache.batik.svggen.SVGFont
33  */

34 public class SVGFontDescriptor implements SVGDescriptor, SVGSyntax {
35     private Element JavaDoc def;
36     private String JavaDoc fontSize;
37     private String JavaDoc fontWeight;
38     private String JavaDoc fontStyle;
39     private String JavaDoc fontFamily;
40
41     /**
42      * Constructor
43      */

44     public SVGFontDescriptor(String JavaDoc fontSize,
45                              String JavaDoc fontWeight,
46                              String JavaDoc fontStyle,
47                              String JavaDoc fontFamily,
48                              Element JavaDoc def){
49         if (fontSize == null ||
50             fontWeight == null ||
51             fontStyle == null ||
52             fontFamily == null)
53             throw new SVGGraphics2DRuntimeException(ErrorConstants.ERR_FONT_NULL);
54
55         this.fontSize = fontSize;
56         this.fontWeight = fontWeight;
57         this.fontStyle = fontStyle;
58         this.fontFamily = fontFamily;
59         this.def = def;
60     }
61
62     public Map JavaDoc getAttributeMap(Map JavaDoc attrMap){
63         if(attrMap == null)
64             attrMap = new HashMap JavaDoc();
65
66         attrMap.put(SVG_FONT_SIZE_ATTRIBUTE, fontSize);
67         attrMap.put(SVG_FONT_WEIGHT_ATTRIBUTE, fontWeight);
68         attrMap.put(SVG_FONT_STYLE_ATTRIBUTE, fontStyle);
69         attrMap.put(SVG_FONT_FAMILY_ATTRIBUTE, fontFamily);
70
71         return attrMap;
72     }
73
74     public Element JavaDoc getDef(){
75         return def;
76     }
77
78     public List JavaDoc getDefinitionSet(List JavaDoc defSet){
79         if (defSet == null)
80             defSet = new LinkedList JavaDoc();
81
82         if(def != null && !defSet.contains(def))
83             defSet.add(def);
84
85         return defSet;
86     }
87 }
88
Popular Tags