KickJava   Java API By Example, From Geeks To Geeks.

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


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;font&gt; object.
64     @version $Id: font.java,v 1.2 2003/04/27 09:40:36 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 font extends MultiPartElement implements Printable
70 {
71
72     /**
73         Private initializer.
74     */

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

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

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

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

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

128     public font(int size)
129     {
130         setSize(size);
131     }
132
133     /**
134         Basic constructor
135         @param size
136         @param face
137         Create a new font object with the size and face already set.
138     */

139     public font(int size,String JavaDoc face)
140     {
141         setSize(size);
142         setFace(face);
143     }
144
145     /**
146         Basic constructor
147         @param color
148         @param size
149         Create a new font object with the size and color already set.
150     */

151     public font(String JavaDoc color,int size)
152     {
153         setSize(size);
154         setColor(color);
155     }
156     
157     /**
158         sets the face="" attribute.
159         @param face sets the face="" attribute.
160     */

161     public font setFace(String JavaDoc face)
162     {
163         addAttribute("face",face);
164         return(this);
165     }
166
167     /**
168         sets the color="" attribute.
169         @param color sets the color="" attribute. Convience colors are defined in the HtmlColors interface.
170     */

171     public font setColor(String JavaDoc color)
172     {
173         addAttribute("color",HtmlColor.convertColor(color));
174         return(this);
175     }
176     
177     /**
178         sets the size="" attribute.
179         @param size sets the size="" attribute.
180     */

181     public font setSize(int size)
182     {
183         addAttribute("size",Integer.toString(size));
184         return(this);
185     }
186
187     /**
188         sets the size="" attribute.
189         @param size sets the size="" attribute.
190     */

191     public font setSize(String JavaDoc size)
192     {
193         addAttribute("size",size);
194         return(this);
195     }
196
197     /**
198         Sets the lang="" and xml:lang="" attributes
199         @param lang the lang="" and xml:lang="" attributes
200     */

201     public Element setLang(String JavaDoc lang)
202     {
203         addAttribute("lang",lang);
204         addAttribute("xml:lang",lang);
205         return this;
206     }
207
208     /**
209         Adds an Element to the element.
210         @param hashcode name of element for hash table
211         @param element Adds an Element to the element.
212      */

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

224     public font addElement(String JavaDoc hashcode,String JavaDoc element)
225     {
226         addElementToRegistry(hashcode,element);
227         return(this);
228     }
229
230     /**
231         Adds an Element to the Element.
232         @param element adds and Element to the Element.
233     */

234     public font addElement(Element element)
235     {
236         addElementToRegistry(element);
237         return(this);
238     }
239
240     /**
241         Adds an Element to the Element.
242         @param element adds and Element to the Element.
243     */

244     public font addElement(String JavaDoc element)
245     {
246         addElementToRegistry(element);
247         return(this);
248     }
249     /**
250         Removes an Element from the element.
251         @param hashcode the name of the element to be removed.
252     */

253     public font removeElement(String JavaDoc hashcode)
254     {
255         removeElementFromRegistry(hashcode);
256         return(this);
257     }
258 }
259
Popular Tags