KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lobobrowser > html > style > TableRenderState


1 /*
2     GNU LESSER GENERAL PUBLIC LICENSE
3     Copyright (C) 2006 The XAMJ 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.style;
22
23 import java.awt.Color JavaDoc;
24 import org.lobobrowser.html.domimpl.*;
25 import org.lobobrowser.util.gui.ColorFactory;
26
27 public class TableRenderState extends StyleSheetRenderState {
28     public TableRenderState(RenderState prevRenderState, HTMLElementImpl element) {
29         super(prevRenderState, element);
30     }
31
32     public Color JavaDoc getTextBackgroundColor() {
33         return super.getTextBackgroundColor();
34     }
35
36     protected int getDefaultDisplay() {
37         return DISPLAY_TABLE;
38     }
39     
40     private BackgroundInfo backgroundInfo = INVALID_BACKGROUND_INFO;
41     
42     public void invalidate() {
43         super.invalidate();
44         this.backgroundInfo = INVALID_BACKGROUND_INFO;
45     }
46     
47     public BackgroundInfo getBackgroundInfo() {
48         BackgroundInfo binfo = this.backgroundInfo;
49         if(binfo != INVALID_BACKGROUND_INFO) {
50             return binfo;
51         }
52         // Apply style based on deprecated attributes.
53
binfo = super.getBackgroundInfo();
54         HTMLTableElementImpl element = (HTMLTableElementImpl) this.element;
55         if(binfo == null || binfo.backgroundColor == null) {
56             String JavaDoc bgColor = element.getBgColor();
57             if(bgColor != null && !"".equals(bgColor)) {
58                 Color JavaDoc bgc = ColorFactory.getInstance().getColor(bgColor);
59                 if(binfo == null) {
60                     binfo = new BackgroundInfo();
61                 }
62                 binfo.backgroundColor = bgc;
63             }
64         }
65         if(binfo == null || binfo.backgroundImage == null) {
66             String JavaDoc background = element.getAttribute("background");
67             if(background != null && !"".equals(background)) {
68                 if(binfo == null) {
69                     binfo = new BackgroundInfo();
70                 }
71                 binfo.backgroundImage = background;
72             }
73         }
74         this.backgroundInfo = binfo;
75         return binfo;
76     }
77 }
78
Popular Tags