X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Foutput%2FDataTable.java;h=0a30180070b13e0f27bdb309101abda4f828063f;hb=8f5c95aa7beae740cbc43bf3958e14eb98d7eb36;hp=60893b0446ef0875453168059abbc0a4881c527e;hpb=c29a2359a3e34c7c131d1d05b601ce9e20eb1a76;p=gigi.git diff --git a/src/org/cacert/gigi/output/DataTable.java b/src/org/cacert/gigi/output/DataTable.java index 60893b04..0a301800 100644 --- a/src/org/cacert/gigi/output/DataTable.java +++ b/src/org/cacert/gigi/output/DataTable.java @@ -15,22 +15,23 @@ public class DataTable implements Outputable { this.cells = content; } - @Override - public void output(PrintWriter out, Language l, Map vars) { - int mesCells = cells.size(); + public void output(PrintWriter out, Language l) { + float mesCells = cells.size(); for (Cell c : cells) { if (c.getColSpan() > 1) { mesCells += c.getColSpan(); } } out.println(""); - for (int i = 0; i < mesCells / columnCount; i++) { + int cellsRendered = 0; + for (int i = 0; i < Math.ceil(mesCells / columnCount) - 1; i++) { out.println(""); for (int j = 0; j < columnCount;) { - Cell current = cells.get((i * columnCount) + j); + Cell current = cells.get(cellsRendered++); j += current.getColSpan(); - out.println(""); @@ -40,12 +41,6 @@ public class DataTable implements Outputable { out.println("
"); + out.println(""); out.print(current.shouldTranslate() ? l.getTranslation(current .getText()) : current.getText()); out.print("
"); } - /** - * Note: All cells have the html attribute class="DataTD"! - * - * @author janis - * - */ public static class Cell { private String text, htmlAttribs; private boolean translate; @@ -60,15 +55,18 @@ public class DataTable implements Outputable { this.text = text; this.translate = translate; this.htmlAttribs = htmlAttribs; + if (colSpan > 1) { + this.htmlAttribs += " colspan=\"" + colSpan + "\""; + } this.colSpan = colSpan; } public Cell(String text, boolean translate) { - this(text, translate, 1, ""); + this(text, translate, 1, "class=\"DataTD\""); } public Cell(String text, boolean translate, int colSpan) { - this(text, translate, colSpan, ""); + this(text, translate, colSpan, "class=\"DataTD\""); } public boolean shouldTranslate() { @@ -89,4 +87,9 @@ public class DataTable implements Outputable { } + @Override + public void output(PrintWriter out, Language l, Map vars) { + output(out, l); + } + }