Padding: Row

The padding of text can be set for individual table cells.

The following code creates a table, adds text objects, and then changes the padding for the last cell in second row leaving all other cells to the default (no padding).

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_Cell cell = at.addRow("row 2 col 1", "row 2 col 2").getCells().get(1);
at.addRule();

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

The resulting output:

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