KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > html > HtmlTableCell


1
2 /*
3  * Enhydra Java Application Server Project
4  *
5  * The contents of this file are subject to the Enhydra Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License on
8  * the Enhydra web site ( http://www.enhydra.org/ ).
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific terms governing rights and limitations
13  * under the License.
14  *
15  * The Initial Developer of the Enhydra Application Server is Lutris
16  * Technologies, Inc. The Enhydra Application Server and portions created
17  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
18  * All Rights Reserved.
19  *
20  * Contributor(s):
21  *
22  * $Id: HtmlTableCell.java,v 1.1 2005/07/13 11:09:06 slobodan Exp $
23  */

24
25
26
27
28
29 package com.lutris.html;
30
31
32 /**
33  * This base class is extended to compose a particular type of cell
34  * within a row within a HTML table. Normally the entire row will be
35  * composed of either data or header cells.
36  *
37  * @see HtmlTable
38  * @see HtmlTableRow
39  * @see HtmlTableDataCell
40  * @see HtmlTableHeaderCell
41  * @author Kyle Clark
42  * @author Paul Morgan
43  * @version 1.0 (File $Revision: 1.1 $)
44  */

45 public abstract class HtmlTableCell {
46
47     public static final int ALIGN_LEFT = 1;
48     public static final int ALIGN_CENTER = 2;
49     public static final int ALIGN_RIGHT = 3;
50     public static final int VALIGN_TOP = 1;
51     public static final int VALIGN_MIDDLE = 2;
52     public static final int VALIGN_BOTTOM = 3;
53
54     protected String JavaDoc caption;
55     protected int rowSpan = 0;
56     protected int colSpan = 0;
57     protected String JavaDoc tdValue = null;
58     protected String JavaDoc align = null;
59     protected String JavaDoc valign = null;
60     protected String JavaDoc bgColor = null;
61     protected int percentWidth = 0;
62
63     public HtmlTableCell(String JavaDoc tdValue)
64     {
65         this.tdValue = tdValue;
66     }
67
68     public HtmlTableCell(String JavaDoc tdValue, String JavaDoc defaultValue)
69     {
70     if (tdValue.equals("")) {
71         this.tdValue = defaultValue;
72     } else {
73         this.tdValue = tdValue;
74     }
75     }
76
77     public void setHorizontalAlignment(int alignment)
78     {
79         switch (alignment) {
80         case ALIGN_CENTER:
81             this.align = "CENTER";
82             break;
83         case ALIGN_RIGHT:
84             this.align = "RIGHT";
85             break;
86         default:
87             this.align = "LEFT";
88             break;
89         }
90     }
91
92     public void setVerticalAlignment(int alignment)
93     {
94         switch (alignment) {
95         case VALIGN_TOP:
96             this.valign = "TOP";
97             break;
98         case VALIGN_MIDDLE:
99             this.valign = "MIDDLE";
100             break;
101         default:
102             this.valign = "BOTTOM";
103             break;
104         }
105     }
106
107     public void setRowSpan(int rowSpan)
108     {
109         if (rowSpan > 0)
110             this.rowSpan = rowSpan;
111     }
112
113     public void setColSpan(int colSpan)
114     {
115         if (colSpan > 0)
116             this.colSpan = colSpan;
117     }
118     
119     public void setValue(String JavaDoc tdValue)
120     {
121         this.tdValue = tdValue;
122     }
123
124     public void setBackgroundColor(String JavaDoc bgColor)
125     {
126         this.bgColor = bgColor;
127     }
128
129     public void setPercentWidth(int percent)
130     {
131         if (percent > 0 && percent <= 100)
132             this.percentWidth = percent;
133     }
134 }
135
Popular Tags