/** * Create a renderer for the specified width and height or return null if the element does not provide any output * for the specified dimensions. The default implementation delegates to the {@link #reader(int)} method when the * <code>height</code> argument is not positive otherwise it returns null. Subclasses should override this method * when they want to provide content that can adapts to the specified height. * * @param width the width * @param height the height * @return the renderer */ public LineReader reader(int width, int height) { if (height > 0) { return null; } else { return reader(width); } }
for (int i = 0;i < readers.length;i++) { Renderer renderer = cols.get(i); LineReader reader = renderer.reader(widths[i] - leftCellPadding - rightCellPadding, height); readers[i] = reader;
public boolean hasLine() { if (height > 0 && index >= height) { return false; } else { if (current == null || !current.hasLine()) { while (i.hasNext()) { Renderer next = i.next(); LineReader reader = next.reader(width); if (reader != null && reader.hasLine()) { current = reader; return true; } } return false; } else { return true; } } }
/** * Renders this object to the provided output. * * @param out the output */ public final void render(RenderAppendable out) { LineReader renderer = reader(out.getWidth()); if (renderer != null) { while (renderer.hasLine()) { renderer.renderLine(out); out.append('\n'); } } }
public void render(RenderAppendable to) { Renderer renderer = renderer(); // For now height - 1 because of the char that goes to the line in some impl LineReader reader = renderer.reader(to.getWidth(), to.getHeight() - 1); if (reader != null) { while (reader.hasLine()) { reader.renderLine(to); to.append('\n'); } } }
return Renderer.NULL.reader(width);