@Override public int getActualWidth() { int width = value != null ? value.getActualWidth() : 0; for (LineRenderer child : children) { width = Math.max(width, 2 + child.getActualWidth()); } return width; }
@Override public int getActualWidth() { int actualWidth = 0; for (int i = 0;i < cols.size();i++) { LineRenderer col = cols.get(i); actualWidth += col.getActualWidth(); actualWidth += leftCellPadding; actualWidth += rightCellPadding; if (separator != null && i > 0) { actualWidth++; } } return actualWidth; }
private Composite(Iterable<? extends LineRenderer> renderers) { int actualWidth = 0; int minWidth = 0; for (LineRenderer renderer : renderers) { actualWidth = Math.max(actualWidth, renderer.getActualWidth()); minWidth = Math.max(minWidth, renderer.getMinWidth()); } this.actualWidth = actualWidth; this.minWidth = minWidth; this.renderers = renderers; }
@Override public LineReader reader(int width) { int[] widths = new int[cols.size()]; int[] minWidths = new int[cols.size()]; for (int i = 0;i < cols.size();i++) { LineRenderer renderable = cols.get(i); widths[i] = Math.max(widths[i], renderable.getActualWidth()); minWidths[i] = Math.max(minWidths[i], renderable.getMinWidth()); } widths = Layout.flow().compute(false, width, widths, minWidths); if (widths == null) { return null; } else { // Size could be smaller and lead to ArrayIndexOutOfBounds later widths = Arrays.copyOf(widths, minWidths.length); return renderer(widths, -1); } } }
@Override public int getActualWidth() { int width = value != null ? value.getActualWidth() : 0; for (LineRenderer child : children) { width = Math.max(width, 2 + child.getActualWidth()); } return width; }
for (int i = 0;i < row.getCols().size();i++) { LineRenderer renderable = row.getCols().get(i); eltWidths[i] = Math.max(eltWidths[i], renderable.getActualWidth() + row.row.leftCellPadding + row.row.rightCellPadding); eltMinWidths[i] = Math.max(eltMinWidths[i], renderable.getMinWidth() + row.row.leftCellPadding + row.row.rightCellPadding);
@Override public int getActualWidth() { int width = value != null ? value.getActualWidth() : 0; for (LineRenderer child : children) { width = Math.max(width, 2 + child.getActualWidth()); } return width; }
@Override public int getActualWidth() { int actualWidth = 0; for (int i = 0;i < cols.size();i++) { LineRenderer col = cols.get(i); actualWidth += col.getActualWidth(); actualWidth += leftCellPadding; actualWidth += rightCellPadding; if (separator != null && i > 0) { actualWidth++; } } return actualWidth; }
@Override public int getActualWidth() { int actualWidth = 0; for (int i = 0;i < cols.size();i++) { LineRenderer col = cols.get(i); actualWidth += col.getActualWidth(); actualWidth += leftCellPadding; actualWidth += rightCellPadding; if (separator != null && i > 0) { actualWidth++; } } return actualWidth; }
private Composite(Iterable<? extends LineRenderer> renderers) { int actualWidth = 0; int minWidth = 0; for (LineRenderer renderer : renderers) { actualWidth = Math.max(actualWidth, renderer.getActualWidth()); minWidth = Math.max(minWidth, renderer.getMinWidth()); } this.actualWidth = actualWidth; this.minWidth = minWidth; this.renderers = renderers; }
private Composite(Iterable<? extends LineRenderer> renderers) { int actualWidth = 0; int minWidth = 0; for (LineRenderer renderer : renderers) { actualWidth = Math.max(actualWidth, renderer.getActualWidth()); minWidth = Math.max(minWidth, renderer.getMinWidth()); } this.actualWidth = actualWidth; this.minWidth = minWidth; this.renderers = renderers; }
@Override public LineReader reader(int width) { int[] widths = new int[cols.size()]; int[] minWidths = new int[cols.size()]; for (int i = 0;i < cols.size();i++) { LineRenderer renderable = cols.get(i); widths[i] = Math.max(widths[i], renderable.getActualWidth()); minWidths[i] = Math.max(minWidths[i], renderable.getMinWidth()); } widths = Layout.flow().compute(false, width, widths, minWidths); if (widths == null) { return null; } else { // Size could be smaller and lead to ArrayIndexOutOfBounds later widths = Arrays.copyOf(widths, minWidths.length); return renderer(widths, -1); } } }
@Override public LineReader reader(int width) { int[] widths = new int[cols.size()]; int[] minWidths = new int[cols.size()]; for (int i = 0;i < cols.size();i++) { LineRenderer renderable = cols.get(i); widths[i] = Math.max(widths[i], renderable.getActualWidth()); minWidths[i] = Math.max(minWidths[i], renderable.getMinWidth()); } widths = Layout.flow().compute(false, width, widths, minWidths); if (widths == null) { return null; } else { // Size could be smaller and lead to ArrayIndexOutOfBounds later widths = Arrays.copyOf(widths, minWidths.length); return renderer(widths, -1); } } }
public void testCellPadding() { TableElement table = new TableElement().leftCellPadding(1).rightCellPadding(2); table.add(new RowElement().add(new LabelElement("foo"), new LabelElement("bar"))); // assertEquals(12, table.renderer().getActualWidth()); assertEquals(8, table.renderer().getMinWidth()); // assertRender(table, 12, " foo bar "); assertRender(table, 11, " foo ba ", " r "); assertRender(table, 10, " foo b ", " a ", " r "); assertRender(table, 9, " foo "); assertRender(table, 8, " foo "); assertRender(table, 7, " foo "); assertRender(table, 6, " foo "); assertRender(table, 5, " fo ", " o "); assertRender(table, 4, " f ", " o ", " o "); // IT SHOULD BE NO RENDER assertRender(table, 3); }
for (int i = 0;i < row.getCols().size();i++) { LineRenderer renderable = row.getCols().get(i); eltWidths[i] = Math.max(eltWidths[i], renderable.getActualWidth() + row.row.leftCellPadding + row.row.rightCellPadding); eltMinWidths[i] = Math.max(eltMinWidths[i], renderable.getMinWidth() + row.row.leftCellPadding + row.row.rightCellPadding);
for (int i = 0;i < row.getCols().size();i++) { LineRenderer renderable = row.getCols().get(i); eltWidths[i] = Math.max(eltWidths[i], renderable.getActualWidth() + row.row.leftCellPadding + row.row.rightCellPadding); eltMinWidths[i] = Math.max(eltMinWidths[i], renderable.getMinWidth() + row.row.leftCellPadding + row.row.rightCellPadding);
assertEquals(6, table.renderer().getActualWidth()); assertEquals(2, table.renderer().getMinWidth());
assertEquals(8, table.renderer().getActualWidth()); assertEquals(4, table.renderer().getMinWidth());
assertEquals(9, table.renderer().getActualWidth()); assertEquals(5, table.renderer().getMinWidth());