Search in sources :

Example 1 with TransformMediator

use of org.uberfire.ext.wires.core.grids.client.widget.layer.pinning.TransformMediator in project drools-wb by kiegroup.

the class GuidedDecisionTableModellerViewImpl method setZoom.

@Override
public void setZoom(final int zoom) {
    // Set zoom preserving translation
    final Transform transform = newTransform();
    final double tx = gridPanel.getViewport().getTransform().getTranslateX();
    final double ty = gridPanel.getViewport().getTransform().getTranslateY();
    transform.translate(tx, ty);
    transform.scale(zoom / 100.0);
    // Ensure the change in zoom keeps the view in bounds. IGridLayer's visibleBounds depends
    // on the Viewport Transformation; so set it to the "proposed" transformation before checking.
    gridPanel.getViewport().setTransform(transform);
    final TransformMediator restriction = mousePanMediator.getTransformMediator();
    final Transform newTransform = restriction.adjust(transform, gridLayer.getVisibleBounds());
    gridPanel.getViewport().setTransform(newTransform);
    gridPanel.getViewport().batch();
    gridPanel.refreshScrollPosition();
}
Also used : Transform(com.ait.lienzo.client.core.types.Transform) TransformMediator(org.uberfire.ext.wires.core.grids.client.widget.layer.pinning.TransformMediator)

Example 2 with TransformMediator

use of org.uberfire.ext.wires.core.grids.client.widget.layer.pinning.TransformMediator in project drools-wb by kiegroup.

the class GuidedDecisionTableModellerViewImplTest method testScrollbarsUpdatedAfterZoom.

@Test
public void testScrollbarsUpdatedAfterZoom() throws Exception {
    final double x = 10.0;
    final double y = 20.0;
    final int zoom = 70;
    final Transform transform = mock(Transform.class);
    final Viewport viewport = mock(Viewport.class);
    final TransformMediator mediator = mock(TransformMediator.class);
    doReturn(transform).when(mediator).adjust(eq(transform), any());
    doReturn(mediator).when(restrictedMousePanMediator).getTransformMediator();
    doReturn(x).when(transform).getTranslateX();
    doReturn(y).when(transform).getTranslateY();
    doReturn(transform).when(view).newTransform();
    doReturn(transform).when(viewport).getTransform();
    doReturn(viewport).when(mockGridPanel).getViewport();
    view.setZoom(zoom);
    verify(transform).translate(x, y);
    verify(transform).scale(zoom / 100.0);
    verify(viewport, times(2)).setTransform(transform);
    verify(viewport).batch();
    verify(mockGridPanel).refreshScrollPosition();
}
Also used : Viewport(com.ait.lienzo.client.core.shape.Viewport) Transform(com.ait.lienzo.client.core.types.Transform) TransformMediator(org.uberfire.ext.wires.core.grids.client.widget.layer.pinning.TransformMediator) Test(org.junit.Test)

Aggregations

Transform (com.ait.lienzo.client.core.types.Transform)2 TransformMediator (org.uberfire.ext.wires.core.grids.client.widget.layer.pinning.TransformMediator)2 Viewport (com.ait.lienzo.client.core.shape.Viewport)1 Test (org.junit.Test)1