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

Add align support #15

Closed sebkur closed 5 years ago

sebkur commented 5 years ago

I added method public ASCIITable align(int column, Align align) that allows us to set the alignment of a column (by index) to Align.RIGHT. I also added a corresponding test.

This is the test example, with column 2 set to Align.RIGHT.

+=====+==============+=====================+
| ID  | Name         | Email               |
|=====|==============|=====================|
| 123 | Alfred Alan  |     aalan@gmail.com |
|-----|--------------|---------------------|
| 223 | Alison Smart |    asmart@gmail.com |
|-----|--------------|---------------------|
| 256 | Ben Bessel   |    benb@outlook.com |
|-----|--------------|---------------------|
| 374 | John Roberts | johnrob@company.com |
+=====+==============+=====================+

Note that I took care not to right-align the header. It's a personal preference, I think it looks better if it is not aligned to the right. Added the disambiguating boolean argument isHeader to appendRow() in order to do that. We could make that configurable, too.

Some notes

MitchTalmadge commented 5 years ago

Wow cool, very well done! Ignore the build error. Do you think it would be a good idea to change the name of the function from align to alignColumn so that later we could add an alignCell function for alignment of a single cell? I think that'd be a nice addition.

Thanks for the contribution!

sebkur commented 5 years ago

Yes, I think renaming to alignColumn makes sense. I'll update the PR

sebkur commented 5 years ago

I pushed a new version a few days ago in case you didn't notice (not sure if you receive a notification about new pushes to my branch)

MitchTalmadge commented 5 years ago

My apologies, I got caught up in work. It looks good!

sebkur commented 5 years ago

Would you make a new release or do you want to wait for more features?

MitchTalmadge commented 5 years ago

Deployed as version 1.4.0, thanks for reminding me!

sebkur commented 5 years ago

Thank you