public TableElement(int ... columns) { this(Layout.flow(), Layout.weighted(columns)); }
@Override public LineReader reader(int width) { int[] widths = new int[cols.size()]; int[] minWidths = new int[cols.size()]; for (int i = 0;i < cols.size();i++) { LineRenderer renderable = cols.get(i); widths[i] = Math.max(widths[i], renderable.getActualWidth()); minWidths[i] = Math.max(minWidths[i], renderable.getMinWidth()); } widths = Layout.flow().compute(false, width, widths, minWidths); if (widths == null) { return null; } else { // Size could be smaller and lead to ArrayIndexOutOfBounds later widths = Arrays.copyOf(widths, minWidths.length); return renderer(widths, -1); } } }
public void testCosmetic() throws Exception { TableElement table = new TableElement(); table.withColumnLayout(Layout.flow()); RowElement row = new RowElement().add(new LabelElement("foo", 5), new LabelElement("This text is larger to be displayed in a cell of 32", 5)); table.add(row); assertRender(table, 32, "fooThis text is larger to be dis", " played in a cell of 32 "); }
public void testCosmeticWithBorder() throws Exception { TableElement table = new TableElement(); table.withColumnLayout(Layout.flow()); RowElement row = new RowElement().add(new LabelElement("foo", 5), new LabelElement("This text is larger to be displayed in a cell of 32", 5)); table.separator(BorderStyle.DASHED); table.border(BorderStyle.DASHED); table.add(row); assertRender(table, 32, " ------------------------------ ", "|foo|This text is larger to be |", "| |displayed in a cell of 32 |", " ------------------------------ "); }
public TableElement(int ... columns) { this(Layout.flow(), Layout.weighted(columns)); }
public TableElement(int ... columns) { this(Layout.flow(), Layout.weighted(columns)); }
public TableElement(int ... columns) { this(Layout.flow(), Layout.weighted(columns)); }
@Override public LineReader reader(int width) { int[] widths = new int[cols.size()]; int[] minWidths = new int[cols.size()]; for (int i = 0;i < cols.size();i++) { LineRenderer renderable = cols.get(i); widths[i] = Math.max(widths[i], renderable.getActualWidth()); minWidths[i] = Math.max(minWidths[i], renderable.getMinWidth()); } widths = Layout.flow().compute(false, width, widths, minWidths); if (widths == null) { return null; } else { // Size could be smaller and lead to ArrayIndexOutOfBounds later widths = Arrays.copyOf(widths, minWidths.length); return renderer(widths, -1); } } }
public void testSimple() throws Exception { TableElement table = new TableElement(); table.withColumnLayout(Layout.flow()); table. add(row(). add(label("a")). add(label("b"))). add(row(). add(label("c")). add(label("d"))); assertRender(table, 2, "ab", "cd"); }
@Override public LineReader reader(int width) { int[] widths = new int[cols.size()]; int[] minWidths = new int[cols.size()]; for (int i = 0;i < cols.size();i++) { Renderer renderable = cols.get(i); widths[i] = Math.max(widths[i], renderable.getActualWidth()); minWidths[i] = Math.max(minWidths[i], renderable.getMinWidth()); } widths = Layout.flow().compute(false, width, widths, minWidths); if (widths == null) { return null; } else { // Size could be smaller and lead to ArrayIndexOutOfBounds later widths = Arrays.copyOf(widths, minWidths.length); return renderer(widths, -1); } } }
@Override public LineReader reader(int width) { int[] widths = new int[cols.size()]; int[] minWidths = new int[cols.size()]; for (int i = 0;i < cols.size();i++) { LineRenderer renderable = cols.get(i); widths[i] = Math.max(widths[i], renderable.getActualWidth()); minWidths[i] = Math.max(minWidths[i], renderable.getMinWidth()); } widths = Layout.flow().compute(false, width, widths, minWidths); if (widths == null) { return null; } else { // Size could be smaller and lead to ArrayIndexOutOfBounds later widths = Arrays.copyOf(widths, minWidths.length); return renderer(widths, -1); } } }
public void testBorderStyle() throws Exception { table.withColumnLayout(Layout.flow()); table.border(BorderStyle.DASHED);
table.withColumnLayout(Layout.flow());
table.withColumnLayout(Layout.flow());
table.withColumnLayout(Layout.flow());
table.withColumnLayout(Layout.flow());