protected static double getCellHeight(final int rowIndex, final GridData model, final GridCell<?> cell) { return IntStream.range(rowIndex, rowIndex + cell.getMergedCellCount()) .mapToDouble(index -> model.getRow(index).getHeight()) .sum(); }
protected static double getCellHeight(final int rowIndex, final GridData model, final GridCell<?> cell) { return IntStream.range(rowIndex, rowIndex + cell.getMergedCellCount()) .mapToDouble(index -> model.getRow(index).getHeight()) .sum(); }
private int findMinRowIndex(final int rowIndex, final int columnIndex, final int minRowIndex, final GridCell<?> currentRowCell) { int minBlockRowIndex = rowIndex; if (currentRowCell != null) { boolean foundTopSplitMarker = currentRowCell.getMergedCellCount() > 0; while (minBlockRowIndex > minRowIndex) { final GridRow previousRow = gridData.getRow(minBlockRowIndex - 1); final GridCell<?> previousRowCell = previousRow.getCells().get(columnIndex); if (previousRowCell == null) { break; } if (previousRowCell.isCollapsed() && foundTopSplitMarker) { break; } if (!previousRowCell.equals(currentRowCell)) { break; } if (previousRowCell.getMergedCellCount() > 0) { foundTopSplitMarker = true; } minBlockRowIndex--; } } return minBlockRowIndex; }
private double getClippedMergedCellHeight(final int uiRowIndex, final int uiColumnIndex) { final GridCell<?> cell = gridModel.getCell(uiRowIndex, uiColumnIndex); GridCell<?> _cell = cell; int _uiRowIndex = uiRowIndex; while (_cell.getMergedCellCount() == 0) { _uiRowIndex--; _cell = gridModel.getCell(_uiRowIndex, uiColumnIndex); } double height = 0; for (int i = _uiRowIndex; i < _uiRowIndex + _cell.getMergedCellCount(); i++) { height = height + gridModel.getRow(i).getHeight(); } return height; }
private double getClippedMergedCellHeight(final int uiRowIndex, final int uiColumnIndex) { final GridCell<?> cell = gridModel.getCell(uiRowIndex, uiColumnIndex); GridCell<?> _cell = cell; int _uiRowIndex = uiRowIndex; while (_cell.getMergedCellCount() == 0) { _uiRowIndex--; _cell = gridModel.getCell(_uiRowIndex, uiColumnIndex); } double height = 0; for (int i = _uiRowIndex; i < _uiRowIndex + _cell.getMergedCellCount(); i++) { height = height + gridModel.getRow(i).getHeight(); } return height; }
private double getRowOffset(final int uiRowIndex, final int uiColumnIndex, final BaseGridRendererHelper rendererHelper) { final GridCell<?> cell = gridModel.getCell(uiRowIndex, uiColumnIndex); if (cell == null) { return rendererHelper.getRowOffset(uiRowIndex); } if (cell.getMergedCellCount() == 1) { return rendererHelper.getRowOffset(uiRowIndex); } else if (cell.getMergedCellCount() > 1) { return rendererHelper.getRowOffset(uiRowIndex); } else { int _uiRowIndex = uiRowIndex; GridCell<?> _cell = cell; while (_cell.getMergedCellCount() == 0) { _uiRowIndex--; _cell = gridModel.getCell(_uiRowIndex, uiColumnIndex); } return rendererHelper.getRowOffset(_uiRowIndex); } }
private double getMergedCellHeight(final int uiRowIndex, final int uiColumnIndex) { double height = 0; final GridCell<?> cell = gridModel.getCell(uiRowIndex, uiColumnIndex); for (int i = uiRowIndex; i < uiRowIndex + cell.getMergedCellCount(); i++) { height = height + gridModel.getRow(i).getHeight(); } return height; }
private double getMergedCellHeight(final int uiRowIndex, final int uiColumnIndex) { double height = 0; final GridCell<?> cell = gridModel.getCell(uiRowIndex, uiColumnIndex); for (int i = uiRowIndex; i < uiRowIndex + cell.getMergedCellCount(); i++) { height = height + gridModel.getRow(i).getHeight(); } return height; }
private int findMaxRowIndex(final int rowIndex, final int columnIndex, final int maxRowIndex, final GridCell<?> currentRowCell) { int maxBlockRowIndex = rowIndex + 1; boolean foundBottomSplitMarker = false; while (maxBlockRowIndex < maxRowIndex) { final GridRow nextRow = gridData.getRow(maxBlockRowIndex); final GridCell<?> nextRowCell = nextRow.getCells().get(columnIndex); if (nextRowCell == null) { break; } if (nextRowCell.isCollapsed() && foundBottomSplitMarker) { maxBlockRowIndex--; break; } if (!nextRowCell.equals(currentRowCell)) { break; } if (nextRowCell.getMergedCellCount() > 0) { foundBottomSplitMarker = true; } maxBlockRowIndex++; } return maxBlockRowIndex; }
private double getRowOffset(final int uiRowIndex, final int uiColumnIndex, final BaseGridRendererHelper rendererHelper) { final GridCell<?> cell = gridModel.getCell(uiRowIndex, uiColumnIndex); if (cell == null) { return rendererHelper.getRowOffset(uiRowIndex); } if (cell.getMergedCellCount() == 1) { return rendererHelper.getRowOffset(uiRowIndex); } else if (cell.getMergedCellCount() > 1) { return rendererHelper.getRowOffset(uiRowIndex); } else { int _uiRowIndex = uiRowIndex; GridCell<?> _cell = cell; while (_cell.getMergedCellCount() == 0) { _uiRowIndex--; _cell = gridModel.getCell(_uiRowIndex, uiColumnIndex); } return rendererHelper.getRowOffset(_uiRowIndex); } }
private int findMinRowIndex(final int rowIndex, final int columnIndex) { int minRowIndex = rowIndex; final GridRow currentRow = gridData.getRow(rowIndex); final GridCell<?> currentRowCell = currentRow.getCells().get(columnIndex); //Find minimum row with a cell containing the same value as that being updated boolean foundTopSplitMarker = currentRowCell != null && currentRowCell.getMergedCellCount() > 0; while (minRowIndex > 0) { final GridRow previousRow = gridData.getRow(minRowIndex - 1); final GridCell<?> previousRowCell = previousRow.getCells().get(columnIndex); if (!(previousRow.isCollapsed() && currentRow.isCollapsed())) { if (previousRowCell == null) { break; } if (previousRowCell.isCollapsed() && foundTopSplitMarker) { break; } if (!previousRowCell.equals(currentRowCell)) { break; } if (previousRowCell.getMergedCellCount() > 0) { foundTopSplitMarker = true; } } minRowIndex--; } return minRowIndex; }
private double getCellHeight(final int uiRowIndex, final int uiColumnIndex) { final GridCell<?> cell = gridModel.getCell(uiRowIndex, uiColumnIndex); if (cell == null) { return gridModel.getRow(uiRowIndex).getHeight(); } if (cell.getMergedCellCount() == 1) { return gridModel.getRow(uiRowIndex).getHeight(); } else if (cell.getMergedCellCount() > 1) { return getMergedCellHeight(uiRowIndex, uiColumnIndex); } else { return getClippedMergedCellHeight(uiRowIndex, uiColumnIndex); } }
private double getCellHeight(final int uiRowIndex, final int uiColumnIndex) { final GridCell<?> cell = gridModel.getCell(uiRowIndex, uiColumnIndex); if (cell == null) { return gridModel.getRow(uiRowIndex).getHeight(); } if (cell.getMergedCellCount() == 1) { return gridModel.getRow(uiRowIndex).getHeight(); } else if (cell.getMergedCellCount() > 1) { return getMergedCellHeight(uiRowIndex, uiColumnIndex); } else { return getClippedMergedCellHeight(uiRowIndex, uiColumnIndex); } }
@Test public void testGetCellHeightCells4() throws Exception { doReturn(4).when(gridCell).getMergedCellCount(); Assertions.assertThat(ColumnRenderingStrategyMerged.getCellHeight(0, gridData, gridCell)).isEqualTo(BaseGridWidgetRenderingTestUtils.HEADER_ROW_HEIGHT * 4); }
@Test public void testGetCellHeightCells3() throws Exception { doReturn(3).when(gridCell).getMergedCellCount(); Assertions.assertThat(ColumnRenderingStrategyMerged.getCellHeight(0, gridData, gridCell)).isEqualTo(BaseGridWidgetRenderingTestUtils.HEADER_ROW_HEIGHT * 3); }
@Test public void testGetCellHeightCells4() throws Exception { doReturn(4).when(gridCell).getMergedCellCount(); Assertions.assertThat(ColumnRenderingStrategyMerged.getCellHeight(0, gridData, gridCell)).isEqualTo(BaseGridWidgetRenderingTestUtils.HEADER_ROW_HEIGHT * 4); }
@Test public void testGetCellHeightCells3() throws Exception { doReturn(3).when(gridCell).getMergedCellCount(); Assertions.assertThat(ColumnRenderingStrategyMerged.getCellHeight(0, gridData, gridCell)).isEqualTo(BaseGridWidgetRenderingTestUtils.HEADER_ROW_HEIGHT * 3); }
@Test @SuppressWarnings("unchecked") public void testNonMergedCell() { when(uiModel.getCell(eq(0), eq(0))).thenReturn(gridCell); when(gridCell.getMergedCellCount()).thenReturn(1); assertThat(handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.empty(), Optional.empty(), Optional.of(0), Optional.of(0), event)).isFalse(); verify(handler, never()).collapseRows(any(GridWidget.class), anyInt(), anyInt(), anyInt()); verify(handler, never()).expandRows(any(GridWidget.class), anyInt(), anyInt(), anyInt()); }
@Test @SuppressWarnings("unchecked") public void testNonMergedCell() { when(uiModel.getCell(eq(0), eq(0))).thenReturn(gridCell); when(gridCell.getMergedCellCount()).thenReturn(1); assertThat(handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.empty(), Optional.empty(), Optional.of(0), Optional.of(0), event)).isFalse(); verify(handler, never()).collapseRows(any(GridWidget.class), anyInt(), anyInt(), anyInt()); verify(handler, never()).expandRows(any(GridWidget.class), anyInt(), anyInt(), anyInt()); }
@Test @SuppressWarnings("unchecked") public void testMergedCellNotOnHotSpot() { when(uiModel.getCell(eq(0), eq(0))).thenReturn(gridCell); when(uiModel.getCell(eq(1), eq(0))).thenReturn(nextGridCell); when(uiModel.getColumns()).thenReturn(Collections.singletonList(gridColumn)); when(uiModel.getRow(eq(0))).thenReturn(gridRow); when(gridCell.getMergedCellCount()).thenReturn(2); when(nextGridCell.isCollapsed()).thenReturn(false); when(gridWidget.onGroupingToggle(anyDouble(), anyDouble(), anyDouble(), anyDouble())).thenReturn(false); assertThat(handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.empty(), Optional.empty(), Optional.of(0), Optional.of(0), event)).isFalse(); verify(handler, never()).collapseRows(any(GridWidget.class), anyInt(), anyInt(), anyInt()); verify(handler, never()).expandRows(any(GridWidget.class), anyInt(), anyInt(), anyInt()); }