KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ecs > html > 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.html;
59
60 import org.apache.ecs.*;
61
62 /**
63     This class creates a &lt;FONT&gt; object.
64     @version $Id: Font.java,v 1.3 2003/04/27 09:21:50 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 Font extends MultiPartElement implements Printable
69 {
70
71     /**
72         Private initializer.
73     */

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

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

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

100     public Font(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 font object with the face,color and size already set. Convience colors are defined in HtmlColor interface.
112     */

113     public Font(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 font object with the size already set.
124     */

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

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

148     public Font(String JavaDoc color,int size)
149     {
150         setSize(size);
151         setColor(color);
152     }
153     
154     /**
155         sets the FACE="" attribute.
156         @param face sets the FACE="" attribute.
157     */

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

168     public Font setColor(String JavaDoc color)
169     {
170         addAttribute("color",HtmlColor.convertColor(color));
171         return(this);
172     }
173     
174     /**
175         sets the SIZE="" attribute.
176         @param size sets the SIZE="" attribute.
177     */

178     public Font setSize(int size)
179     {
180         addAttribute("size",Integer.toString(size));
181         return(this);
182     }
183
184     /**
185         sets the SIZE="" attribute.
186         @param size sets the SIZE="" attribute.
187     */

188     public Font setSize(String JavaDoc size)
189     {
190         addAttribute("size",size);
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 Font addElement(String JavaDoc hashcode,Element element)
200     {
201         addElementToRegistry(hashcode,element);
202         return(this);
203     }
204
205     /**
206         Adds an Element to the element.
207         @param hashcode name of element for hash table
208         @param element Adds an Element to the element.
209      */

210     public Font addElement(String JavaDoc hashcode,String JavaDoc element)
211     {
212         addElementToRegistry(hashcode,element);
213         return(this);
214     }
215
216     /**
217         Adds an Element to the Element.
218         @param element adds and Element to the Element.
219     */

220     public Font addElement(Element element)
221     {
222         addElementToRegistry(element);
223         return(this);
224     }
225
226     /**
227         Adds an Element to the Element.
228         @param element adds and Element to the Element.
229     */

230     public Font addElement(String JavaDoc element)
231     {
232         addElementToRegistry(element);
233         return(this);
234     }
235     /**
236         Removes an Element from the element.
237         @param hashcode the name of the element to be removed.
238     */

239     public Font removeElement(String JavaDoc hashcode)
240     {
241         removeElementFromRegistry(hashcode);
242         return(this);
243     }
244 }
245
Popular Tags