Search in sources :

Example 1 with LienzoPanel

use of org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoPanel in project kie-wb-common by kiegroup.

the class LienzoPanelMediators method init.

public LienzoPanelMediators init(final Supplier<LienzoCanvas> canvas) {
    CanvasPanel panel = canvas.get().getView().getPanel();
    if (panel instanceof LienzoPanel) {
        focusHandler = new LienzoPanelFocusHandler().listen((LienzoPanel) canvas.get().getView().getPanel(), this::enable, this::disable);
        mediators.init(canvas);
        selector.init(canvas);
        setZoomFactor(ZOOM_FACTOR);
        setMinScale(MIN_SCALE);
        setMaxScale(MAX_SCALE);
        enable();
    }
    return this;
}
Also used : CanvasPanel(org.kie.workbench.common.stunner.core.client.canvas.CanvasPanel) LienzoPanelFocusHandler(org.kie.workbench.common.stunner.client.lienzo.components.views.LienzoPanelFocusHandler) LienzoPanel(org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoPanel)

Example 2 with LienzoPanel

use of org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoPanel in project kie-wb-common by kiegroup.

the class LienzoCanvasNotification method show.

public void show(final String text) {
    final LienzoPanel p = panel.get();
    final int absoluteLeft = p.getView().getAbsoluteLeft();
    final int absoluteTop = p.getView().getAbsoluteTop();
    final int width = p.getWidthPx();
    final double x = absoluteLeft + (width / 2) - (5 * text.length());
    final double y = absoluteTop + 50;
    view.at(x, y);
    view.setText(text);
    view.show();
}
Also used : LienzoPanel(org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoPanel)

Example 3 with LienzoPanel

use of org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoPanel in project kie-wb-common by kiegroup.

the class LienzoCanvasMediators method init.

public void init(final Supplier<LienzoCanvas> canvas) {
    keyEventHandler.setTimerDelay(150).addKeyShortcutCallback(new KeyboardControl.KeyShortcutCallback() {

        @Override
        public void onKeyShortcut(Key... keys) {
            if (doKeysMatch(keys, Key.CONTROL)) {
                enableZoom();
            } else if (doKeysMatch(keys, Key.ALT)) {
                enablePan();
            } else if (doKeysMatch(keys, Key.CONTROL, Key.ALT) || doKeysMatch(keys, Key.ALT, Key.CONTROL)) {
                enablePreview();
            }
        }

        @Override
        public void onKeyUp(Key key) {
            clear();
        }
    });
    cursor = c -> canvas.get().getView().setCursor(c);
    final LienzoPanel panel = (LienzoPanel) canvas.get().getView().getPanel();
    this.mediators = mediatorsBuilder.apply(panel.getView());
    this.notification.init(() -> panel);
    setScaleAboutPoint(false);
}
Also used : KeyboardControl(org.kie.workbench.common.stunner.core.client.canvas.controls.keyboard.KeyboardControl) LienzoPanel(org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoPanel) Key(org.kie.workbench.common.stunner.core.client.event.keyboard.KeyboardEvent.Key)

Example 4 with LienzoPanel

use of org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoPanel in project kie-wb-common by kiegroup.

the class ZoomLevelSelectorPresenter method reposition.

private void reposition() {
    final LienzoPanel panel = getPanel();
    onPanelResize(panel.getView().getWidthPx(), panel.getView().getHeightPx());
}
Also used : LienzoPanel(org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoPanel)

Example 5 with LienzoPanel

use of org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoPanel in project kie-wb-common by kiegroup.

the class ZoomLevelSelectorPresenter method init.

public ZoomLevelSelectorPresenter init(final Supplier<LienzoCanvas> canvas) {
    this.canvas = canvas;
    final Layer layer = getLayer();
    final LienzoPanel panel = getPanel();
    selector.setText(parseLevel(1)).dropUp().onReset(this::reset).onIncreaseLevel(this::increaseLevel).onDecreaseLevel(this::decreaseLevel).add(LEVEL_25, () -> setLevel(0.25)).add(LEVEL_50, () -> setLevel(0.5)).add(LEVEL_75, () -> setLevel(0.75)).add(LEVEL_100, () -> setLevel(1)).add(LEVEL_150, () -> setLevel(1.5)).add(LEVEL_200, () -> setLevel(2)).add(translationService.getNotNullValue(CoreTranslationMessages.FIT), () -> setLevel(computeZoomLevelFitToWidth(panel.getView())));
    floatingView.add(selector);
    if (panel.getView() instanceof ScrollablePanel) {
        ScrollablePanel scrollablePanel = (ScrollablePanel) panel.getView();
        panelResizeHandlerRegistration = scrollablePanel.addLienzoPanelResizeEventHandler(event -> onPanelResize(event.getWidth(), event.getHeight()));
    }
    reposition();
    transformChangedHandler = layer.getViewport().addViewportTransformChangedHandler(event -> onViewportTransformChanged());
    selectorOverHandler = selector.asWidget().addDomHandler(mouseOverEvent -> cancelHide(), MouseOverEvent.getType());
    return this;
}
Also used : FloatingView(org.kie.workbench.common.stunner.core.client.components.views.FloatingView) Supplier(java.util.function.Supplier) LienzoCanvas(org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoCanvas) PanelTransformUtils.setScaleLevel(com.ait.lienzo.client.widget.panel.util.PanelTransformUtils.setScaleLevel) ScrollablePanel(com.ait.lienzo.client.widget.panel.scrollbars.ScrollablePanel) LienzoPanel(org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoPanel) Inject(javax.inject.Inject) HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) PreDestroy(javax.annotation.PreDestroy) ClientTranslationService(org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService) CoreTranslationMessages(org.kie.workbench.common.stunner.core.i18n.CoreTranslationMessages) Layer(com.ait.lienzo.client.core.shape.Layer) Dependent(javax.enterprise.context.Dependent) LienzoCanvasView(org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoCanvasView) PostConstruct(javax.annotation.PostConstruct) PanelTransformUtils(com.ait.lienzo.client.widget.panel.util.PanelTransformUtils) IsWidget(com.google.gwt.user.client.ui.IsWidget) PanelTransformUtils.computeLevel(com.ait.lienzo.client.widget.panel.util.PanelTransformUtils.computeLevel) PanelTransformUtils.computeZoomLevelFitToWidth(com.ait.lienzo.client.widget.panel.util.PanelTransformUtils.computeZoomLevelFitToWidth) Timer(com.google.gwt.user.client.Timer) MouseOverEvent(com.google.gwt.event.dom.client.MouseOverEvent) ScrollablePanel(com.ait.lienzo.client.widget.panel.scrollbars.ScrollablePanel) LienzoPanel(org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoPanel) Layer(com.ait.lienzo.client.core.shape.Layer)

Aggregations

LienzoPanel (org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoPanel)6 Layer (com.ait.lienzo.client.core.shape.Layer)1 ScrollablePanel (com.ait.lienzo.client.widget.panel.scrollbars.ScrollablePanel)1 PanelTransformUtils (com.ait.lienzo.client.widget.panel.util.PanelTransformUtils)1 PanelTransformUtils.computeLevel (com.ait.lienzo.client.widget.panel.util.PanelTransformUtils.computeLevel)1 PanelTransformUtils.computeZoomLevelFitToWidth (com.ait.lienzo.client.widget.panel.util.PanelTransformUtils.computeZoomLevelFitToWidth)1 PanelTransformUtils.setScaleLevel (com.ait.lienzo.client.widget.panel.util.PanelTransformUtils.setScaleLevel)1 MouseOverEvent (com.google.gwt.event.dom.client.MouseOverEvent)1 HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)1 Timer (com.google.gwt.user.client.Timer)1 IsWidget (com.google.gwt.user.client.ui.IsWidget)1 Supplier (java.util.function.Supplier)1 PostConstruct (javax.annotation.PostConstruct)1 PreDestroy (javax.annotation.PreDestroy)1 Dependent (javax.enterprise.context.Dependent)1 Inject (javax.inject.Inject)1 LienzoCanvas (org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoCanvas)1 LienzoCanvasView (org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoCanvasView)1 LienzoPanelFocusHandler (org.kie.workbench.common.stunner.client.lienzo.components.views.LienzoPanelFocusHandler)1 CanvasPanel (org.kie.workbench.common.stunner.core.client.canvas.CanvasPanel)1