KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lobobrowser > html > domimpl > HTMLFontElementImpl


1 /*
2     GNU LESSER GENERAL PUBLIC LICENSE
3     Copyright (C) 2006 The Lobo Project
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Lesser General Public
7     License as published by the Free Software Foundation; either
8     version 2.1 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13     Lesser General Public License for more details.
14
15     You should have received a copy of the GNU Lesser General Public
16     License along with this library; if not, write to the Free Software
17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19     Contact info: xamjadmin@users.sourceforge.net
20 */

21 package org.lobobrowser.html.domimpl;
22
23 import org.lobobrowser.html.style.BaseFontRenderState;
24 import org.lobobrowser.html.style.ColorRenderState;
25 import org.lobobrowser.html.style.FontNameRenderState;
26 import org.lobobrowser.html.style.FontSizeRenderState;
27 import org.lobobrowser.html.style.HtmlValues;
28 import org.lobobrowser.html.style.RenderState;
29 import org.lobobrowser.util.gui.ColorFactory;
30 import org.w3c.dom.html2.HTMLFontElement;
31
32 public class HTMLFontElementImpl extends HTMLAbstractUIElement implements
33         HTMLFontElement {
34     public HTMLFontElementImpl(String JavaDoc name) {
35         super(name);
36     }
37
38     public String JavaDoc getColor() {
39         return this.getAttribute("color");
40     }
41
42     public String JavaDoc getFace() {
43         return this.getAttribute("face");
44     }
45
46     public String JavaDoc getSize() {
47         return this.getAttribute("size");
48     }
49
50     public void setColor(String JavaDoc color) {
51         this.setAttribute("color", color);
52     }
53
54     public void setFace(String JavaDoc face) {
55         this.setAttribute("face", face);
56     }
57
58     public void setSize(String JavaDoc size) {
59         this.setAttribute("size", size);
60     }
61
62     protected RenderState createRenderState(RenderState prevRenderState) {
63         String JavaDoc face = this.getAttribute("face");
64         String JavaDoc size = this.getAttribute("size");
65         String JavaDoc color = this.getAttribute("color");
66         if(face != null) {
67             prevRenderState = new FontNameRenderState(prevRenderState, face);
68         }
69         if(size != null) {
70             int fontNumber = HtmlValues.getFontNumberOldStyle(size, prevRenderState);
71             float fontSize = HtmlValues.getFontSize(fontNumber);
72             prevRenderState = new FontSizeRenderState(prevRenderState, fontSize);
73         }
74         if(color != null) {
75             prevRenderState = new ColorRenderState(prevRenderState, ColorFactory.getInstance().getColor(color));
76         }
77         return prevRenderState;
78     }
79 }
80
Popular Tags