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(); }
/** * Get the y-offset for a given Row index. * @param rowIndex The index of the GridRow. * @return */ public double getRowOffset(final int rowIndex) { double rowOffset = 0; final GridData model = view.getModel(); for (int i = 0; i < rowIndex; i++) { final GridRow row = model.getRow(i); rowOffset = rowOffset + row.getHeight(); } return rowOffset; }
/** * Get the y-offset for a given Row index. * @param rowIndex The index of the GridRow. * @return */ public double getRowOffset(final int rowIndex) { double rowOffset = 0; final GridData model = view.getModel(); for (int i = 0; i < rowIndex; i++) { final GridRow row = model.getRow(i); rowOffset = rowOffset + row.getHeight(); } return rowOffset; }
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; }
@Before public void setUp() throws Exception { doReturn(gridRow).when(gridData).getRow(anyInt()); doReturn(BaseGridWidgetRenderingTestUtils.HEADER_ROW_HEIGHT).when(gridRow).getHeight(); }
@Before public void setUp() throws Exception { doReturn(gridRow).when(gridData).getRow(anyInt()); doReturn(BaseGridWidgetRenderingTestUtils.HEADER_ROW_HEIGHT).when(gridRow).getHeight(); }
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); } }
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; }
@Test public void testInsert() throws VetoException { modelSynchronizer.appendRow(); modelSynchronizer.insertRow(0); assertEquals(2, model.getData().size()); assertEquals(2, uiModel.getRowCount()); assertEquals(GuidedDecisionTableView.ROW_HEIGHT, uiModel.getRow(0).getHeight(), 0.0); assertEquals(GuidedDecisionTableView.ROW_HEIGHT, uiModel.getRow(1).getHeight(), 0.0); }
@Test public void testAppend() throws VetoException { modelSynchronizer.appendRow(); assertEquals(1, model.getData().size()); assertEquals(1, uiModel.getRowCount()); assertEquals(GuidedDecisionTableView.ROW_HEIGHT, uiModel.getRow(0).getHeight(), 0.0); }
protected void showRowHighlight(final GridWidget view, final List<GridRow> activeGridRows) { final BaseGridRendererHelper rendererHelper = view.getRendererHelper(); final BaseGridRendererHelper.RenderingInformation renderingInformation = rendererHelper.getRenderingInformation(); if (renderingInformation == null) { return; } final Bounds bounds = renderingInformation.getBounds(); final GridRow row = activeGridRows.get(0); final double rowOffsetY = rendererHelper.getRowOffset(row) + view.getRenderer().getHeaderHeight(); final double highlightWidth = Math.min(bounds.getX() + bounds.getWidth() - view.getAbsoluteX(), view.getWidth()); final double highlightHeight = row.getHeight(); state.getEventColumnHighlight().setWidth(highlightWidth) .setHeight(highlightHeight) .setX(view.getAbsoluteX()) .setY(view.getAbsoluteY() + rowOffsetY); layer.add(state.getEventColumnHighlight()); layer.getLayer().batch(); } }
protected void showRowHighlight(final GridWidget view, final List<GridRow> activeGridRows) { final BaseGridRendererHelper rendererHelper = view.getRendererHelper(); final BaseGridRendererHelper.RenderingInformation renderingInformation = rendererHelper.getRenderingInformation(); if (renderingInformation == null) { return; } final Bounds bounds = renderingInformation.getBounds(); final GridRow row = activeGridRows.get(0); final double rowOffsetY = rendererHelper.getRowOffset(row) + view.getRenderer().getHeaderHeight(); final double highlightWidth = Math.min(bounds.getX() + bounds.getWidth() - view.getAbsoluteX(), view.getWidth()); final double highlightHeight = row.getHeight(); state.getEventColumnHighlight().setWidth(highlightWidth) .setHeight(highlightHeight) .setX(view.getAbsoluteX()) .setY(view.getAbsoluteY() + rowOffsetY); layer.add(state.getEventColumnHighlight()); layer.getLayer().batch(); } }
Rectangle makeRowHighlight(final int _rowIndex, final int _visibleRowIndex, final GridData model, final GridBodyRenderContext context, final BaseGridRendererHelper rendererHelper) { final Rectangle r = new Rectangle(0, 0).setAlpha(0.3).setFillColor(ColorName.ORANGE).setListening(false); r.setY(rendererHelper.getRowOffset(_visibleRowIndex)); r.setWidth(rendererHelper.getWidth(context.getBlockColumns())); r.setHeight(model.getRow(_rowIndex).getHeight()); switch (rowHighlightSeverity) { case NOTE: r.setFillColor(ColorName.LIGHTBLUE); break; case WARNING: r.setFillColor(ColorName.ORANGE); break; case ERROR: r.setFillColor(ColorName.RED); break; } return r; } }
private double getCellScrollDeltaY(final GridWidget gridWidget) { final GridData gridModel = gridWidget.getModel(); final GridData.SelectedCell origin = gridModel.getSelectedCellsOrigin(); final int uiRowIndex = origin.getRowIndex(); double dy = 0; final Bounds bounds = gridLayer.getVisibleBounds(); final double rowHeight = gridModel.getRow(uiRowIndex).getHeight(); final double headerHeight = gridWidget.getRenderer().getHeaderHeight(); final double gridCellY = gridWidget.getY() + headerHeight + gridWidget.getRendererHelper().getRowOffset(uiRowIndex); if (gridCellY + rowHeight >= bounds.getY() + bounds.getHeight()) { dy = bounds.getY() + bounds.getHeight() - gridCellY - rowHeight; } else if (gridCellY <= bounds.getY() + headerHeight) { dy = bounds.getY() + headerHeight - gridCellY; } return dy; }
private double getCellScrollDeltaY(final GridWidget gridWidget) { final GridData gridModel = gridWidget.getModel(); final GridData.SelectedCell origin = gridModel.getSelectedCellsOrigin(); final int uiRowIndex = origin.getRowIndex(); double dy = 0; final Bounds bounds = gridLayer.getVisibleBounds(); final double rowHeight = gridModel.getRow(uiRowIndex).getHeight(); final double headerHeight = gridWidget.getRenderer().getHeaderHeight(); final double gridCellY = gridWidget.getY() + headerHeight + gridWidget.getRendererHelper().getRowOffset(uiRowIndex); if (gridCellY + rowHeight >= bounds.getY() + bounds.getHeight()) { dy = bounds.getY() + bounds.getHeight() - gridCellY - rowHeight; } else if (gridCellY <= bounds.getY() + headerHeight) { dy = bounds.getY() + headerHeight - gridCellY; } return dy; }
Rectangle makeRowHighlight(final int _rowIndex, final int _visibleRowIndex, final GridData model, final GridBodyRenderContext context, final BaseGridRendererHelper rendererHelper) { final Rectangle r = new Rectangle(0, 0).setAlpha(0.3).setFillColor(ColorName.ORANGE).setListening(false); r.setY(rendererHelper.getRowOffset(_visibleRowIndex)); r.setWidth(rendererHelper.getWidth(context.getBlockColumns())); r.setHeight(model.getRow(_rowIndex).getHeight()); switch (rowHighlightSeverity) { case NOTE: r.setFillColor(ColorName.LIGHTBLUE); break; case WARNING: r.setFillColor(ColorName.ORANGE); break; case ERROR: r.setFillColor(ColorName.RED); break; } return r; } }