GridHighlightHelper { void moveCanvasTo(final double x, final double y) { final double deltaY = calculateDeltaY(y); final double deltaX = calculateDeltaX(x); final Transform newTransform = getTransform().copy().translate(deltaX, deltaY); getViewport().setTransform(newTransform); getDefaultGridLayer().batch(); getGridPanel().refreshScrollPosition(); } GridHighlightHelper(final GridLienzoPanel gridPanel,
                               final GridWidget gridWidget); void highlight(final int row,
                          final int column); void clearSelections(); void clearHighlight(); GridHighlightHelper withPaddingX(final double paddingX); GridHighlightHelper withPaddingY(final double paddingY); GridHighlightHelper withPinnedGrid();  }
@Test public void testMoveCanvasToWhenTheElementIsVisible() { final int expectedDeltaX = 0; final int expectedDeltaY = 0; final Transform copy = mock(Transform.class); final Transform newTransform = mock(Transform.class); when(transform.copy()).thenReturn(copy); when(copy.translate(anyInt(), anyInt())).thenReturn(newTransform); highlightHelper.moveCanvasTo(x, y); verify(copy).translate(expectedDeltaX, expectedDeltaY); verify(viewport).setTransform(newTransform); verify(defaultGridLayer).batch(); verify(gridPanel).refreshScrollPosition(); }
@Test public void testMoveCanvasToWhenElementIsNotHorizontallyVisible() { final int expectedDeltaX = -747; final int expectedDeltaY = 0; final Transform copy = mock(Transform.class); final Transform newTransform = mock(Transform.class); when(transform.copy()).thenReturn(copy); when(copy.translate(anyInt(), anyInt())).thenReturn(newTransform); highlightHelper.moveCanvasTo(x - visibleBoundsWidth, y); verify(copy).translate(expectedDeltaX, expectedDeltaY); verify(viewport).setTransform(newTransform); verify(defaultGridLayer).batch(); verify(gridPanel).refreshScrollPosition(); }
@Test public void testMoveCanvasToWhenElementIsNotVerticallyVisible() { final int expectedDeltaX = 0; final int expectedDeltaY = -493; final Transform copy = mock(Transform.class); final Transform newTransform = mock(Transform.class); when(transform.copy()).thenReturn(copy); when(copy.translate(anyInt(), anyInt())).thenReturn(newTransform); highlightHelper.moveCanvasTo(x, y - visibleBoundsHeight); verify(copy).translate(expectedDeltaX, expectedDeltaY); verify(viewport).setTransform(newTransform); verify(defaultGridLayer).batch(); verify(gridPanel).refreshScrollPosition(); }