@Test public void testInit() { tested.init(() -> canvas); verify(selector, times(1)).setText(eq("100%")); verify(selector, times(1)).dropUp(); verify(selector, times(1)).onReset(any(Command.class)); verify(selector, times(1)).onIncreaseLevel(any(Command.class)); verify(selector, times(1)).onDecreaseLevel(any(Command.class)); verify(selector, times(1)).add(eq(ZoomLevelSelectorPresenter.LEVEL_25), any(Command.class)); verify(selector, times(1)).add(eq(ZoomLevelSelectorPresenter.LEVEL_50), any(Command.class)); verify(selector, times(1)).add(eq(ZoomLevelSelectorPresenter.LEVEL_75), any(Command.class)); verify(selector, times(1)).add(eq(ZoomLevelSelectorPresenter.LEVEL_100), any(Command.class)); verify(selector, times(1)).add(eq(ZoomLevelSelectorPresenter.LEVEL_150), any(Command.class)); verify(selector, times(1)).add(eq(ZoomLevelSelectorPresenter.LEVEL_200), any(Command.class)); verify(selector, times(1)).add(eq(CoreTranslationMessages.FIT), any(Command.class)); verify(floatingView, times(1)).add(eq(selector)); verify(viewport, times(1)).addViewportTransformChangedHandler(any(ViewportTransformChangedHandler.class)); verify(panelView, never()).addMouseOutHandler(any(MouseOutHandler.class)); verify(panelView, never()).addMouseOverHandler(any(MouseOverHandler.class)); }
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; }
ZoomLevelSelectorPresenter { 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; } }
ZoomLevelSelectorPresenter { 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; } @Inject  ZoomLevelSelectorPresenter(final ClientTranslationService translationService,
                                      final FloatingView<IsWidget> floatingView,
                                      final ZoomLevelSelector selector); }
ZoomLevelSelectorPresenter { 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; } @Inject  ZoomLevelSelectorPresenter(final ClientTranslationService translationService,
                                      final FloatingView<IsWidget> floatingView,
                                      final ZoomLevelSelector selector); @PostConstruct void construct(); ZoomLevelSelectorPresenter init(final Supplier<LienzoCanvas> canvas); ZoomLevelSelectorPresenter setMinScale(double minScale); ZoomLevelSelectorPresenter setMaxScale(double maxScale); ZoomLevelSelectorPresenter setZoomFactor(double zoomFactor); ZoomLevelSelectorPresenter at(final double x,
                                         final double y); ZoomLevelSelectorPresenter show(); ZoomLevelSelectorPresenter hide(); @PreDestroy void destroy(); }
ZoomLevelSelectorPresenter { 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; } @Inject  ZoomLevelSelectorPresenter(final ClientTranslationService translationService,
                                      final FloatingView<IsWidget> floatingView,
                                      final ZoomLevelSelector selector); @PostConstruct void construct(); ZoomLevelSelectorPresenter init(final Supplier<LienzoCanvas> canvas); ZoomLevelSelectorPresenter setMinScale(double minScale); ZoomLevelSelectorPresenter setMaxScale(double maxScale); ZoomLevelSelectorPresenter setZoomFactor(double zoomFactor); ZoomLevelSelectorPresenter at(final double x,
                                         final double y); ZoomLevelSelectorPresenter show(); ZoomLevelSelectorPresenter hide(); @PreDestroy void destroy();  }