int relativeY(final int y) { final Double relativeY = ((y) - getViewportTransform().getTranslateY()) / getViewportTransform().getScaleY(); return relativeY.intValue(); }
@Override public int getTransformedY(final int y) { final DMNGridPanel gridPanel = gridPanelSupplier.get(); final Transform transform = gridPanel.getViewport().getTransform(); return (int) ((y * transform.getScaleY()) + transform.getTranslateY()) + gridPanel.getAbsoluteTop(); } }
private Transform makeTransform() { final Transform transform = mock(Transform.class); doReturn(TRANSLATE_X).when(transform).getTranslateX(); doReturn(TRANSLATE_Y).when(transform).getTranslateY(); doReturn(SCALE_X).when(transform).getScaleX(); doReturn(SCALE_Y).when(transform).getScaleY(); return transform; } }
private Transform makeTransform() { final Transform transform = mock(Transform.class); doReturn(TRANSLATE_X).when(transform).getTranslateX(); doReturn(TRANSLATE_Y).when(transform).getTranslateY(); doReturn(SCALE_X).when(transform).getScaleX(); doReturn(SCALE_Y).when(transform).getScaleY(); return transform; } }
protected Point2D getScale() { return new Point2D( layer.getAbsoluteTransform().getScaleX(), layer.getAbsoluteTransform().getScaleY() ); }
private Double currentY() { return -(getTransform().getTranslateY() / getTransform().getScaleY() + bounds().minBoundY()); }
private Double currentY() { return -(getTransform().getTranslateY() / getTransform().getScaleY() + bounds().minBoundY()); }
private void updateVisibleBounds() { final Viewport viewport = getViewport(); Transform transform = viewport.getTransform(); if (transform == null) { viewport.setTransform(transform = new Transform()); } final double x = (PADDING - transform.getTranslateX()) / transform.getScaleX(); final double y = (PADDING - transform.getTranslateY()) / transform.getScaleY(); bounds.setX(x); bounds.setY(y); bounds.setHeight(Math.max(0, (viewport.getHeight() - PADDING * 2) / transform.getScaleX())); bounds.setWidth(Math.max(0, (viewport.getWidth() - PADDING * 2) / transform.getScaleY())); }
@Test public void testCalculateInternalScrollPanelHeightWhenScrollbarYIsDisabled() { final Double maximumBoundY = +20d; final Double minimumBoundY = -20d; final Double zoomLevel = 0.75d; final Double currentScrollPosition = 0d; doReturn(maximumBoundY).when(scrollBounds).maxBoundY(); doReturn(minimumBoundY).when(scrollBounds).minBoundY(); doReturn(zoomLevel).when(transform).getScaleY(); doReturn(currentScrollPosition).when(scrollPosition).deltaY(); final Integer panelHeight = gridLienzoScrollHandler.calculateInternalScrollPanelHeight(); assertEquals(DEFAULT_INTERNAL_SCROLL_HEIGHT, panelHeight, 0); }
@Test public void testCalculateInternalScrollPanelHeightWhenScrollbarYIsDisabled() { final Double maximumBoundY = +20d; final Double minimumBoundY = -20d; final Double zoomLevel = 0.75d; final Double currentScrollPosition = 0d; doReturn(maximumBoundY).when(scrollBounds).maxBoundY(); doReturn(minimumBoundY).when(scrollBounds).minBoundY(); doReturn(zoomLevel).when(transform).getScaleY(); doReturn(currentScrollPosition).when(scrollPosition).deltaY(); final Integer panelHeight = gridLienzoScrollHandler.calculateInternalScrollPanelHeight(); assertEquals(DEFAULT_INTERNAL_SCROLL_HEIGHT, panelHeight, 0); }
private void updateVisibleBounds() { final Viewport viewport = getViewport(); Transform transform = viewport.getTransform(); if (transform == null) { viewport.setTransform(transform = new Transform()); } final double x = (PADDING - transform.getTranslateX()) / transform.getScaleX(); final double y = (PADDING - transform.getTranslateY()) / transform.getScaleY(); bounds.setX(x); bounds.setY(y); bounds.setHeight(Math.max(0, (viewport.getHeight() - PADDING * 2) / transform.getScaleX())); bounds.setWidth(Math.max(0, (viewport.getWidth() - PADDING * 2) / transform.getScaleY())); }
@Test public void testCalculateInternalScrollPanelHeightWhenScrollbarYIsEnabled() { final Double maximumBoundY = +20d; final Double minimumBoundY = -20d; final Double zoomLevel = 0.75d; final Double currentScrollPosition = 10d; doReturn(maximumBoundY).when(scrollBounds).maxBoundY(); doReturn(minimumBoundY).when(scrollBounds).minBoundY(); doReturn(zoomLevel).when(transform).getScaleY(); doReturn(currentScrollPosition).when(scrollPosition).deltaY(); final Integer panelHeight = gridLienzoScrollHandler.calculateInternalScrollPanelHeight(); final Integer scaledHeight = (int) ((maximumBoundY - minimumBoundY) * zoomLevel); assertEquals(scaledHeight, panelHeight, 0); }
Integer calculateInternalScrollPanelHeight() { final Double absHeight = scrollBounds().maxBoundY() - scrollBounds().minBoundY(); if (getViewport() != null && scrollPosition().deltaY() != 0) { final Double scaleY = getViewport().getTransform().getScaleY(); final Double height = absHeight * scaleY; return height.intValue(); } return DEFAULT_INTERNAL_SCROLL_HEIGHT; }
Integer calculateInternalScrollPanelHeight() { final Double absHeight = scrollBounds().maxBoundY() - scrollBounds().minBoundY(); if (getViewport() != null && scrollPosition().deltaY() != 0) { final Double scaleY = getViewport().getTransform().getScaleY(); final Double height = absHeight * scaleY; return height.intValue(); } return DEFAULT_INTERNAL_SCROLL_HEIGHT; }
void updateGridLienzoTransform(final Double currentXPosition, final Double currentYPosition) { final Transform oldTransform = getViewport().getTransform(); final Double dx = currentXPosition - (oldTransform.getTranslateX() / oldTransform.getScaleX()); final Double dy = currentYPosition - (oldTransform.getTranslateY() / oldTransform.getScaleY()); final Transform newTransform = oldTransform.copy().translate(dx, dy); getViewport().setTransform(newTransform); getDefaultGridLayer().batch(); }
void updateGridLienzoTransform(final Double currentXPosition, final Double currentYPosition) { final Transform oldTransform = getViewport().getTransform(); final Double dx = currentXPosition - (oldTransform.getTranslateX() / oldTransform.getScaleX()); final Double dy = currentYPosition - (oldTransform.getTranslateY() / oldTransform.getScaleY()); final Transform newTransform = oldTransform.copy().translate(dx, dy); getViewport().setTransform(newTransform); getDefaultGridLayer().batch(); }
@Override public void onFrame(final IAnimation animation, final IAnimationHandle handle) { final double pct = assertPct(animation.getPercent()); final Viewport vp = gridWidget.getViewport(); final Transform transform = vp.getTransform(); final double scaleX = transform.getScaleX(); final double scaleY = transform.getScaleY(); transform.reset(); final Point2D frameLocation = startTranslation.add(delta.mul(pct)); transform.scale(scaleX, scaleY).translate(frameLocation.getX(), frameLocation.getY()); gridWidget.getLayer().batch(); }
@Override public void onFrame(final IAnimation animation, final IAnimationHandle handle) { final double pct = assertPct(animation.getPercent()); final Viewport vp = gridWidget.getViewport(); final Transform transform = vp.getTransform(); final double scaleX = transform.getScaleX(); final double scaleY = transform.getScaleY(); transform.reset(); final Point2D frameLocation = startTranslation.add(delta.mul(pct)); transform.scale(scaleX, scaleY).translate(frameLocation.getX(), frameLocation.getY()); gridWidget.getLayer().batch(); }
private void adjustViewportTransform(final Viewport vp, final Point2D delta) { final Transform transform = vp.getTransform(); final Transform t = transform.copy().getInverse(); final Point2D translation = new Point2D(t.getTranslateX(), t.getTranslateY()).mul(-1.0); final double scaleX = transform.getScaleX(); final double scaleY = transform.getScaleY(); transform.reset(); final Point2D frameLocation = translation.add(delta); transform.scale(scaleX, scaleY).translate(frameLocation.getX(), frameLocation.getY()); } }
private void adjustViewportTransform(final Viewport vp, final Point2D delta) { final Transform transform = vp.getTransform(); final Transform t = transform.copy().getInverse(); final Point2D translation = new Point2D(t.getTranslateX(), t.getTranslateY()).mul(-1.0); final double scaleX = transform.getScaleX(); final double scaleY = transform.getScaleY(); transform.reset(); final Point2D frameLocation = translation.add(delta); transform.scale(scaleX, scaleY).translate(frameLocation.getX(), frameLocation.getY()); } }