Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/lutris/html/HtmlTableCell.java


1   /*
2    * Enhydra Java Application Server Project
3    * 
4    * The contents of this file are subject to the Enhydra Public License
5    * Version 1.1 (the "License"); you may not use this file except in
6    * compliance with the License. You may obtain a copy of the License on
7    * the Enhydra web site ( http://www.enhydra.org/ ).
8    * 
9    * Software distributed under the License is distributed on an "AS IS"
10   * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 
11   * the License for the specific terms governing rights and limitations
12   * under the License.
13   * 
14   * The Initial Developer of the Enhydra Application Server is Lutris
15   * Technologies, Inc. The Enhydra Application Server and portions created
16   * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17   * All Rights Reserved.
18   * 
19   * Contributor(s):
20   * 
21   * $Id: HtmlTableCell.java,v 1.9.12.1 2000/10/19 17:58:53 jasona Exp $
22   */
23  
24  
25  
26  
27  
28  package com.lutris.html;
29  
30  import java.util.Vector;
31  import java.util.Enumeration;
32  
33  /**
34   * This base class is extended to compose a particular type of cell
35   * within a row within a HTML table. Normally the entire row will be
36   * composed of either data or header cells.
37   *
38   * @see HtmlTable
39   * @see HtmlTableRow
40   * @see HtmlTableDataCell
41   * @see HtmlTableHeaderCell
42   * @author Kyle Clark
43   * @author Paul Morgan
44   * @version 1.0 (File $Revision: 1.9.12.1 $)
45   */
46  public abstract class HtmlTableCell {
47  
48      public static final int ALIGN_LEFT = 1;
49      public static final int ALIGN_CENTER = 2;
50      public static final int ALIGN_RIGHT = 3;
51      public static final int VALIGN_TOP = 1; 
52      public static final int VALIGN_MIDDLE = 2;
53      public static final int VALIGN_BOTTOM = 3;
54  
55      protected String caption;
56      protected int rowSpan = 0;
57      protected int colSpan = 0;
58      protected String tdValue = null;
59      protected String align = null;
60      protected String valign = null;
61      protected String bgColor = null;
62      protected int percentWidth = 0;
63  
64      public HtmlTableCell(String tdValue)
65      {
66          this.tdValue = tdValue;
67      }
68  
69      public HtmlTableCell(String tdValue, String defaultValue)
70      {
71    if (tdValue.equals("")) {
72        this.tdValue = defaultValue;
73    } else {
74        this.tdValue = tdValue;
75    }
76      }
77  
78      public void setHorizontalAlignment(int alignment)
79      {
80          switch (alignment) {
81          case ALIGN_CENTER:
82              this.align = "CENTER";
83              break;
84          case ALIGN_RIGHT:
85              this.align = "RIGHT";
86              break;
87          default:
88              this.align = "LEFT";
89              break;
90          }
91      }
92  
93      public void setVerticalAlignment(int alignment)
94      {
95          switch (alignment) {
96          case VALIGN_TOP:
97              this.valign = "TOP";
98              break;
99          case VALIGN_MIDDLE:
100             this.valign = "MIDDLE";
101             break;
102         default:
103             this.valign = "BOTTOM";
104             break;
105         }
106     }
107 
108     public void setRowSpan(int rowSpan)
109     {
110         if (rowSpan > 0)
111             this.rowSpan = rowSpan;
112     }
113 
114     public void setColSpan(int colSpan)
115     {
116         if (colSpan > 0)
117             this.colSpan = colSpan;
118     }
119     
120     public void setValue(String tdValue)
121     {
122         this.tdValue = tdValue;
123     }
124 
125     public void setBackgroundColor(String bgColor)
126     {
127         this.bgColor = bgColor;
128     }
129 
130     public void setPercentWidth(int percent)
131     {
132         if (percent > 0 && percent <= 100)
133             this.percentWidth = percent;
134     }
135 }