Search in sources :

Example 1 with Transform

use of com.ait.lienzo.client.core.types.Transform in project drools-wb by kiegroup.

the class RadarMenuBuilder method onDragVisibleBounds.

@Override
public void onDragVisibleBounds(final double canvasX, final double canvasY) {
    final double _canvasX = -canvasX;
    final double _canvasY = -canvasY;
    final Transform oldTransform = modeller.getView().getGridLayerView().getViewport().getTransform();
    final double scaleX = oldTransform.getScaleX();
    final double scaleY = oldTransform.getScaleY();
    final double translateX = oldTransform.getTranslateX();
    final double translateY = oldTransform.getTranslateY();
    final double dx = _canvasX - (translateX / scaleX);
    final double dy = _canvasY - (translateY / scaleY);
    final Transform newTransform = oldTransform.copy().translate(dx, dy);
    modeller.getView().getGridLayerView().getViewport().setTransform(newTransform);
    modeller.getView().getGridLayerView().batch();
    modeller.getView().refreshScrollPosition();
}
Also used : Transform(com.ait.lienzo.client.core.types.Transform)

Example 2 with Transform

use of com.ait.lienzo.client.core.types.Transform in project drools-wb by kiegroup.

the class BoundaryTransformMediator method adjust.

@Override
public Transform adjust(final Transform transform, final Bounds visibleBounds) {
    updateBounds();
    Transform newTransform = transform.copy();
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    final double translateX = newTransform.getTranslateX();
    final double translateY = newTransform.getTranslateY();
    final double scaledTranslateX = translateX / scaleX;
    final double scaledTranslateY = translateY / scaleY;
    final double visibleBoundsWidth = visibleBounds.getWidth();
    final double visibleBoundsHeight = visibleBounds.getHeight();
    if (-scaledTranslateX < minX) {
        newTransform = newTransform.translate(-scaledTranslateX - minX, 0);
    }
    if (-scaledTranslateY < minY) {
        newTransform = newTransform.translate(0, -scaledTranslateY - minY);
    }
    if (-scaledTranslateX + visibleBoundsWidth > maxX) {
        newTransform = newTransform.translate(-scaledTranslateX + visibleBoundsWidth - maxX, 0);
    }
    if (-scaledTranslateY + visibleBoundsHeight > maxY) {
        newTransform = newTransform.translate(0, -scaledTranslateY + visibleBoundsHeight - maxY);
    }
    return newTransform;
}
Also used : Transform(com.ait.lienzo.client.core.types.Transform)

Example 3 with Transform

use of com.ait.lienzo.client.core.types.Transform in project drools-wb by kiegroup.

the class GuidedDecisionTableModellerViewImpl method getTranslation.

private Point2D getTranslation(final GuidedDecisionTableView gridWidget) {
    final double boundsPadding = GuidedDecisionTableModellerBoundsHelper.BOUNDS_PADDING;
    final Transform t = gridLayer.getViewport().getTransform();
    final double requiredTranslateX = boundsPadding - gridWidget.getX();
    final double requiredTranslateY = boundsPadding - gridWidget.getY();
    final double actualTranslateX = t.getTranslateX();
    final double actualTranslateY = t.getTranslateY();
    final double dx = requiredTranslateX - actualTranslateX;
    final double dy = requiredTranslateY - actualTranslateY;
    return new Point2D(dx, dy);
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D) Transform(com.ait.lienzo.client.core.types.Transform)

Example 4 with Transform

use of com.ait.lienzo.client.core.types.Transform 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 5 with Transform

use of com.ait.lienzo.client.core.types.Transform in project drools-wb by kiegroup.

the class ColumnHeaderPopOverImpl method getScreenX.

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;
}
Also used : GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) GridLayer(org.uberfire.ext.wires.core.grids.client.widget.layer.GridLayer) Transform(com.ait.lienzo.client.core.types.Transform) BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)

Aggregations

Transform (com.ait.lienzo.client.core.types.Transform)19 Test (org.junit.Test)9 Bounds (org.uberfire.ext.wires.core.grids.client.model.Bounds)4 BaseBounds (org.uberfire.ext.wires.core.grids.client.model.impl.BaseBounds)4 Viewport (com.ait.lienzo.client.core.shape.Viewport)3 Mediators (com.ait.lienzo.client.core.mediator.Mediators)2 Point2D (com.ait.lienzo.client.core.types.Point2D)2 Element (com.google.gwt.user.client.Element)2 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)2 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)2 GridLayer (org.uberfire.ext.wires.core.grids.client.widget.layer.GridLayer)2 TransformMediator (org.uberfire.ext.wires.core.grids.client.widget.layer.pinning.TransformMediator)2 Group (com.ait.lienzo.client.core.shape.Group)1 ScrollEvent (com.google.gwt.event.dom.client.ScrollEvent)1 ScrollHandler (com.google.gwt.event.dom.client.ScrollHandler)1 Before (org.junit.Before)1 BaseGridRendererHelper (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)1