Padding: Table

Inside a cell, the padding for top and bottom (above and below cell text) as well as left and right (horizontally before and after each line of text) can be set separately. The character used for the padding can be set as well.

The following code shows how to set the padding for the whole table. First, we create a table and add content (rows with cells and text). Then we set the padding and the padding character for the whole table.

Note: settings for the whole table only effect cells that have been already added.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
AsciiTable at = new AsciiTable();
at.addRule();
at.addRow("row 1 col 1", "row 1 col 2");
at.addRule();
at.addRow("row 2 col 1", "row 2 col 2");
at.addRule();

at.setPaddingTopChar('v');
at.setPaddingBottomChar('^');
at.setPaddingLeftChar('>');
at.setPaddingRightChar('<');
at.setTextAlignment(TextAlignment.CENTER);
at.setPadding(1);
System.out.println(at.render(33));

The resulting output:

┌───────────────┬───────────────┐
│vvvvvvvvvvvvvvv│vvvvvvvvvvvvvvv│
│> row 1 col 1 <│> row 1 col 2 <│
│^^^^^^^^^^^^^^^│^^^^^^^^^^^^^^^│
├───────────────┼───────────────┤
│vvvvvvvvvvvvvvv│vvvvvvvvvvvvvvv│
│> row 2 col 1 <│> row 2 col 2 <│
│^^^^^^^^^^^^^^^│^^^^^^^^^^^^^^^│
└───────────────┴───────────────┘