at.setPaddingLeftRight(1); CWC_LongestLine cwc = new CWC_LongestLine(); at.getRenderer().setCWC(cwc);
/** * Renders an {@link AsciiTable}. * @param rows table rows to render, cannot be null * @param colNumbers number of columns in the table * @param ctx context of the original table with relevant settings, cannot be null * @param width maximum line width, excluding any extra padding * @return a single string with the rendered table * @throws {@link NullPointerException} if rows or context where null */ default String render(LinkedList<AT_Row> rows, int colNumbers, AT_Context ctx, int width){ Validate.notNull(rows); Validate.notNull(ctx); Collection<StrBuilder> coll = this.renderAsCollection(rows, colNumbers, ctx, width); String fileSeparator = this.getLineSeparator(); if(fileSeparator==null){ fileSeparator = ctx.getLineSeparator(); } if(fileSeparator==null){ fileSeparator = System.lineSeparator(); } return new StrBuilder().appendWithSeparators(coll, fileSeparator).build(); }
/** * Renders an {@link AsciiTable}. * @param rows table rows to render, cannot be null * @param colNumbers number of columns in the table * @param ctx context of the original table with relevant settings, cannot be null * @return a single string with the rendered table * @throws {@link NullPointerException} if rows or context where null */ default String render(LinkedList<AT_Row> rows, int colNumbers, AT_Context ctx){ Validate.notNull(rows); Validate.notNull(ctx); return this.render(rows, colNumbers, ctx, ctx.getWidth()); }
/** * Renders an {@link AsciiTable}. * @param rows table rows to render, cannot be null * @param colNumbers number of columns in the table * @param ctx context of the original table with relevant settings, cannot be null * @return collection of lines, each as a {@link StrBuilder} * @throws {@link NullPointerException} if rows or context where null */ default Collection<StrBuilder> renderAsCollection(LinkedList<AT_Row> rows, int colNumbers, AT_Context ctx){ Validate.notNull(rows); Validate.notNull(ctx); return this.renderAsCollection(rows, colNumbers, ctx, ctx.getWidth()); }
int[] colWidth = this.getCWC().calculateColumnWidths(rows, colNumbers, ctx.getTextWidth(width));
/** * Renders an {@link AsciiTable}. * @param rows table rows to render, cannot be null * @param colNumbers number of columns in the table * @param ctx context of the original table with relevant settings, cannot be null * @param width maximum line width, excluding any extra padding * @return a single string with the rendered table * @throws {@link NullPointerException} if rows or context where null */ default String render(LinkedList<AT_Row> rows, int colNumbers, AT_Context ctx, int width){ Validate.notNull(rows); Validate.notNull(ctx); Collection<StrBuilder> coll = this.renderAsCollection(rows, colNumbers, ctx, width); String fileSeparator = this.getLineSeparator(); if(fileSeparator==null){ fileSeparator = ctx.getLineSeparator(); } if(fileSeparator==null){ fileSeparator = System.lineSeparator(); } return new StrBuilder().appendWithSeparators(coll, fileSeparator).build(); }
/** * Renders an {@link AsciiTable}. * @param rows table rows to render, cannot be null * @param colNumbers number of columns in the table * @param ctx context of the original table with relevant settings, cannot be null * @return a single string with the rendered table * @throws {@link NullPointerException} if rows or context where null */ default String render(LinkedList<AT_Row> rows, int colNumbers, AT_Context ctx){ Validate.notNull(rows); Validate.notNull(ctx); return this.render(rows, colNumbers, ctx, ctx.getWidth()); }
/** * Renders an {@link AsciiTable}. * @param rows table rows to render, cannot be null * @param colNumbers number of columns in the table * @param ctx context of the original table with relevant settings, cannot be null * @return collection of lines, each as a {@link StrBuilder} * @throws {@link NullPointerException} if rows or context where null */ default Collection<StrBuilder> renderAsCollection(LinkedList<AT_Row> rows, int colNumbers, AT_Context ctx){ Validate.notNull(rows); Validate.notNull(ctx); return this.renderAsCollection(rows, colNumbers, ctx, ctx.getWidth()); }
int[] colWidth = this.getCWC().calculateColumnWidths(rows, colNumbers, ctx.getTextWidth(width));
private static void printGenericTable(String title, List<String> messages) { AsciiTable table = new AsciiTable(); table.addRule(); table.addRow(null, title + ": " + messages.size()).getCells().get(1).getContext().setTextAlignment(TextAlignment.CENTER); table.addRule(); int count = 1; for (String mess : messages) { table.addRow("#" + count, mess).getCells().get(0).getContext().setTextAlignment(TextAlignment.CENTER); table.addRule(); count ++; } table.getContext().setGrid(A7_Grids.minusBarPlusEquals()); table.getRenderer().setCWC(new CWC_LongestWordMin(new int[]{5, 101})); table.renderAsCollection().forEach(SDLogger::info); }
@Override public String render(){ return this.renderer.render(this.getRawContent(), this.getColNumber(), this.ctx); // return new StrBuilder().appendWithSeparators(this.renderer.render(this.getRawContent(), this.getColNumber(), this.ctx), "\n").toString(); }
@Override public Collection<String> renderAsCollection(){ return ClusterElementTransformer.create().transform( this.renderer.renderAsCollection(this.getRawContent(), this.getColNumber(), this.ctx), StrBuilder_To_String.create(), ArrayListStrategy.create() ); }
generatedTable.getRenderer().setCWC(new CWC_LongestWordMin(new int[]{20, 68, 17})); generatedTable.renderAsCollection().forEach(SDLogger::info);
@Override public String render(int width){ return this.renderer.render(this.getRawContent(), this.getColNumber(), this.ctx, width); // return new StrBuilder().appendWithSeparators(this.renderer.render(this.getRawContent(), this.getColNumber(), this.ctx, this.ctx.getTextWidth(width)), "\n").toString(); }
@Override public Collection<String> renderAsCollection(){ return ClusterElementTransformer.create().transform( this.renderer.renderAsCollection(this.getRawContent(), this.getColNumber(), this.ctx), StrBuilder_To_String.create(), ArrayListStrategy.create() ); }
@Override public String render(int width){ return this.renderer.render(this.getRawContent(), this.getColNumber(), this.ctx, width); // return new StrBuilder().appendWithSeparators(this.renderer.render(this.getRawContent(), this.getColNumber(), this.ctx, this.ctx.getTextWidth(width)), "\n").toString(); }
@Override public Collection<String> renderAsCollection(int width){ return ClusterElementTransformer.create().transform( this.renderer.renderAsCollection(this.getRawContent(), this.getColNumber(), this.ctx, this.ctx.getTextWidth(width)), StrBuilder_To_String.create(), ArrayListStrategy.create() ); }
@Override public String render(){ return this.renderer.render(this.getRawContent(), this.getColNumber(), this.ctx); // return new StrBuilder().appendWithSeparators(this.renderer.render(this.getRawContent(), this.getColNumber(), this.ctx), "\n").toString(); }
@Override public Collection<String> renderAsCollection(int width){ return ClusterElementTransformer.create().transform( this.renderer.renderAsCollection(this.getRawContent(), this.getColNumber(), this.ctx, this.ctx.getTextWidth(width)), StrBuilder_To_String.create(), ArrayListStrategy.create() ); }