java.lang.Object
io.github.chkrishnatej.rp3200.Columns
A column layout for table-like rows such as
Item | Qty | Amount.
Written as a compact spec string, one entry per column, separated by commas:
| Entry | Meaning |
|---|---|
10 | 10 characters wide, left aligned |
10r | 10 characters wide, right aligned (use for numbers) |
10c | 10 characters wide, centred |
* / *r / *c | takes the remaining width; several
* columns share it equally |
Columns are separated by one space (withGap(int) changes that). Text that does not
fit is word-wrapped inside its own column. Widths are in normal-size characters; the whole
row must fit the profile's PrinterProfile.charsPerLine() (48 on 80 mm, 32 on 58 mm).
// 80 mm: name gets 48 - 4 - 9 - 10 - 3 gaps = 22 characters
Columns items = Columns.parse("*,4r,9r,10r");
builder.row(items, "Item", "Qty", "Rate", "Amount");
Immutable and thread-safe: parse once and reuse. In templates the same spec is written as
[cols *,4r,9r,10r].
-
Method Summary
-
Method Details
-
parse
Parses a column spec such as"*,4r,10r". Spaces around entries are ignored.- Parameters:
spec- comma-separated column entries, see the class description- Returns:
- the layout
- Throws:
IllegalArgumentException- if the spec is empty or an entry is malformed
-
withGap
Returns a copy with a different number of spaces between columns (default 1).- Parameters:
spaces- spaces between neighbouring columns, 0 or more- Returns:
- the new layout
- Throws:
IllegalArgumentException- ifspacesis negative
-
size
public int size()Returns the number of columns.- Returns:
- the column count
-