BaseGridRenderer implements GridRenderer { void setCellHighlightX(final Rectangle r, final GridBodyRenderContext context, final BaseGridRendererHelper rendererHelper) { double columnOffsetX = context.getAbsoluteColumnOffsetX(); double x = rendererHelper.getColumnOffset(getHighlightCellColumnIndex()) - columnOffsetX; r.setX(x); } 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 setCellHighlightX() { final RenderingInformation renderingInformation = mock(RenderingInformation.class); final RenderingBlockInformation floatingBlockInformation = mock(RenderingBlockInformation.class); final List<GridColumn<?>> fakeList = mock(List.class); when(floatingBlockInformation.getColumns()).thenReturn(fakeList); when(fakeList.size()).thenReturn(1); final Rectangle rectangle = mock(Rectangle.class); final double columnOffsetX = 77; final int columnIndex = 3; final double xOffset = 128; final double expectedOffset = xOffset - columnOffsetX; when(renderingInformation.getFloatingBlockInformation()).thenReturn(floatingBlockInformation); when(context.getAbsoluteColumnOffsetX()).thenReturn(columnOffsetX); final GridColumn<?> column = mock(GridColumn.class); when(column.getIndex()).thenReturn(columnIndex); when(rendererHelper.getColumnOffset(columnIndex)).thenReturn(xOffset); renderer.highlightCell(columnIndex, 0); renderer.setCellHighlightX(rectangle, context, rendererHelper); verify(rectangle).setX(expectedOffset); }