private BaseGridRendererHelper.RenderingInformation prepare() { this.body = null; this.header = null; this.floatingBody = null; this.floatingHeader = null; this.bodySelections = null; this.headerSelections = null; this.floatingBodySelections = null; this.floatingHeaderSelections = null; this.boundary = null; this.selection = null; this.allColumns.clear(); this.bodyColumns.clear(); this.floatingColumns.clear(); this.renderQueue.clear(); //If there's no RenderingInformation the GridWidget is not visible final BaseGridRendererHelper.RenderingInformation renderingInformation = rendererHelper.getRenderingInformation(); if (renderingInformation == null) { return null; } final BaseGridRendererHelper.RenderingBlockInformation bodyBlockInformation = renderingInformation.getBodyBlockInformation(); final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = renderingInformation.getFloatingBlockInformation(); final List<GridColumn<?>> allColumns = renderingInformation.getAllColumns(); final List<GridColumn<?>> bodyColumns = bodyBlockInformation.getColumns(); final List<GridColumn<?>> floatingColumns = floatingBlockInformation.getColumns(); this.allColumns.addAll(allColumns); this.bodyColumns.addAll(bodyColumns); this.floatingColumns.addAll(floatingColumns); return renderingInformation; }
private BaseGridRendererHelper.RenderingInformation prepare() { this.body = null; this.header = null; this.floatingBody = null; this.floatingHeader = null; this.bodySelections = null; this.headerSelections = null; this.floatingBodySelections = null; this.floatingHeaderSelections = null; this.boundary = null; this.selection = null; this.allColumns.clear(); this.bodyColumns.clear(); this.floatingColumns.clear(); this.renderQueue.clear(); //If there's no RenderingInformation the GridWidget is not visible final BaseGridRendererHelper.RenderingInformation renderingInformation = rendererHelper.getRenderingInformation(); if (renderingInformation == null) { return null; } final BaseGridRendererHelper.RenderingBlockInformation bodyBlockInformation = renderingInformation.getBodyBlockInformation(); final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = renderingInformation.getFloatingBlockInformation(); final List<GridColumn<?>> allColumns = renderingInformation.getAllColumns(); final List<GridColumn<?>> bodyColumns = bodyBlockInformation.getColumns(); final List<GridColumn<?>> floatingColumns = floatingBlockInformation.getColumns(); this.allColumns.addAll(allColumns); this.bodyColumns.addAll(bodyColumns); this.floatingColumns.addAll(floatingColumns); return renderingInformation; }
@Before public void setup() { doReturn(gridRenderer).when(gridWidget).getRenderer(); doReturn(gridRendererHelper).when(gridWidget).getRendererHelper(); doReturn(ri).when(gridRendererHelper).getRenderingInformation(); doReturn(HEADER_HEIGHT).when(gridRenderer).getHeaderHeight(); doReturn(HEADER_ROW_HEIGHT).when(gridRenderer).getHeaderRowHeight(); doReturn(floatingBlockInformation).when(ri).getFloatingBlockInformation(); doReturn(0.0).when(floatingBlockInformation).getX(); doReturn(0.0).when(floatingBlockInformation).getWidth(); doReturn(mock(Viewport.class)).when(gridWidget).getViewport(); doReturn(new BaseGridData()).when(gridWidget).getModel(); }
final List<GridColumn<?>> allColumns = new ArrayList<>(); final BaseGridRendererHelper.RenderingBlockInformation bodyBlockInformation = renderingInformation.getBodyBlockInformation(); final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = renderingInformation.getFloatingBlockInformation();
final List<GridColumn<?>> allColumns = new ArrayList<>(); final BaseGridRendererHelper.RenderingBlockInformation bodyBlockInformation = renderingInformation.getBodyBlockInformation(); final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = renderingInformation.getFloatingBlockInformation();
@Before public void setup() { super.setup(); doReturn(gridRenderer).when(scenarioGridMock).getRenderer(); doReturn(gridRendererHelper).when(scenarioGridMock).getRendererHelper(); doReturn(ri).when(gridRendererHelper).getRenderingInformation(); doReturn(HEADER_HEIGHT).when(gridRenderer).getHeaderHeight(); doReturn(HEADER_ROW_HEIGHT).when(gridRenderer).getHeaderRowHeight(); doReturn(floatingBlockInformation).when(ri).getFloatingBlockInformation(); doReturn(0.0).when(floatingBlockInformation).getX(); doReturn(0.0).when(floatingBlockInformation).getWidth(); doReturn(mock(Viewport.class)).when(scenarioGridMock).getViewport(); when(scenarioGridMock.getModel()).thenReturn(scenarioGridModelMock); final ScenarioHeaderMetaData clickedScenarioHeaderMetadataMock = mock(ScenarioHeaderMetaData.class); scenarioGridColumnOne = mockGridColumn(100.0, Collections.singletonList(clickedScenarioHeaderMetadataMock), columnOneTitle, columnGroup); scenarioGridColumnTwo = mockGridColumn(100.0, Collections.singletonList(clickedScenarioHeaderMetadataMock), columnTwoTitle, columnGroup); gridColumns.add(scenarioGridColumnOne); gridColumns.add(scenarioGridColumnTwo); }
private boolean isOverRowDragHandleColumn(final GridWidget view, final double cx) { //Gather information on columns final BaseGridRendererHelper rendererHelper = view.getRendererHelper(); final BaseGridRendererHelper.RenderingInformation renderingInformation = rendererHelper.getRenderingInformation(); if (renderingInformation == null) { return false; } final BaseGridRendererHelper.RenderingBlockInformation bodyBlockInformation = renderingInformation.getBodyBlockInformation(); final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = renderingInformation.getFloatingBlockInformation(); final List<GridColumn<?>> bodyColumns = bodyBlockInformation.getColumns(); final List<GridColumn<?>> floatingColumns = floatingBlockInformation.getColumns(); final double bodyX = bodyBlockInformation.getX(); final double floatingX = floatingBlockInformation.getX(); //Check floating columns if (findRowDragHandleColumn(floatingColumns, floatingX, cx) != null) { return true; } //Check all other columns return findRowDragHandleColumn(bodyColumns, bodyX, cx) != null; }
private boolean isOverRowDragHandleColumn(final GridWidget view, final double cx) { //Gather information on columns final BaseGridRendererHelper rendererHelper = view.getRendererHelper(); final BaseGridRendererHelper.RenderingInformation renderingInformation = rendererHelper.getRenderingInformation(); if (renderingInformation == null) { return false; } final BaseGridRendererHelper.RenderingBlockInformation bodyBlockInformation = renderingInformation.getBodyBlockInformation(); final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = renderingInformation.getFloatingBlockInformation(); final List<GridColumn<?>> bodyColumns = bodyBlockInformation.getColumns(); final List<GridColumn<?>> floatingColumns = floatingBlockInformation.getColumns(); final double bodyX = bodyBlockInformation.getX(); final double floatingX = floatingBlockInformation.getX(); //Check floating columns if (findRowDragHandleColumn(floatingColumns, floatingX, cx) != null) { return true; } //Check all other columns return findRowDragHandleColumn(bodyColumns, bodyX, cx) != null; }
@Before public void setUp() { super.setup(); doReturn(scenarioGridCellMock).when(scenarioGridModelMock).getCell(UI_ROW_INDEX, UI_COLUMN_INDEX); when(scenarioGridPanelMock.getScenarioGrid()).thenReturn(scenarioGridMock); when(scenarioGridMock.getWidth()).thenReturn(GRID_WIDTH); when(scenarioGridMock.getModel()).thenReturn(scenarioGridModelMock); when(scenarioGridMock.getRenderer()).thenReturn(scenarioGridRendererMock); when(scenarioGridMock.getRendererHelper()).thenReturn(scenarioGridRendererHelperMock); when(scenarioGridMock.getViewport()).thenReturn(viewportMock); when(scenarioGridRendererMock.getHeaderHeight()).thenReturn(HEADER_HEIGHT); when(scenarioGridRendererMock.getHeaderRowHeight()).thenReturn(HEADER_ROW_HEIGHT); when(scenarioGridRendererHelperMock.getRenderingInformation()).thenReturn(scenarioRenderingInformationMock); // mock single column in grid when(scenarioGridModelMock.getHeaderRowCount()).thenReturn(1); columnsMock = Arrays.asList(gridColumnMock, gridColumnMock); when(scenarioGridModelMock.getColumns()).thenReturn(columnsMock); when(scenarioGridModelMock.getColumnCount()).thenReturn(2); // mock that column to index 0 BaseGridRendererHelper.ColumnInformation columnInformation = new BaseGridRendererHelper.ColumnInformation(gridColumnMock, UI_COLUMN_INDEX, OFFSET_X); when(scenarioGridRendererHelperMock.getColumnInformation(AdditionalMatchers.or(eq(0.0), eq(CLICK_POINT_X)))) .thenReturn(columnInformation); when(scenarioRenderingInformationMock.getFloatingBlockInformation()).thenReturn(floatingBlockInformationMock); } }
private Bounds getSelectorBounds(final double width, final double height, final BaseGridRendererHelper.RenderingInformation renderingInformation) { final BaseGridRendererHelper.RenderingBlockInformation bodyBlockInformation = renderingInformation.getBodyBlockInformation(); final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = renderingInformation.getFloatingBlockInformation(); double boundsX = 0.0; double boundsY = 0.0; double boundsWidth = width; double boundsHeight = height; if (!floatingBlockInformation.getColumns().isEmpty()) { boundsX = floatingBlockInformation.getX(); boundsWidth = boundsWidth - floatingBlockInformation.getX(); } if (renderingInformation.isFloatingHeader()) { boundsY = bodyBlockInformation.getHeaderY(); boundsHeight = boundsHeight - bodyBlockInformation.getHeaderY(); } return new BaseBounds(boundsX, boundsY, boundsWidth, boundsHeight); }
@Before public void setup() { this.uiModel = new GuidedDecisionTableUiModel(synchronizer); this.uiColumn = new RowNumberColumn(); this.uiModel.appendColumn(uiColumn); this.uiModel.appendRow(new BaseGridRow()); this.renderer = new GuidedDecisionTableRenderer(uiModel, new GuidedDecisionTable52()); doReturn(new ArrayList<Double>() {{ add(20.0); }}).when(renderingInformation).getVisibleRowOffsets(); doReturn(new ArrayList<GridColumn<?>>() {{ add(uiColumn); }}).when(context).getBlockColumns(); doReturn(bodyBlockInformation).when(renderingInformation).getBodyBlockInformation(); doReturn(new ArrayList<GridColumn<?>>() {{ add(uiColumn); }}).when(bodyBlockInformation).getColumns(); doReturn(floatingBlockInformation).when(renderingInformation).getFloatingBlockInformation(); doReturn(Collections.emptyList()).when(floatingBlockInformation).getColumns(); doReturn(renderer).when(context).getRenderer(); }
private Bounds getSelectorBounds(final double width, final double height, final BaseGridRendererHelper.RenderingInformation renderingInformation) { final BaseGridRendererHelper.RenderingBlockInformation bodyBlockInformation = renderingInformation.getBodyBlockInformation(); final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = renderingInformation.getFloatingBlockInformation(); double boundsX = 0.0; double boundsY = 0.0; double boundsWidth = width; double boundsHeight = height; if (!floatingBlockInformation.getColumns().isEmpty()) { boundsX = floatingBlockInformation.getX(); boundsWidth = boundsWidth - floatingBlockInformation.getX(); } if (renderingInformation.isFloatingHeader()) { boundsY = bodyBlockInformation.getHeaderY(); boundsHeight = boundsHeight - bodyBlockInformation.getHeaderY(); } return new BaseBounds(boundsX, boundsY, boundsWidth, boundsHeight); }
private int getScreenX(final GuidedDecisionTableModellerView modellerView, final GuidedDecisionTableView.Presenter dtPresenter, final int uiColumnIndex) { final GridWidget gridWidget = dtPresenter.getView(); final GridColumn<?> uiColumn = gridWidget.getModel().getColumns().get(uiColumnIndex); final double gx = gridWidget.getX(); final GridLayer layer = modellerView.getGridLayerView(); final int containerX = layer.getDomElementContainer().getAbsoluteLeft(); final double vx = layer.getVisibleBounds().getX(); final Transform t = layer.getViewport().getTransform(); final BaseGridRendererHelper rendererHelper = gridWidget.getRendererHelper(); final BaseGridRendererHelper.RenderingInformation ri = rendererHelper.getRenderingInformation(); final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = ri.getFloatingBlockInformation(); final double offsetX = floatingBlockInformation.getColumns().contains(uiColumn) ? floatingBlockInformation.getX() : 0; final int screenX = containerX + (int) ((gx - vx + offsetX + rendererHelper.getColumnOffset(uiColumn) + uiColumn.getWidth() / 2) * t.getScaleX()); return screenX; }
@Before @SuppressWarnings("unchecked") public void setup() { super.setUp(); this.clickEvent = new NodeMouseClickEvent(nativeClickEvent); this.doubleClickEvent = new NodeMouseDoubleClickEvent(nativeDoubleClickEvent); when(scenarioGridMock.getRendererHelper()).thenReturn(rendererHelper); when(scenarioGridMock.getViewport()).thenReturn(viewportMock); when(scenarioGridMock.getComputedLocation()).thenReturn(computedLocation); when(rendererHelper.getRenderingInformation()).thenReturn(renderingInformation); when(rendererHelper.getColumnInformation(anyDouble())).thenReturn(columnInformation); when(columnInformation.getColumn()).thenReturn((GridColumn) gridColumnMock); when(renderingInformation.getBodyBlockInformation()).thenReturn(renderingBlockInformation); when(renderingInformation.getFloatingBlockInformation()).thenReturn(renderingBlockInformation); when(informationHeaderMetaDataMock.getSupportedEditAction()).thenReturn(GridCellEditAction.SINGLE_CLICK); this.handler = spy(new ScenarioSimulationGridWidgetMouseEventHandler()); }
private int getScreenX(final GuidedDecisionTableModellerView modellerView, final GuidedDecisionTableView.Presenter dtPresenter, final int uiColumnIndex) { final GridWidget gridWidget = dtPresenter.getView(); final GridColumn<?> uiColumn = gridWidget.getModel().getColumns().get(uiColumnIndex); final double gx = gridWidget.getX(); final GridLayer layer = modellerView.getGridLayerView(); final int containerX = layer.getDomElementContainer().getAbsoluteLeft(); final double vx = layer.getVisibleBounds().getX(); final Transform t = layer.getViewport().getTransform(); final BaseGridRendererHelper rendererHelper = gridWidget.getRendererHelper(); final BaseGridRendererHelper.RenderingInformation ri = rendererHelper.getRenderingInformation(); final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = ri.getFloatingBlockInformation(); final double offsetX = floatingBlockInformation.getColumns().contains(uiColumn) ? floatingBlockInformation.getX() : 0; final int screenX = containerX + (int) ((gx - vx + offsetX + rendererHelper.getColumnOffset(uiColumn) + uiColumn.getWidth() / 2) * t.getScaleX()); return screenX; }
private boolean isGridColumnCandidateForScroll(final GridWidget gridWidget) { final GridData gridModel = gridWidget.getModel(); final BaseGridRendererHelper rendererHelper = gridWidget.getRendererHelper(); final BaseGridRendererHelper.RenderingInformation renderingInformation = rendererHelper.getRenderingInformation(); if (renderingInformation == null) { return false; } final List<GridColumn<?>> columns = gridModel.getColumns(); final GridData.SelectedCell origin = gridModel.getSelectedCellsOrigin(); final int uiColumnIndex = ColumnIndexUtilities.findUiColumnIndex(columns, origin.getColumnIndex()); final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = renderingInformation.getFloatingBlockInformation(); final List<GridColumn<?>> floatingColumns = floatingBlockInformation.getColumns(); final GridColumn<?> column = columns.get(uiColumnIndex); return !floatingColumns.contains(column); }
private boolean isGridColumnCandidateForScroll(final GridWidget gridWidget) { final GridData gridModel = gridWidget.getModel(); final BaseGridRendererHelper rendererHelper = gridWidget.getRendererHelper(); final BaseGridRendererHelper.RenderingInformation renderingInformation = rendererHelper.getRenderingInformation(); if (renderingInformation == null) { return false; } final List<GridColumn<?>> columns = gridModel.getColumns(); final GridData.SelectedCell origin = gridModel.getSelectedCellsOrigin(); final int uiColumnIndex = ColumnIndexUtilities.findUiColumnIndex(columns, origin.getColumnIndex()); final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = renderingInformation.getFloatingBlockInformation(); final List<GridColumn<?>> floatingColumns = floatingBlockInformation.getColumns(); final GridColumn<?> column = columns.get(uiColumnIndex); return !floatingColumns.contains(column); }
private BaseGridRendererHelper.ColumnInformation getFloatingColumnInformation(final int uiColumnIndex) { final GridColumn<?> column = gridModel.getColumns().get(uiColumnIndex); final BaseGridRendererHelper rendererHelper = gridWidget.getRendererHelper(); final BaseGridRendererHelper.RenderingInformation renderingInformation = rendererHelper.getRenderingInformation(); final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = renderingInformation.getFloatingBlockInformation(); final List<GridColumn<?>> floatingColumns = floatingBlockInformation.getColumns(); if (!floatingColumns.contains(column)) { return null; } return new BaseGridRendererHelper.ColumnInformation(column, uiColumnIndex, floatingBlockInformation.getX() + rendererHelper.getColumnOffset(floatingColumns, floatingColumns.indexOf(column))); }
private BaseGridRendererHelper.ColumnInformation getFloatingColumnInformation(final int uiColumnIndex) { final GridColumn<?> column = gridModel.getColumns().get(uiColumnIndex); final BaseGridRendererHelper rendererHelper = gridWidget.getRendererHelper(); final BaseGridRendererHelper.RenderingInformation renderingInformation = rendererHelper.getRenderingInformation(); final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = renderingInformation.getFloatingBlockInformation(); final List<GridColumn<?>> floatingColumns = floatingBlockInformation.getColumns(); if (!floatingColumns.contains(column)) { return null; } return new BaseGridRendererHelper.ColumnInformation(column, uiColumnIndex, floatingBlockInformation.getX() + rendererHelper.getColumnOffset(floatingColumns, floatingColumns.indexOf(column))); }
@Before public void setup() { doReturn(gridRenderer).when(gridWidget).getRenderer(); doReturn(gridRendererHelper).when(gridWidget).getRendererHelper(); doReturn(ri).when(gridRendererHelper).getRenderingInformation(); doReturn(HEADER_HEIGHT).when(gridRenderer).getHeaderHeight(); doReturn(HEADER_ROW_HEIGHT).when(gridRenderer).getHeaderRowHeight(); doReturn(floatingBlockInformation).when(ri).getFloatingBlockInformation(); doReturn(0.0).when(floatingBlockInformation).getX(); doReturn(0.0).when(floatingBlockInformation).getWidth(); doReturn(mock(Viewport.class)).when(gridWidget).getViewport(); doReturn(new BaseGridData()).when(gridWidget).getModel(); }