KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > dom > AbstractStylableDocument


1 /*
2
3    Copyright 2004 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
19 package org.apache.batik.dom;
20
21 import org.apache.batik.css.engine.CSSEngine;
22
23 import org.w3c.dom.css.DocumentCSS;
24 import org.w3c.dom.css.CSSStyleDeclaration;
25 import org.w3c.dom.DocumentType JavaDoc;
26 import org.w3c.dom.DOMImplementation JavaDoc;
27 import org.w3c.dom.Element JavaDoc;
28 import org.w3c.dom.stylesheets.StyleSheetList;
29 import org.w3c.dom.views.DocumentView;
30 import org.w3c.dom.views.AbstractView;
31
32 /**
33  * A Document that supports CSS styling.
34  *
35  * @author <a HREF="mailto:deweese@apache.org">deweese</a>
36  * @version $Id: AbstractStylableDocument.java,v 1.2 2005/03/27 08:58:32 cam Exp $
37  */

38 public abstract class AbstractStylableDocument extends AbstractDocument
39     implements DocumentCSS,
40                DocumentView {
41
42     /**
43      * The default view.
44      */

45     protected transient AbstractView defaultView;
46
47     /**
48      * The CSS engine.
49      */

50     protected transient CSSEngine cssEngine;
51
52
53     protected AbstractStylableDocument() {
54     }
55
56     /**
57      * Creates a new document.
58      */

59     protected AbstractStylableDocument(DocumentType JavaDoc dt,
60                                        DOMImplementation JavaDoc impl) {
61         super(dt, impl);
62     }
63
64     /**
65      * Sets the CSS engine.
66      */

67     public void setCSSEngine(CSSEngine ctx) {
68         cssEngine = ctx;
69     }
70
71     /**
72      * Returns the CSS engine.
73      */

74     public CSSEngine getCSSEngine() {
75         return cssEngine;
76     }
77
78     // DocumentStyle /////////////////////////////////////////////////////////
79

80     /**
81      * <b>DOM</b>: Implements {@link
82      * org.w3c.dom.stylesheets.DocumentStyle#getStyleSheets()}.
83      */

84     public StyleSheetList getStyleSheets() {
85         throw new RuntimeException JavaDoc(" !!! Not implemented");
86     }
87
88     // DocumentView ///////////////////////////////////////////////////////////
89

90     /**
91      * <b>DOM</b>: Implements {@link DocumentView#getDefaultView()}.
92      * @return a ViewCSS object.
93      */

94     public AbstractView getDefaultView() {
95         if (defaultView == null) {
96             ExtensibleDOMImplementation impl;
97             impl = (ExtensibleDOMImplementation)implementation;
98             defaultView = impl.createViewCSS(this);
99         }
100         return defaultView;
101     }
102
103     /**
104      * Clears the view CSS.
105      */

106     public void clearViewCSS() {
107         defaultView = null;
108         if (cssEngine != null) {
109             cssEngine.dispose();
110         }
111         cssEngine = null;
112     }
113
114     // DocumentCSS ////////////////////////////////////////////////////////////
115

116     /**
117      * <b>DOM</b>: Implements
118      * {@link DocumentCSS#getOverrideStyle(Element,String)}.
119      */

120     public CSSStyleDeclaration getOverrideStyle(Element JavaDoc elt,
121                                                 String JavaDoc pseudoElt) {
122         throw new RuntimeException JavaDoc(" !!! Not implemented");
123     }
124
125 };
126
Popular Tags