BaseGridRenderer implements GridRenderer { @Override public List<RendererCommand> renderHeader(final GridData model, final GridHeaderRenderContext context, final BaseGridRendererHelper rendererHelper, final BaseGridRendererHelper.RenderingInformation renderingInformation) { final List<RendererCommand> commands = new ArrayList<>(); final int headerRowCount = renderingInformation.getHeaderRowCount(); if (headerRowCount == 0) { return commands; } final List<GridColumn<?>> allBlockColumns = context.getAllColumns(); final List<GridColumn<?>> visibleBlockColumns = context.getBlockColumns(); final double headerRowsHeight = renderingInformation.getHeaderRowsHeight(); final double headerRowsYOffset = renderingInformation.getHeaderRowsYOffset(); double cx = 0; for (final GridColumn<?> column : visibleBlockColumns) { if (column.isVisible()) { final double x = cx; final double w = column.getWidth(); Rectangle header; if (column.isLinked()) { header = theme.getHeaderLinkBackground(column); } else { header = theme.getHeaderBackground(column); } if (header != null) { commands.add((RenderHeaderBackgroundCommand) (rc) -> { if (columnRenderingConstraint.apply(rc.isSelectionLayer(), column)) { header.setWidth(w) .setListening(true) .setHeight(headerRowsHeight) .setY(headerRowsYOffset) .setX(x); rc.getGroup().add(header); } }); } cx = cx + w; } } cx = 0; for (final GridColumn<?> column : visibleBlockColumns) { if (column.isVisible()) { final double columnWidth = column.getWidth(); final int columnIndex = visibleBlockColumns.indexOf(column); final GridHeaderColumnRenderContext headerCellRenderContext = new GridHeaderColumnRenderContext(cx, allBlockColumns, visibleBlockColumns, columnIndex, model, this); commands.addAll(column.getColumnRenderer().renderHeader(column.getHeaderMetaData(), headerCellRenderContext, renderingInformation, columnRenderingConstraint)); cx = cx + columnWidth; } } cx = 0; for (final GridColumn<?> column : visibleBlockColumns) { if (column.isVisible()) { final double x = cx; final double w = column.getWidth(); if (column.isLinked()) { commands.add((RenderHeaderContentCommand) (rc) -> { if (columnRenderingConstraint.apply(rc.isSelectionLayer(), column)) { final Text t = theme.getBodyText() .setFontFamily(LINK_FONT_FAMILY) .setFontSize(LINK_FONT_SIZE) .setText(LINK_ICON) .setY(headerRowsYOffset + LINK_FONT_SIZE) .setX(x + w - LINK_FONT_SIZE); rc.getGroup().add(t); } }); } cx = cx + w; } } commands.add(renderHeaderBodyDivider(rendererHelper.getWidth(visibleBlockColumns))); return commands; } BaseGridRenderer(final GridRendererTheme theme); @Override double getHeaderHeight(); @Override double getHeaderRowHeight(); @Override GridRendererTheme getTheme(); @Override void setTheme(final GridRendererTheme theme); @Override RendererCommand renderSelector(final double width,
                                          final double height,
                                          final BaseGridRendererHelper.RenderingInformation renderingInformation); @Override RendererCommand renderSelectedCells(final GridData model,
                                               final GridBodyRenderContext context,
                                               final BaseGridRendererHelper rendererHelper,
                                               final List<GridData.SelectedCell> selectedCells,
                                               final BiFunction<SelectedRange, Integer, Double> selectedCellsYOffsetStrategy,
                                               final Function<SelectedRange, Double> selectedCellsHeightStrategy); @Override List<RendererCommand> renderHeader(final GridData model,
                                              final GridHeaderRenderContext context,
                                              final BaseGridRendererHelper rendererHelper,
                                              final BaseGridRendererHelper.RenderingInformation renderingInformation); @Override RendererCommand renderHeaderBodyDivider(final double width); @Override List<RendererCommand> renderBody(final GridData model,
                                            final GridBodyRenderContext context,
                                            final BaseGridRendererHelper rendererHelper,
                                            final BaseGridRendererHelper.RenderingInformation renderingInformation); @Override RendererCommand renderGridBoundary(final GridBoundaryRenderContext context); @Override boolean onGroupingToggle(double cellX,
                                    double cellY,
                                    double cellWidth,
                                    double cellHeight); @Override void setColumnRenderConstraint(final BiFunction<Boolean, GridColumn<?>, Boolean> columnRenderingConstraint); void clearCellHighlight(); void highlightCell(final int column, final int row); Integer getHighlightCellColumnIndex(); Integer getHighlightCellRowIndex();  }
@Test public void checkRenderHeaderWhenColumnsHaveNoMetaData() { column.getHeaderMetaData().clear(); final RenderingInformation ri = makeRenderingInformation(model); final GridHeaderRenderContext context = mock(GridHeaderRenderContext.class); final List<GridRenderer.RendererCommand> commands = renderer.renderHeader(model, context, rendererHelper, ri); assertThat(commands).isNotNull(); assertThat(commands).asList().hasSize(0); }