public void onMouseWheel(MouseWheelEvent event) { try { ChartState chartInfo = getChartState(event); Chart chart = chartInfo.chart; int wheelDir = event.getNativeEvent().getMouseWheelVelocityY(); boolean isMouseWheelUp = (wheelDir <= 0); if (isMouseWheelUp) { chart.nextZoom(); } else { chart.prevZoom(); } chartInfo.setHandled(true); } catch (Exception e) { e.printStackTrace(); } // Do not move scroll event.preventDefault(); }
public void onMouseWheel(MouseWheelEvent e) { e.preventDefault(); // once we start zooming, don't allow other uses of mouse wheel for a while // so we don't accidentally edit a resistor value while zooming boolean zoomOnly = System.currentTimeMillis() < zoomTime+1000; if (!zoomOnly) scrollValues(e.getNativeEvent().getClientX(), e.getNativeEvent().getClientY(), e.getDeltaY()); if (mouseElm instanceof MouseWheelHandler && !zoomOnly) ((MouseWheelHandler) mouseElm).onMouseWheel(e); else if (scopeSelected != -1) scopes[scopeSelected].onMouseWheel(e); else if (!dialogIsShowing()) { zoomCircuit(e.getDeltaY()); zoomTime = System.currentTimeMillis(); } }
@UiHandler("paletteChooser") void onPaletteChooserMouseWheel(MouseWheelEvent event) { // determine new index based on scroll direction int newIndex = paletteChooser.getSelectedIndex(); if (event.getDeltaY() < 0) { newIndex--; } else { newIndex++; } // set new index (if it's valid) and trigger change event (is not automatically triggered) if (newIndex >= 0 && newIndex < paletteChooser.getItemCount()) { paletteChooser.setSelectedIndex(newIndex); DomEvent.fireNativeEvent(Document.get().createChangeEvent(), paletteChooser); } }
@Override public void onMouseWheel(MouseWheelEvent event) { if(useTrackball){ return; } double tzoom=0.05*baseScale; //TODO make class long t=System.currentTimeMillis(); if(mouseLast+100>t){ czoom*=2; }else{ czoom=tzoom; } //GWT.log("wheel:"+event.getDeltaY()); double tmp=cameraZ+event.getDeltaY()*czoom; tmp=Math.max(0.2, tmp); tmp=Math.min(4000, tmp); cameraZ=(double)tmp; mouseLast=t; }
@Override public void onMouseWheel( MouseWheelEvent event ) { if( m_callback == null ) return; event.preventDefault(); int x = event.getRelativeX( m_canvas.getElement() ); int delta = event.getDeltaY(); if( delta > 0 ) delta = 1; else if( delta < 0 ) delta = -1; m_callback.onMouseWheel( m_cookie, event, x, delta ); }
public VImageViewer() { /* Create widget's root panel */ panelRoot = new FlowPanel(); Style style = panelRoot.getElement().getStyle(); style.setPosition(Position.RELATIVE); setStyleName(CLASSNAME); panelRoot.setStyleName(CLASSNAME + "-flow"); style.setWidth(100, Unit.PCT); style.setHeight(100, Unit.PCT); /* Create image container */ imageContainer = new FlowPanel(); style = imageContainer.getElement().getStyle(); style.setPosition(Position.ABSOLUTE); style.setOverflow(Overflow.HIDDEN); /* Add widgets */ setWidget(panelRoot); panelRoot.add(imageContainer); /* Register handlers */ addDomHandler(this, KeyDownEvent.getType()); addDomHandler(this, ClickEvent.getType()); addMouseWheelHandler(new MouseWheelHandler() { public void onMouseWheel(MouseWheelEvent event) { event.preventDefault(); if (event.isNorth()) { moveImages(true); } else { moveImages(false); } } }); }
void onMouseWheel(MouseWheelEvent e) { wheelDeltaY += e.getDeltaY(); if (wheelDeltaY > 5) { slowDown(); wheelDeltaY = 0; } if (wheelDeltaY < -5) speedUp(); wheelDeltaY = 0; }
@Override public void onMouseWheel(MouseWheelEvent event) { if (event.isControlKeyDown()) { int delta = event.getDeltaY(); app.getToolbar().zoomChangeClicked(Integer.signum(-delta)); event.preventDefault(); } }
@Test public void testSetupContextSwitcher() { final AbsolutePanel domElementContainer = mock(AbsolutePanel.class); final LienzoPanel lienzoPanel = mock(LienzoPanel.class); final MouseWheelHandler wheelHandler = mock(MouseWheelHandler.class); final MouseMoveHandler moveHandler = mock(MouseMoveHandler.class); doReturn(domElementContainer).when(gridLienzoPanel).getDomElementContainer(); doReturn(wheelHandler).when(gridLienzoScrollHandler).disablePointerEvents(); doReturn(moveHandler).when(gridLienzoScrollHandler).enablePointerEvents(); gridLienzoScrollHandler.setupContextSwitcher(); verify(domElementContainer).addDomHandler(wheelHandler, MouseWheelEvent.getType()); verify(gridLienzoPanel).addMouseMoveHandler(moveHandler); }
public void setMouseWheelMoved(JavaScriptObject aValue) { if (mouseWheelMoved != aValue) { if (mouseWheelReg != null) { mouseWheelReg.removeHandler(); mouseWheelReg = null; } mouseWheelMoved = aValue; if (mouseWheelMoved != null) { MouseWheelHandler handler = new MouseWheelHandler() { @Override public void onMouseWheel(MouseWheelEvent event) { if (mouseWheelMoved != null) { event.stopPropagation(); executeEvent(mouseWheelMoved, EventsPublisher.publish(event)); } } }; if (component instanceof Widget) { mouseWheelReg = ((Widget) component).addDomHandler(handler, MouseWheelEvent.getType()); } else if (component instanceof HasMouseWheelHandlers) { mouseWheelReg = ((HasMouseWheelHandlers) component).addMouseWheelHandler(handler); } } } }
@Override public HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler) { return this.addDomHandler(handler, MouseWheelEvent.getType()); }
public void onMouseWheel(MouseWheelEvent event) { final boolean isNorth; if (event.getDeltaY() == 0) { isNorth = (getWheelDelta(event.getNativeEvent()) < 0); } else { isNorth = event.isNorth(); } if (isNorth) { if (zoomType == ScrollZoomType.ZOOM_POSITION) { mapModel.getMapView().scale( 2.0f, MapView.ZoomOption.LEVEL_CHANGE, mapModel.getMapView().getWorldViewTransformer() .viewToWorld(new Coordinate(event.getX(), event.getY()))); } else { mapModel.getMapView().scale(2.0f, MapView.ZoomOption.LEVEL_CHANGE); } } else { if (zoomType == ScrollZoomType.ZOOM_POSITION) { mapModel.getMapView().scale( 0.5f, MapView.ZoomOption.LEVEL_CHANGE, mapModel.getMapView().getWorldViewTransformer() .viewToWorld(new Coordinate(event.getX(), event.getY()))); } else { mapModel.getMapView().scale(0.5f, MapView.ZoomOption.LEVEL_CHANGE); } } }
@Override public void onMouseWheel(MouseWheelEvent event) { final boolean isNorth; if (event.getDeltaY() == 0) { isNorth = (getWheelDelta(event.getNativeEvent()) < 0); } else { isNorth = event.isNorth(); } Coordinate location = getLocation(event, RenderSpace.WORLD); scrollZoomTo(isNorth, location); }
/** * Update event caches to keep track of the latest event of each instance. * @param the event to cache */ private void updateEventCaches(Event<?> event){ if(event == null){ return; } if(event instanceof DoubleClickEvent){ doubleClickEvent = new org.gz.gwt.mousemanager.client.event.DoubleClickEvent((DoubleClickEvent)event, target); } if(event instanceof ClickEvent){ clickEvent = new org.gz.gwt.mousemanager.client.event.ClickEvent((ClickEvent)event, target); } if(event instanceof MouseUpEvent){ mouseUpEvent = new org.gz.gwt.mousemanager.client.event.MouseUpEvent((MouseUpEvent)event, target); } if(event instanceof MouseDownEvent){ mouseDownEvent = new org.gz.gwt.mousemanager.client.event.MouseDownEvent((MouseDownEvent)event, target); } if(event instanceof MouseMoveEvent){ mouseMoveEvent = new org.gz.gwt.mousemanager.client.event.MouseMoveEvent((MouseMoveEvent)event, target); } if(event instanceof MouseOverEvent){ mouseOverEvent = new org.gz.gwt.mousemanager.client.event.MouseOverEvent((MouseOverEvent)event, target); } if(event instanceof MouseOutEvent){ mouseOutEvent = new org.gz.gwt.mousemanager.client.event.MouseOutEvent((MouseOutEvent)event, target); } if(event instanceof MouseWheelEvent){ mouseWheelEvent = new org.gz.gwt.mousemanager.client.event.MouseWheelEvent((MouseWheelEvent)event, target); } if(event instanceof ContextMenuEvent){ contextMenuEvent = new org.gz.gwt.mousemanager.client.event.ContextMenuEvent(); } }
@Override public void onMouseWheel(MouseWheelEvent event) { int wheelDelta = event.getDeltaY(); wheelDelta = wheelDelta != 0 ? wheelDelta : workaroundEventGetMouseWheelVelocityY(event.getNativeEvent()); this.setMousePoint(event.getRelativeX(m_container.getElement()), event.getRelativeY(m_container.getElement()), m_mouseEvent.getPoint()); m_mouseEvent.set(E_MouseEventType.MOUSE_SCROLLED, -wheelDelta, Element.as(event.getNativeEvent().getEventTarget()), false); s_logger.log(Level.INFO, "scroll" + m_mouseEvent.getScrollDelta()); dispatchEvent(m_mouseEvent); }
@Override public void onMouseWheel(MouseWheelEvent event) { if(event.getDeltaY() > 0) { scale /= KEY_ZOOM_STEP; } else { scale *= KEY_ZOOM_STEP; } updateZoom(); event.preventDefault(); }
/** * Computes the new bounds of the image for the preview */ private Bounds changeImageBounds(MouseWheelEvent mouseWheelEvent) { // memorizing current mouse position Point mousePos = new Point(mouseWheelEvent.getX() - getViewportBounds().getLeft(), mouseWheelEvent.getY() - getViewportBounds().getTop()); // zoom in or zoom out at the center (the inverse of changeSetBounds) Bounds newImageBounds; if (mouseWheelEvent.isNorth()) { newImageBounds = getViewportDataAreaBounds().transformProportional( createZoomOutBounds(computeDelta(mouseWheelEvent))); } else { newImageBounds = getViewportDataAreaBounds().transformProportional( createZoomInBounds(computeDelta(mouseWheelEvent))); } // translating it back to the viewport size newImageBounds = newImageBounds.transform(getViewportDataAreaBounds(), getViewportBounds()); // new pixel position at mouse coordinates Point relPoint = new Point((mouseWheelEvent.getX() - getViewportBounds().getLeft()) / getViewportBounds().getWidth(), (mouseWheelEvent.getY() - getViewportBounds().getTop()) / getViewportBounds().getHeight()); Point newMousePos = newImageBounds.findAbsolutePoint(relPoint); // shifting the mousePos back to the mouse position newImageBounds = newImageBounds.shiftAbsolute(mousePos.getX() - newMousePos.getX(), mousePos.getY() - newMousePos.getY()); return newImageBounds; }
ScrollValuePopup(final int x, final int y, int dy, CircuitElm e, CirSim s) { super(); myElm=e; deltaY=0; sim=s; sim.pushUndo(); vp=new VerticalPanel(); setWidget(vp); setupValues(); vp.add(new Label(name)); labels=new Label[labMax]; for (int i=0; i<labMax; i++) { labels[i] = new Label("---"); labels[i].setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); if (i==2) labels[i].addStyleDependentName("selected"); else if (i==1 || i==3) labels[i].addStyleDependentName("1off"); else labels[i].addStyleDependentName("2off"); vp.add(labels[i]); } doDeltaY(dy); this.addDomHandler(this, MouseOutEvent.getType()); this.addDomHandler(this, MouseWheelEvent.getType()); this.addDomHandler(this, MouseDownEvent.getType()); // this.addDomHandler(this, KeyPressEvent.getType()); setPopupPositionAndShow(new PopupPanel.PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { int left = Math.max(0, (x - offsetWidth/4)); int top = Math.max(0, y - 7*offsetHeight/12); setPopupPosition(left, top); } }); }
public void onMouseWheel(MouseWheelEvent e) { e.preventDefault(); doDeltaY( e.getDeltaY()); }
public void onMouseWheel(MouseWheelEvent e) { e.preventDefault(); if (enabled) setValue(val+e.getDeltaY()/3); }
public PanController(Widget widget) { super(widget); widget.addDomHandler(this, MouseWheelEvent.getType()); widget.addDomHandler(this, KeyDownEvent.getType()); app.getHorizontalScrollbar().addScrollPanListener(this); app.getVerticalScrollbar().addScrollPanListener(this); }
void setupContextSwitcher() { getDomElementContainer().addDomHandler(disablePointerEvents(), MouseWheelEvent.getType()); getPanel().addMouseMoveHandler(enablePointerEvents()); }
@Test public void testDisablePointerEvents() { final MouseWheelEvent mouseWheelEvent = mock(MouseWheelEvent.class); final AbsolutePanel domElementContainer = mock(AbsolutePanel.class); final GridLienzoScrollUI scrollUI = mock(GridLienzoScrollUI.class); doReturn(domElementContainer).when(gridLienzoPanel).getDomElementContainer(); doReturn(scrollUI).when(gridLienzoScrollHandler).gridLienzoScrollUI(); doNothing().when(scrollUI).disablePointerEvents(any()); gridLienzoScrollHandler.disablePointerEvents().onMouseWheel(mouseWheelEvent); verify(scrollUI).disablePointerEvents(domElementContainer); }
public GreenScrollPanel(boolean withHorizontalScroll) { mainPanel = new ResizeLayoutPanel() { @Override protected void onAttach() { super.onAttach(); // hack to hide scrollbar in chrome when leaflet map is also // displayed (check GreenScrollImpl.onAttach too) if (isChrome()) { try { ((Element) (getElement().getChild(1))).getStyle().setZIndex(-1000); ((Element) (getElement().getChild(2))).getStyle().setZIndex(-1000); } catch (Exception e) { GWT.log("", e); } } } }; if (hasMacNanoScrollBar()) { this.impl = new ScrollPanel(); } else { this.impl = new GreenScrollImpl(withHorizontalScroll); } mainPanel.setWidget(impl); impl.addDomHandler(new MouseWheelHandler() { @Override public void onMouseWheel(MouseWheelEvent event) { event.stopPropagation(); } }, MouseWheelEvent.getType()); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler) { eventHandlers.put(handler, (DomEvent.Type) MouseWheelEvent.getType()); if (canvas != null) { canvas.addDomHandler(handler, MouseWheelEvent.getType()); } return null; }
@Override public HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler) { return addDomHandler(handler, MouseWheelEvent.getType()); }
/** * Return Event object string identifier * @param event * @return Type name of the event object */ private static String convertNativeEventToStringIdentifier(Event<?> event){ if(event == null){ return ""; } if(event instanceof DoubleClickEvent){ return DoubleClickEvent.getType().getName(); } if(event instanceof ClickEvent){ return ClickEvent.getType().getName(); } if(event instanceof MouseUpEvent){ return MouseUpEvent.getType().getName(); } if(event instanceof MouseDownEvent){ return MouseDownEvent.getType().getName(); } if(event instanceof MouseMoveEvent){ return MouseMoveEvent.getType().getName(); } if(event instanceof MouseOverEvent){ return MouseOverEvent.getType().getName(); } if(event instanceof MouseOutEvent){ return MouseOutEvent.getType().getName(); } if(event instanceof MouseWheelEvent){ return MouseWheelEvent.getType().getName(); } if(event instanceof ContextMenuEvent){ return ContextMenuEvent.getType().getName(); } return ""; }
@Override public void onMouseWheel(MouseWheelEvent event) { if (event.isNorth()) { getConnector().doZoomOut(); } else if (event.isSouth()){ getConnector().doZoomIn(); } }
public DMNGridPanel(final DMNGridLayer gridLayer, final RestrictedMousePanMediator mousePanMediator) { super(LIENZO_PANEL_WIDTH, LIENZO_PANEL_HEIGHT); this.gridLayer = gridLayer; this.mousePanMediator = mousePanMediator; getDomElementContainer().addDomHandler(destroyDOMElements(), MouseWheelEvent.getType()); }
private void addMouseDownHandlers() { m_container.addDomHandler(this, MouseWheelEvent.getType()); m_container.addDomHandler(this, MouseOverEvent.getType()); m_container.addDomHandler(this, MouseOutEvent.getType()); m_container.addDomHandler(this, MouseMoveEvent.getType()); m_container.addDomHandler(this, MouseUpEvent.getType()); m_container.addDomHandler(this, MouseDownEvent.getType()); m_container.addDomHandler(this, TouchStartEvent.getType()); m_container.addDomHandler(this, TouchEndEvent.getType()); m_container.addDomHandler(this, TouchMoveEvent.getType()); }
private void attach(SVGSVGElement svg) { OMSVGSVGElement omsvg = OMDocument.convert(svg); omsvg.addMouseDownHandler(this); omsvg.addMouseUpHandler(this); omsvg.addMouseMoveHandler(this); omsvg.addClickHandler(this); RootPanel.get().addDomHandler(this, MouseWheelEvent.getType()); RootPanel.get().addDomHandler(this, KeyPressEvent.getType()); }
/** * Computes the new domain bounds */ private Bounds changeDomainBounds(MouseWheelEvent mouseWheelEvent) { Bounds setBounds = this.currentSetDomainBoundsEvent.getBounds(); // memorizing the domain point at the current mouse position Point originalDomainPoint = computeDomainPointAtMousePosition(mouseWheelEvent, setBounds); // zoom in or zoom out at the center if (mouseWheelEvent.isNorth()) { setBounds = this.currentSetDomainBoundsEvent.getBounds().transformProportional( createZoomInBounds(computeDelta(mouseWheelEvent))); } else { setBounds = this.currentSetDomainBoundsEvent.getBounds().transformProportional( createZoomOutBounds(computeDelta(mouseWheelEvent))); } // figuring out the new domain point at the mouse position Point newDomainPoint = computeDomainPointAtMousePosition(mouseWheelEvent, setBounds); // shifting the originalDomainPoint back to the mouse position setBounds = setBounds.shiftAbsolute(originalDomainPoint.getX() - newDomainPoint.getX(), originalDomainPoint.getY() - newDomainPoint.getY()); if (this.currentMaxDomainBoundsEvent == null || (this.currentMaxDomainBoundsEvent.containsHorizontally(setBounds.getLeft(), setBounds.getRight()) && this.currentMaxDomainBoundsEvent .containsVertically(setBounds.getTop(), setBounds.getBottom()))) { return setBounds; } else { return null; } }
private Point computeDomainPointAtMousePosition(MouseWheelEvent mouseWheelEvent, Bounds domainBounds) { Bounds viewportDataAreaBounds = getViewportDataAreaBounds(); Point relPoint = new Point((mouseWheelEvent.getX() - viewportDataAreaBounds.getLeft()) / viewportDataAreaBounds.getWidth(), (mouseWheelEvent.getY() - viewportDataAreaBounds.getTop()) / viewportDataAreaBounds.getHeight()); return domainBounds.findAbsolutePoint(relPoint); }
private int computeDelta(MouseWheelEvent mouseWheelEvent) { /* * If the user scrolls fast, multiple mouse wheels might be summed up to * one event. GWT seems to normalize the different deltas across browser * to a multiple of 3 (3, 6, 9... tested with IE, FF, Chrome). * * Here we normalize to 1, 2, 3... */ return Math.abs(mouseWheelEvent.getDeltaY() / 3); // integer division }
@Override public HandlerRegistration addMouseWheelHandler( MouseWheelHandler handler) { return addHandler(handler, MouseWheelEvent.getType()); }
public HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler) { return addDomHandler(handler, MouseWheelEvent.getType()); }
public void onMouseWheel(MouseWheelEvent e) { if (slider!=null) slider.onMouseWheel(e); }
@Override public HandlerRegistration addMouseWheelHandler(final MouseWheelHandler handler) { return this.addDomHandler(handler, MouseWheelEvent.getType()); }
public native static JavaScriptObject publish(MouseWheelEvent aEvent)/*-{ var constr = @com.eas.ui.EventsPublisher::getPublisher(Ljava/lang/String;)('MouseEvent'); return new constr(aEvent); }-*/;