Printing comma-aligned doubles to printer device with Java -
for project need print numbers printer. need printed below eachother, aligned on comma. font not , can not monospaced one. i'm using decimalformat("0.000") transform numbers strings ending in 3 decimals.
what right way align numbers on comma, below eachother? i'm using java's printable interface, explained here http://docs.oracle.com/javase/tutorial/2d/printing/index.html.
thanks
edit: i'm not trying print console, printer (the actual hardware thing real paper comes out)
this improve monospaced font.
i'm assuming comma decimal point. here's do.
generate comma image using drawstring.
break number 2 parts, number before decimal, , number after decimal.
generate number images before decimal , number after decimal using drawstring.
after numbers converted images, go through numbers after decimal images see 1 has longest width.
you have number of pixels of width longest numbers after decimal, , comma.
go through number images again, drawing images on printer canvas in next order.
number after decimal comma number before decimal java printing alignment
No comments:
Post a Comment