/** * Creates a new ASCII table with given context. * @param ctx the table context, default context created if null */ public AsciiTable(AT_Context ctx){ if(ctx!=null){ this.ctx = ctx; } else{ this.ctx = new AT_Context(); } }
@Override public int getTextWidth(int width) { int ret = width - this.getFrameLeftMargin() - this.getFrameRightMargin(); return ret; }
int[] colWidth = this.getCWC().calculateColumnWidths(rows, colNumbers, ctx.getTextWidth(width)); ArrayList<StrBuilder> ret = ctx.getGrid().addGrid(table, ctx.getGridTheme() | ctx.getGridThemeOptions()); int max = ret.get(0).length() + ctx.getFrameLeftMargin() + ctx.getFrameRightMargin(); for (StrBuilder sb : ret){ sb.insert(0, new StrBuilder().appendPadding(ctx.getFrameLeftMargin(), ctx.getFrameLeftChar())); sb.appendPadding(ctx.getFrameRightMargin(), ctx.getFrameRightChar()); for(int k=0; k<ctx.getFrameTopMargin(); k++){ ret.add(0, new StrBuilder().appendPadding(max, ctx.getFrameTopChar())); for(int k=0; k<ctx.getFrameBottomMargin(); k++){ ret.add(new StrBuilder().appendPadding(max, ctx.getFrameBottomChar()));
int[] colWidth = this.getCWC().calculateColumnWidths(rows, colNumbers, ctx.getTextWidth(width)); ArrayList<StrBuilder> ret = ctx.getGrid().addGrid(table, ctx.getGridTheme() | ctx.getGridThemeOptions()); int max = ret.get(0).length() + ctx.getFrameLeftMargin() + ctx.getFrameRightMargin(); for (StrBuilder sb : ret){ sb.insert(0, new StrBuilder().appendPadding(ctx.getFrameLeftMargin(), ctx.getFrameLeftChar())); sb.appendPadding(ctx.getFrameRightMargin(), ctx.getFrameRightChar()); for(int k=0; k<ctx.getFrameTopMargin(); k++){ ret.add(0, new StrBuilder().appendPadding(max, ctx.getFrameTopChar())); for(int k=0; k<ctx.getFrameBottomMargin(); k++){ ret.add(new StrBuilder().appendPadding(max, ctx.getFrameBottomChar()));
@Override public int getTextWidth(int width) { int ret = width - this.getFrameLeftMargin() - this.getFrameRightMargin(); return ret; }
/** * Creates a new ASCII table with given context. * @param ctx the table context, default context created if null */ public AsciiTable(AT_Context ctx){ if(ctx!=null){ this.ctx = ctx; } else{ this.ctx = new AT_Context(); } }