KickJava   Java API By Example, From Geeks To Geeks.

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


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.renderer;
22
23 import org.lobobrowser.html.HtmlRendererContext;
24 import org.lobobrowser.html.UserAgentContext;
25 import org.lobobrowser.html.domimpl.HTMLElementImpl;
26 import org.lobobrowser.html.domimpl.NodeImpl;
27 import org.lobobrowser.html.style.ListStyle;
28 import org.lobobrowser.html.style.RenderState;
29
30 class RList extends BaseRListElement {
31     public RList(NodeImpl modelNode, int listNesting, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext, RenderableContainer parentContainer, RCollection parent) {
32         super(modelNode, listNesting, pcontext, rcontext, frameContext, parentContainer);
33         this.defaultMarginInsets = new java.awt.Insets JavaDoc(5, 0, 5, 0);
34     }
35
36     private int counterStart;
37     
38     protected void applyStyle() {
39         super.applyStyle();
40         this.counterStart = 1;
41         Object JavaDoc rootNode = this.modelNode;
42         if(!(rootNode instanceof HTMLElementImpl)) {
43             return;
44         }
45         HTMLElementImpl rootElement = (HTMLElementImpl) rootNode;
46         String JavaDoc startText = rootElement.getAttribute("start");
47         if(startText != null) {
48             try {
49                 this.counterStart = Integer.parseInt(startText);
50             } catch(NumberFormatException JavaDoc nfe) {
51                 // ignore
52
}
53         }
54         ListStyle listStyle = this.listStyle;
55         if(listStyle == null || listStyle.type == ListStyle.TYPE_UNSET) {
56             if(listStyle == null) {
57                 listStyle = new ListStyle();
58                 this.listStyle = listStyle;
59             }
60             if("ul".equalsIgnoreCase(rootElement.getTagName())) {
61                 int listNesting = this.listNesting;
62                 if(listNesting == 0) {
63                     listStyle.type = ListStyle.TYPE_DISC;
64                 }
65                 else if(listNesting == 1) {
66                     listStyle.type = ListStyle.TYPE_CIRCLE;
67                 }
68                 else {
69                     listStyle.type = ListStyle.TYPE_SQUARE;
70                 }
71             }
72             else {
73                 listStyle.type = ListStyle.TYPE_DECIMAL;
74             }
75         }
76     }
77
78     public void doLayout(int availWidth, int availHeight, boolean expandWidth, boolean expandHeight, FloatingBounds floatBounds, int tentativeY, int defaultOverflow) {
79         RenderState renderState = this.modelNode.getRenderState();
80         renderState.resetCount(DEFAULT_COUNTER_NAME, this.listNesting, this.counterStart);
81         super.doLayout(availWidth, availHeight, expandWidth, expandHeight,
82                 floatBounds, tentativeY, defaultOverflow);
83     }
84 }
Popular Tags