KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > bridge > SVGFontFace


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.bridge;
19
20 import java.util.List JavaDoc;
21
22 import org.apache.batik.gvt.font.GVTFontFamily;
23 import org.w3c.dom.Element JavaDoc;
24
25 /**
26  * This class represents a <font-face> element or @font-face rule
27  *
28  * @author <a HREF="mailto:bella.robinson@cmis.csiro.au">Bella Robinson</a>
29  * @version $Id: SVGFontFace.java,v 1.7 2004/08/18 07:12:34 vhardy Exp $
30  */

31 public class SVGFontFace extends FontFace {
32
33     Element JavaDoc fontFaceElement;
34     GVTFontFamily fontFamily = null;
35     /**
36      * Constructes an SVGFontFace with the specfied font-face attributes.
37      */

38     public SVGFontFace
39         (Element JavaDoc fontFaceElement, List JavaDoc srcs,
40          String JavaDoc familyName, float unitsPerEm, String JavaDoc fontWeight,
41          String JavaDoc fontStyle, String JavaDoc fontVariant, String JavaDoc fontStretch,
42          float slope, String JavaDoc panose1, float ascent, float descent,
43          float strikethroughPosition, float strikethroughThickness,
44          float underlinePosition, float underlineThickness,
45          float overlinePosition, float overlineThickness) {
46         super(srcs,
47               familyName, unitsPerEm, fontWeight,
48               fontStyle, fontVariant, fontStretch,
49               slope, panose1, ascent, descent,
50               strikethroughPosition, strikethroughThickness,
51               underlinePosition, underlineThickness,
52               overlinePosition, overlineThickness);
53         this.fontFaceElement = fontFaceElement;
54     }
55
56     /**
57      * Returns the font associated with this rule or element.
58      */

59     public GVTFontFamily getFontFamily(BridgeContext ctx) {
60         if (fontFamily != null)
61             return fontFamily;
62
63         Element JavaDoc fontElt = SVGUtilities.getParentElement(fontFaceElement);
64         if (fontElt.getNamespaceURI().equals(SVG_NAMESPACE_URI) &&
65             fontElt.getLocalName().equals(SVG_FONT_TAG)) {
66             return new SVGFontFamily(this, fontElt, ctx);
67         }
68
69         fontFamily = super.getFontFamily(ctx);
70         return fontFamily;
71     }
72
73     public Element JavaDoc getFontFaceElement() {
74         return fontFaceElement;
75     }
76
77     /**
78      * Default implementation uses the root element of the document
79      * associated with BridgeContext. This is useful for CSS case.
80      */

81     protected Element JavaDoc getBaseElement(BridgeContext ctx) {
82         if (fontFaceElement != null)
83             return fontFaceElement;
84         return super.getBaseElement(ctx);
85     }
86
87 }
88
Popular Tags