001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: *
021: * $Id: HtmlTableCell.java,v 1.2 2006-06-15 13:40:47 sinisa Exp $
022: */
023:
024: package com.lutris.html;
025:
026: /**
027: * This base class is extended to compose a particular type of cell
028: * within a row within a HTML table. Normally the entire row will be
029: * composed of either data or header cells.
030: *
031: * @see HtmlTable
032: * @see HtmlTableRow
033: * @see HtmlTableDataCell
034: * @see HtmlTableHeaderCell
035: * @author Kyle Clark
036: * @author Paul Morgan
037: * @version 1.0 (File $Revision: 1.2 $)
038: */
039: public abstract class HtmlTableCell {
040:
041: public static final int ALIGN_LEFT = 1;
042: public static final int ALIGN_CENTER = 2;
043: public static final int ALIGN_RIGHT = 3;
044: public static final int VALIGN_TOP = 1;
045: public static final int VALIGN_MIDDLE = 2;
046: public static final int VALIGN_BOTTOM = 3;
047:
048: protected String caption;
049: protected int rowSpan = 0;
050: protected int colSpan = 0;
051: protected String tdValue = null;
052: protected String align = null;
053: protected String valign = null;
054: protected String bgColor = null;
055: protected int percentWidth = 0;
056:
057: public HtmlTableCell(String tdValue) {
058: this .tdValue = tdValue;
059: }
060:
061: public HtmlTableCell(String tdValue, String defaultValue) {
062: if (tdValue.equals("")) {
063: this .tdValue = defaultValue;
064: } else {
065: this .tdValue = tdValue;
066: }
067: }
068:
069: public void setHorizontalAlignment(int alignment) {
070: switch (alignment) {
071: case ALIGN_CENTER:
072: this .align = "CENTER";
073: break;
074: case ALIGN_RIGHT:
075: this .align = "RIGHT";
076: break;
077: default:
078: this .align = "LEFT";
079: break;
080: }
081: }
082:
083: public void setVerticalAlignment(int alignment) {
084: switch (alignment) {
085: case VALIGN_TOP:
086: this .valign = "TOP";
087: break;
088: case VALIGN_MIDDLE:
089: this .valign = "MIDDLE";
090: break;
091: default:
092: this .valign = "BOTTOM";
093: break;
094: }
095: }
096:
097: public void setRowSpan(int rowSpan) {
098: if (rowSpan > 0)
099: this .rowSpan = rowSpan;
100: }
101:
102: public void setColSpan(int colSpan) {
103: if (colSpan > 0)
104: this .colSpan = colSpan;
105: }
106:
107: public void setValue(String tdValue) {
108: this .tdValue = tdValue;
109: }
110:
111: public void setBackgroundColor(String bgColor) {
112: this .bgColor = bgColor;
113: }
114:
115: public void setPercentWidth(int percent) {
116: if (percent > 0 && percent <= 100)
117: this.percentWidth = percent;
118: }
119: }
|