CoordinateUtilities { public static Integer getUiColumnIndex(final GridWidget gridWidget, final double relativeX) { final GridData gridModel = gridWidget.getModel(); final BaseGridRendererHelper rendererHelper = gridWidget.getRendererHelper(); if (relativeX < 0 || relativeX > gridWidget.getWidth()) { return null; } final BaseGridRendererHelper.ColumnInformation ci = rendererHelper.getColumnInformation(relativeX); final GridColumn<?> uiColumn = ci.getColumn(); final int uiColumnIndex = ci.getUiColumnIndex(); if (uiColumn == null) { return null; } if (uiColumnIndex < 0 || uiColumnIndex > gridModel.getColumnCount() - 1) { return null; } return uiColumnIndex; }  static Point2D convertDOMToGridCoordinate(final GridWidget view,
                                                     final Point2D point); static Integer getUiRowIndex(final GridWidget gridWidget,
                                        final double relativeY); static Integer getUiColumnIndex(final GridWidget gridWidget,
                                           final double relativeX); static Integer getUiHeaderRowIndex(final GridWidget gridWidget,
                                              final Point2D rp); static int getRelativeXOfEvent(final DomEvent event); static int getRelativeYOfEvent(final DomEvent event);  }
@Test public void testGetUiColumnIndexBeforeWidget() throws Exception { setupGridWidget(); final Integer columnIndex = CoordinateUtilities.getUiColumnIndex(view, -1); Assertions.assertThat(columnIndex).isNull(); }
@Test public void testGetUiColumnIndexAfterWidgetHeader() throws Exception { setupGridWidget(); final Integer columnIndex = CoordinateUtilities.getUiColumnIndex(view, view.getWidth() + 1); Assertions.assertThat(columnIndex).isNull(); }
@Test @SuppressWarnings("unchecked") public void testGetUiColumnIndexInHeaderAfterLastColumn() throws Exception { gridData.appendColumn(new BaseGridColumn<>(new BaseHeaderMetaData("first"), gridColumnRenderer, COLUMN_WIDTH)); gridData.appendColumn(new BaseGridColumn<>(new BaseHeaderMetaData("second"), gridColumnRenderer, COLUMN_WIDTH)); gridData.appendColumn(new BaseGridColumn<>(new BaseHeaderMetaData("third"), gridColumnRenderer, COLUMN_WIDTH)); setupGridWidget(); doReturn(gridSelectionManager).when(view).getLayer(); final Integer columnIndex = CoordinateUtilities.getUiColumnIndex(view, (COLUMN_WIDTH * 3) + 1); Assertions.assertThat(columnIndex).isNull(); }