KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ecs > xhtml > basefont


1 /*
2  * ====================================================================
3  *
4  * The Apache Software License, Version 1.1
5  *
6  * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
7  * reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution, if
22  * any, must include the following acknowlegement:
23  * "This product includes software developed by the
24  * Apache Software Foundation (http://www.apache.org/)."
25  * Alternately, this acknowlegement may appear in the software itself,
26  * if and wherever such third-party acknowlegements normally appear.
27  *
28  * 4. The names "The Jakarta Project", "Jakarta Element Construction Set",
29  * "Jakarta ECS" , and "Apache Software Foundation" must not be used
30  * to endorse or promote products derived
31  * from this software without prior written permission. For written
32  * permission, please contact apache@apache.org.
33  *
34  * 5. Products derived from this software may not be called "Apache",
35  * "Jakarta Element Construction Set" nor "Jakarta ECS" nor may "Apache"
36  * appear in their names without prior written permission of the Apache Group.
37  *
38  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
39  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
42  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
48  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49  * SUCH DAMAGE.
50  * ====================================================================
51  *
52  * This software consists of voluntary contributions made by many
53  * individuals on behalf of the Apache Software Foundation. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  *
57  */

58 package org.apache.ecs.xhtml;
59
60 import org.apache.ecs.*;
61
62 /**
63     This class creates a &lt;basefont&gt; object.
64     @version $Id: basefont.java,v 1.2 2003/04/27 09:40:57 rdonkin Exp $
65     @author <a HREF="mailto:snagy@servletapi.com">Stephan Nagy</a>
66     @author <a HREF="mailto:jon@clearink.com">Jon S. Stevens</a>
67     @author <a HREF="mailto:bojan@binarix.com">Bojan Smojver</a>
68 */

69 public class basefont extends SinglePartElement implements Printable
70 {
71
72     /**
73         Private initializer.
74      */

75     {
76         setElementType("basefont");
77         setCase(LOWERCASE);
78         setAttributeQuote(true);
79         setBeginEndModifier('/');
80     }
81
82     /**
83         Basic Constructor. use set* methods.
84      */

85     public basefont()
86     {
87     }
88
89     /**
90         Basic constructor.
91         @param face create new basefont object with this face.
92     */

93     public basefont(String JavaDoc face)
94     {
95         setFace(face);
96     }
97
98     /**
99         Basic constructor
100         @param face
101         @param color
102         Create a new BaseFont object with the face abd color already set. Convience colors are defined in HtmlColor interface.
103     */

104     public basefont(String JavaDoc face,String JavaDoc color)
105     {
106         setFace(face);
107         setColor(color);
108     }
109
110     /**
111         Basic constructor
112         @param face
113         @param color
114         @param size
115         Create a new basefont object with the face,color and size already set. Convience colors are defined in HtmlColor interface.
116     */

117     public basefont(String JavaDoc face,String JavaDoc color,int size)
118     {
119         setFace(face);
120         setColor(color);
121         setSize(size);
122     }
123
124     /**
125         Basic constructor
126         @param size
127         Create a new basefont object with the size already set.
128     */

129     public basefont(int size,String JavaDoc face)
130     {
131         setSize(size);
132         setFace(face);
133     }
134
135     /**
136         Basic constructor
137         @param color
138         @param size
139         Create a new BaseFont object with the size and color already set.
140     */

141     public basefont(String JavaDoc color,int size)
142     {
143         setSize(size);
144         setColor(color);
145     }
146     
147     /**
148         sets the face="" attribute.
149         @param face sets the face="" attribute.
150     */

151     public basefont setFace(String JavaDoc face)
152     {
153         addAttribute("face",face);
154         return(this);
155     }
156
157     /**
158         sets the color="" attribute.
159         @param color sets the color="" attribute. Convience colors are defined in the HtmlColors interface.
160     */

161     public basefont setColor(String JavaDoc color)
162     {
163         addAttribute("color",HtmlColor.convertColor(color));
164         return(this);
165     }
166     
167     /**
168         sets the size="" attribute.
169         @param size sets the size="" attribute.
170     */

171     public basefont setSize(int size)
172     {
173         addAttribute("size",Integer.toString(size));
174         return(this);
175     }
176
177     /**
178         sets the size="" attribute.
179         @param size sets the size="" attribute.
180     */

181     public basefont setSize(String JavaDoc size)
182     {
183         addAttribute("size",size);
184         return(this);
185     }
186
187     /**
188         Sets the lang="" and xml:lang="" attributes
189         @param lang the lang="" and xml:lang="" attributes
190     */

191     public Element setLang(String JavaDoc lang)
192     {
193         addAttribute("lang",lang);
194         addAttribute("xml:lang",lang);
195         return this;
196     }
197
198     /**
199         Adds an Element to the element.
200         @param hashcode name of element for hash table
201         @param element Adds an Element to the element.
202      */

203     public basefont addElement(String JavaDoc hashcode,Element element)
204     {
205         addElementToRegistry(hashcode,element);
206         return(this);
207     }
208
209     /**
210         Adds an Element to the element.
211         @param hashcode name of element for hash table
212         @param element Adds an Element to the element.
213      */

214     public basefont addElement(String JavaDoc hashcode,String JavaDoc element)
215     {
216         addElementToRegistry(hashcode,element);
217         return(this);
218     }
219
220     /**
221         Adds an Element to the element.
222         @param element Adds an Element to the element.
223      */

224     public basefont addElement(Element element)
225     {
226         addElementToRegistry(element);
227         return(this);
228     }
229
230     /**
231         Adds an Element to the element.
232         @param element Adds an Element to the element.
233      */

234     public basefont addElement(String JavaDoc element)
235     {
236         addElementToRegistry(element);
237         return(this);
238     }
239     /**
240         Removes an Element from the element.
241         @param hashcode the name of the element to be removed.
242     */

243     public basefont removeElement(String JavaDoc hashcode)
244     {
245         removeElementFromRegistry(hashcode);
246         return(this);
247     }
248 }
249
Popular Tags