KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ecs > html > 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.html;
59
60 import org.apache.ecs.*;
61
62 /**
63     This class creates a &lt;BASEFONT&gt; object.
64     @version $Id: BaseFont.java,v 1.3 2003/04/27 09:20:40 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 */

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

74     {
75         setElementType("basefont");
76     }
77
78     /**
79         Basic Constructor. use set* methods.
80     */

81     public BaseFont()
82     {
83     }
84
85     /**
86         Basic constructor.
87         @param face create new BaseFont object with this face.
88     */

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

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

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

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

137     public BaseFont(String JavaDoc color,int size)
138     {
139         setSize(size);
140         setColor(color);
141     }
142     
143     /**
144         sets the FACE="" attribute.
145         @param face sets the FACE="" attribute.
146     */

147     public BaseFont setFace(String JavaDoc face)
148     {
149         addAttribute("face",face);
150         return(this);
151     }
152
153     /**
154         sets the COLOR="" attribute.
155         @param color sets the COLOR="" attribute. Convience colors are defined in the HtmlColors interface.
156     */

157     public BaseFont setColor(String JavaDoc color)
158     {
159         addAttribute("color",HtmlColor.convertColor(color));
160         return(this);
161     }
162     
163     /**
164         sets the SIZE="" attribute.
165         @param size sets the SIZE="" attribute.
166     */

167     public BaseFont setSize(int size)
168     {
169         addAttribute("size",Integer.toString(size));
170         return(this);
171     }
172
173     /**
174         sets the SIZE="" attribute.
175         @param size sets the SIZE="" attribute.
176     */

177     public BaseFont setSize(String JavaDoc size)
178     {
179         addAttribute("size",size);
180         return(this);
181     }
182
183     /**
184         Adds an Element to the element.
185         @param hashcode name of element for hash table
186         @param element Adds an Element to the element.
187      */

188     public BaseFont addElement(String JavaDoc hashcode,Element element)
189     {
190         addElementToRegistry(hashcode,element);
191         return(this);
192     }
193
194     /**
195         Adds an Element to the element.
196         @param hashcode name of element for hash table
197         @param element Adds an Element to the element.
198      */

199     public BaseFont addElement(String JavaDoc hashcode,String JavaDoc element)
200     {
201         addElementToRegistry(hashcode,element);
202         return(this);
203     }
204
205     /**
206         Adds an Element to the element.
207         @param element Adds an Element to the element.
208      */

209     public BaseFont addElement(Element element)
210     {
211         addElementToRegistry(element);
212         return(this);
213     }
214
215     /**
216         Adds an Element to the element.
217         @param element Adds an Element to the element.
218      */

219     public BaseFont addElement(String JavaDoc element)
220     {
221         addElementToRegistry(element);
222         return(this);
223     }
224     /**
225         Removes an Element from the element.
226         @param hashcode the name of the element to be removed.
227     */

228     public BaseFont removeElement(String JavaDoc hashcode)
229     {
230         removeElementFromRegistry(hashcode);
231         return(this);
232     }
233 }
234
Popular Tags