Grids

The frame of a table is called grid in the implementation. The grid is based on the TA_Grid implementation in the package ascii-utf-themes. The package also provides a number of predefined grids using standard 7-Bit ASCII characters, standard 8-Bit ASCII characters, and UTF characters.

The following example creates a table and renders it (then using the default grid). The we change the grid 4 times and render the table, resulting in different grids being used.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
AsciiTable at = new AsciiTable();
at.addRule();
at.addRow("rc 11", "rc 12");
at.addRule();
at.addRow("rc 21", "rc 22");
at.addRule();
at.getContext().setWidth(13);

System.out.println(at.render());

at.getContext().setGrid(A7_Grids.minusBarPlusEquals());
System.out.println(at.render());

at.getContext().setGrid(A8_Grids.lineDoubleBlocks());
System.out.println(at.render());

at.getContext().setGrid(U8_Grids.borderDoubleLight());
System.out.println(at.render());

at.getContext().setGrid(U8_Grids.borderDouble());
System.out.println(at.render());

The resulting output (all 5 rendered tables next to each other):

┌─────┬─────┐      +-----+-----+      ═════════════      ╒═════╤═════╕      ╔═════╦═════╗
│rc 11│rc 12│      |rc 11|rc 12|       rc 11 rc 12       │rc 11│rc 12│      ║rc 11║rc 12║
├─────┼─────┤      +-----+-----+      ═════════════      ╞═════╪═════╡      ╠═════╬═════╣
│rc 21│rc 22│      |rc 21|rc 22|       rc 21 rc 22       │rc 21│rc 22│      ║rc 21║rc 22║
└─────┴─────┘      +-----+-----+      ═════════════      ╘═════╧═════╛      ╚═════╩═════╝