KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lobobrowser > html > renderer > BaseControl


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 /*
22  * Created on Oct 23, 2005
23  */

24 package org.lobobrowser.html.renderer;
25
26 import java.awt.Color JavaDoc;
27 import java.awt.Component JavaDoc;
28 import java.awt.Dimension JavaDoc;
29
30 import javax.swing.*;
31
32 import org.lobobrowser.html.domimpl.*;
33
34 import java.util.logging.*;
35
36 abstract class BaseControl extends JComponent implements UIControl {
37     private static final Logger logger = Logger.getLogger(BaseControl.class.getName());
38     protected static final Dimension JavaDoc ZERO_DIMENSION = new Dimension JavaDoc(0, 0);
39     protected final HTMLElementImpl controlElement;
40     protected RUIControl ruicontrol;
41     
42     /**
43      * @param context
44      */

45     public BaseControl(HTMLElementImpl modelNode) {
46         this.controlElement = modelNode;
47     }
48
49     public Component JavaDoc getComponent() {
50         return this;
51     }
52     
53     public void setRUIControl(RUIControl ruicontrol) {
54         this.ruicontrol = ruicontrol;
55     }
56     
57     public int getVAlign() {
58         return RElement.VALIGN_BASELINE;
59     }
60
61     /**
62      * Method invoked when image changes size.
63      * It's expected to be called outside the GUI thread.
64      */

65     protected void invalidateAndRepaint() {
66         RUIControl rc = this.ruicontrol;
67         if(rc == null) {
68             logger.severe("invalidateAndPaint(): RUIControl not set.");
69             return;
70         }
71         if(rc.isValid()) {
72             rc.relayout();
73         }
74     }
75
76     /* (non-Javadoc)
77      * @see org.xamjwg.html.renderer.UIControl#getBackgroundColor()
78      */

79     public Color JavaDoc getBackgroundColor() {
80         return this.getBackground();
81     }
82 }
83
Popular Tags