Fixed formatting for small column headers

Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
2017-07-04 18:00:53 +02:00
parent 3e175712c3
commit 3945e41a8c

View File

@ -26,9 +26,15 @@ public class MainAnalysis {
for (String article : articleNames) { for (String article : articleNames) {
if (article.equals("total")) continue; if (article.equals("total")) continue;
int colSize = article.length(); int colSize = article.length();
int fillUp = 0;
if (colSize < 7) {
fillUp = 7 - colSize;
colSize = 7;
}
columnHeaderEdge.append(new String(new char[colSize + 2]).replace('\0', '-')).append("+"); columnHeaderEdge.append(new String(new char[colSize + 2]).replace('\0', '-')).append("+");
leftAlignFormat.append(" %").append(colSize).append("d |"); leftAlignFormat.append(" %").append(colSize).append("d |");
columnHeader.append(" ").append(article).append(" |"); columnHeader.append(" ").append(article).append(new String(new char[fillUp]).replace('\0', ' '))
.append(" |");
} }
columnHeaderEdge.append("---------+%n"); columnHeaderEdge.append("---------+%n");
leftAlignFormat.append(" %7d |%n"); leftAlignFormat.append(" %7d |%n");