MitchTalmadge / ASCII-Data

A small Java library for producing nice looking text-based line-graphs and tables.
Apache License 2.0
120 stars 13 forks source link

Table align option #13

Closed sebkur closed 5 years ago

sebkur commented 5 years ago

For the tables, it would be really useful to have an option on the ASCIITable class to set a column's justification, so that we can create tables with centered or right-aligned content. What do you think about it?

Examples

Instead of this:

╔═══════════╤══════════╗
║ FirstName │ LastName ║
╠═══════════╪══════════╣
║ Foo       │ Bar      ║
╟───────────┼──────────╢
║ Kit       │ Kat      ║
╚═══════════╧══════════╝

I sometimes prefer this:

╔═══════════╤══════════╗
║ FirstName │ LastName ║
╠═══════════╪══════════╣
║ Foo       │      Bar ║
╟───────────┼──────────╢
║ Kit       │      Kat ║
╚═══════════╧══════════╝

Escpecially when numbers are involved:

╔═══════════╤══════════╗
║ Name      │ Score    ║
╠═══════════╪══════════╣
║ Foo       │        5 ║
╟───────────┼──────────╢
║ Kit       │      123 ║
╚═══════════╧══════════╝
sebkur commented 5 years ago

Partially implemented in #15

MitchTalmadge commented 5 years ago

Merged, will release 1.4.0 when I get a chance.