⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tableprimitive.java

📁 考勤管理系统源码
💻 JAVA
字号:
package com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.Layout;import com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.Core.*;import java.util.*;/** The TablePrimitive class encapsulates the details of building the HTML  *  for a table. */public class TablePrimitive implements IHtmlPrimitive{  private HAlignment tableHorizontalAlignment;  private VAlignment tableVerticalAlignment;  private Style tableStyle;  private Style cellStyle;  private HAlignment cellHorizontalAlignment;  private VAlignment cellVerticalAlignment;  private int cellColumnSpan = -1;  private HashMap rows = new HashMap();  private int maxRow = -1;  /** Construct an empty TablePrimitive.*/  public TablePrimitive()  {  }  /** Set the style for the entire table. */  public void setStyle(Style style)  {    this.tableStyle = style;  }  /** Set the horizontal and vertical alignment of the table. */  public void setAlignment(HAlignment horizontalAlignment, VAlignment verticalAlignment)  {    this.tableHorizontalAlignment = horizontalAlignment;    this.tableVerticalAlignment = verticalAlignment;  }  /** Specify the style class that is applied to the specified row. */  public void setStyleForRow(int rowIndex, Style style)  {    getRow(rowIndex).setStyle(style);  }  /** Specify the alignment for the specified row */  public void setAlignmentForRow(int rowIndex, HAlignment horizontalAlignment, VAlignment verticalAlignment)  {    getRow(rowIndex).setAlignment(horizontalAlignment, verticalAlignment);  }  /** Specify the style class that is applied to cells as primitives are added to them. */  public void setStyleForCells(Style style)  {    this.cellStyle = style;  }  /** Reset the style class that is applied to cells as primitives are added to them. */  public void resetStyleForCells()  {    this.cellStyle = null;  }  /** Specify the alignment that is applied to cells as primitives are added to them. */  public void setAlignmentForCells(HAlignment horizontalAlignment, VAlignment verticalAlignment)  {    this.cellHorizontalAlignment = horizontalAlignment;    this.cellVerticalAlignment = verticalAlignment;  }  /** Reset the alignment that is applied to cells as primitives are added to them. */  public void resetAlignmentForCells()  {    this.cellHorizontalAlignment = null;    this.cellVerticalAlignment = null;  }  /** Specify the column span that is applied to cells as primitives are added to them. */  public void setColumnSpanForCells(int columnSpan)  {    this.cellColumnSpan = columnSpan;  }  /** Reset the column span that is applied to cells as primitives are added to them. */  public void resetColumnSpanForCells()  {    this.cellColumnSpan = -1;  }  /** Insert the specified primitive at the specified location. */  public void setPrimitiveAt(int rowIndex, int colIndex, IHtmlPrimitive primitive)  {    CellPrimitive cell = new CellPrimitive(primitive);    cell.setAlignment(cellHorizontalAlignment, cellVerticalAlignment);    cell.setColumnSpan(cellColumnSpan);    cell.setStyle(cellStyle);    RowPrimitive row = getRow(rowIndex);    row.setCellAt(colIndex, cell);  }  /** Build the content for this primitive and append it to the specified buffer.*/  public void buildContent(StringBuffer buffer)  {    String class_string = Formatting.convertToAttribute("class", tableStyle);    String align_string = Formatting.convertToAttribute("align", tableHorizontalAlignment);    String valign_string = Formatting.convertToAttribute("valign", tableVerticalAlignment);    buffer.append("<table" +class_string+align_string+valign_string+ ">\n");    int ctr = 0;    while (ctr <= maxRow)    {      RowPrimitive row = (RowPrimitive) rows.get(""+ctr);      if (row != null)      {        row.buildContent(buffer);        buffer.append("\n");      }      else      {        buffer.append("<tr></tr>\n");      }      ctr++;    }    buffer.append("</table>\n");  }  private RowPrimitive getRow(int row_index)  {    String key = ""+row_index;    if (!rows.containsKey(key))    {      RowPrimitive row = new RowPrimitive();      rows.put(key, row);      maxRow = Math.max(maxRow, row_index);    }    return (RowPrimitive) rows.get(key);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -