com.google.gwt.event.dom.client.MouseWheelEvent Java Examples
The following examples show how to use
com.google.gwt.event.dom.client.MouseWheelEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CirSim.java From circuitjs1 with GNU General Public License v2.0 | 6 votes |
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(); } repaint(); }
Example #2
Source File: SinglePageLayout.java From djvu-html5 with GNU General Public License v2.0 | 5 votes |
public PanController(Widget widget) { super(widget); widget.addDomHandler(this, MouseWheelEvent.getType()); widget.addDomHandler(this, KeyDownEvent.getType()); app.getHorizontalScrollbar().addScrollPanListener(this); app.getVerticalScrollbar().addScrollPanListener(this); }
Example #3
Source File: SinglePageLayout.java From djvu-html5 with GNU General Public License v2.0 | 5 votes |
@Override public void onMouseWheel(MouseWheelEvent event) { if (event.isControlKeyDown()) { int delta = event.getDeltaY(); app.getToolbar().zoomChangeClicked(Integer.signum(-delta)); event.preventDefault(); } }
Example #4
Source File: MouseWheelControl.java From SensorWebClient with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example #5
Source File: MouseWheelControl.java From SensorWebClient with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #6
Source File: MouseWheelControl.java From SensorWebClient with GNU General Public License v2.0 | 5 votes |
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); }
Example #7
Source File: MouseWheelControl.java From SensorWebClient with GNU General Public License v2.0 | 5 votes |
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 }
Example #8
Source File: HandlerPanel.java From appinventor-extensions with Apache License 2.0 | 4 votes |
public HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler) { return addDomHandler(handler, MouseWheelEvent.getType()); }
Example #9
Source File: P.java From unitime with Apache License 2.0 | 4 votes |
@Override public HandlerRegistration addMouseWheelHandler( MouseWheelHandler handler) { return addHandler(handler, MouseWheelEvent.getType()); }
Example #10
Source File: AbstractInput.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 4 votes |
@Override public com.google.gwt.event.shared.HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler) { return this.addDomHandler(handler, MouseWheelEvent.getType()); }
Example #11
Source File: ListItem.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 4 votes |
@Override public HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler) { return this.addDomHandler(handler, MouseWheelEvent.getType()); }
Example #12
Source File: Anchor.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 4 votes |
@Override public HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler) { return this.addDomHandler(handler, MouseWheelEvent.getType()); }