1 2 24 25 26 27 28 29 package com.lutris.html; 30 31 import java.util.Enumeration ; 32 import java.util.Vector ; 33 34 45 public class HtmlTableRow { 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 private String caption = null; 55 private String align = null; 56 private String valign = null; 57 private Vector row = new Vector (); 58 private int colSpan = 0; 59 private int rowSpan = 0; 60 private String bgColor = null; 61 62 public HtmlTableRow() 63 { 64 } 66 67 public HtmlTableRow(HtmlTableCell td) 68 { 69 addCell(td); 70 } 71 72 public HtmlTableRow(String td) 73 { 74 addCell(td); 75 } 76 77 public void addCell(HtmlTableCell td) 78 { 79 row.addElement(td); 80 } 81 82 public void addCell(String td) 83 { 84 row.addElement(td); 85 } 86 87 public void setHorizontalAlignment(int alignment) 88 { 89 switch (alignment) { 90 case ALIGN_CENTER: 91 this.align = "CENTER"; 92 break; 93 case ALIGN_RIGHT: 94 this.align = "RIGHT"; 95 break; 96 default: 97 this.align = "LEFT"; 98 break; 99 } 100 } 101 102 public void setVerticalAlignment(int alignment) 103 { 104 switch (alignment) { 105 case VALIGN_TOP: 106 this.valign = "TOP"; 107 break; 108 case VALIGN_MIDDLE: 109 this.valign = "MIDDLE"; 110 break; 111 default: 112 this.valign = "BOTTOM"; 113 break; 114 } 115 } 116 117 public void setRowSpan(int rowSpan) 118 { 119 if (rowSpan > 0) 120 this.rowSpan = rowSpan; 121 } 122 123 public void setColSpan(int colSpan) 124 { 125 if (colSpan > 0) 126 this.colSpan = colSpan; 127 } 128 129 public void setBackgroundColor(String bgColor) 130 { 131 this.bgColor = bgColor; 132 } 133 134 public String toString() 135 { 136 StringBuffer html = new StringBuffer (); 137 138 html.append("<TR"); 139 if (align != null) 140 html.append(" ALIGN=" + align); 141 if (valign != null) 142 html.append(" VALIGN=" + valign); 143 if (colSpan > 0) 144 html.append(" COLSPAN=" + colSpan); 145 if (rowSpan > 0) 146 html.append(" ROWSPAN=" + rowSpan); 147 if (bgColor != null) 148 html.append(" BGCOLOR=" + bgColor); 149 html.append(">\n"); 150 151 Enumeration e = row.elements(); 152 while (e.hasMoreElements()) { 153 html.append(e.nextElement().toString()); 154 } 155 html.append("</TR>\n"); 156 157 return html.toString(); 158 } 159 } 160 | Popular Tags |