Java Code Examples for com.google.gwt.event.dom.client.MouseWheelEvent#isNorth()

The following examples show how to use com.google.gwt.event.dom.client.MouseWheelEvent#isNorth() . 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: MouseWheelControl.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 2
Source File: MouseWheelControl.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}