1 package org.cacert.gigi.output;
3 import java.io.PrintWriter;
4 import java.util.LinkedList;
7 import org.cacert.gigi.Language;
9 public class DataTable implements Outputable {
10 private LinkedList<Cell> cells;
11 private int columnCount;
13 public DataTable(int coloumnCount, LinkedList<Cell> content) {
14 this.columnCount = coloumnCount;
19 public void output(PrintWriter out, Language l, Map<String, Object> vars) {
20 int mesCells = cells.size();
21 for (Cell c : cells) {
22 if (c.getColSpan() > 1) {
23 mesCells += c.getColSpan();
26 out.println("<table align=\"center\" valign=\"middle\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"wrapper\">");
27 for (int i = 0; i < mesCells / columnCount; i++) {
29 for (int j = 0; j < columnCount;) {
30 Cell current = cells.get((i * columnCount) + j);
31 j += current.getColSpan();
32 out.println("<td " + current.getHtmlAttribs()
33 + " class=\"DataTD\">");
34 out.print(current.shouldTranslate() ? l.getTranslation(current
35 .getText()) : current.getText());
40 out.println("</table>");
44 * <b>Note:</b> All cells have the html attribute class="DataTD"!
49 public static class Cell {
50 private String text, htmlAttribs;
51 private boolean translate;
55 this(" ", false);
58 public Cell(String text, boolean translate, int colSpan,
61 this.translate = translate;
62 this.htmlAttribs = htmlAttribs;
63 this.colSpan = colSpan;
66 public Cell(String text, boolean translate) {
67 this(text, translate, 1, "");
70 public Cell(String text, boolean translate, int colSpan) {
71 this(text, translate, colSpan, "");
74 public boolean shouldTranslate() {
78 public String getText() {
82 public int getColSpan() {
86 public String getHtmlAttribs() {