KickJava   Java API By Example, From Geeks To Geeks.

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


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 Dec 3, 2005
23  */

24 package org.lobobrowser.html.renderer;
25
26 import org.lobobrowser.html.style.HtmlLength;
27
28 class VirtualCell {
29     private final RTableCell actualCell;
30     private final boolean isTopLeft;
31     private int column;
32     private int row;
33
34     /**
35      * @param cell
36      */

37     public VirtualCell(RTableCell cell, boolean isTopLeft) {
38         actualCell = cell;
39         this.isTopLeft = isTopLeft;
40     }
41     
42     public boolean isTopLeft() {
43         return this.isTopLeft;
44     }
45
46     /**
47      * @return Returns the column.
48      */

49     public int getColumn() {
50         return column;
51     }
52
53
54
55     /**
56      * @param column The column to set.
57      */

58     public void setColumn(int column) {
59         this.column = column;
60     }
61
62
63
64     /**
65      * @return Returns the row.
66      */

67     public int getRow() {
68         return row;
69     }
70
71
72
73     /**
74      * @param row The row to set.
75      */

76     public void setRow(int row) {
77         this.row = row;
78     }
79
80
81
82     /**
83      * @return Returns the actualCell.
84      */

85     public RTableCell getActualCell() {
86         return actualCell;
87     }
88     
89     public HtmlLength getHeightLength() {
90         //TODO: Does not consider cellpadding and border
91
RTableCell cell = this.actualCell;
92         String JavaDoc heightText = cell.getHeightText();
93         HtmlLength length;
94         try {
95             length = heightText == null ? null : new HtmlLength(heightText);
96         } catch(Exception JavaDoc err) {
97             length = null;
98         }
99         if(length != null) {
100             length.divideBy(cell.getRowSpan());
101         }
102         return length;
103     }
104
105     public HtmlLength getWidthLength() {
106         RTableCell cell = this.actualCell;
107         String JavaDoc widthText = cell.getWidthText();
108         HtmlLength length;
109         try {
110             length = widthText == null ? null : new HtmlLength(widthText);
111         } catch(Exception JavaDoc err) {
112             length = null;
113         }
114         if(length != null) {
115             length.divideBy(cell.getColSpan());
116         }
117         return length;
118     }
119     
120 // public Dimension layoutMinWidth() {
121
//
122
// ActualCell cell = this.actualCell;
123
//
124
// Dimension ad = cell.layoutMinWidth();
125
//
126
// int colspan = cell.getColSpan();
127
//
128
// int rowspan = cell.getRowSpan();
129
//
130
// if(colspan == 1 && rowspan == 1) {
131
//
132
// return ad;
133
//
134
// }
135
//
136
// else {
137
//
138
// return new Dimension(ad.width / colspan, ad.height / rowspan);
139
//
140
// }
141
//
142
// }
143
}
144
Popular Tags