Example usage for com.google.gwt.user.client.ui MouseWheelVelocity getDeltaY

List of usage examples for com.google.gwt.user.client.ui MouseWheelVelocity getDeltaY

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui MouseWheelVelocity getDeltaY.

Prototype

@Deprecated
public int getDeltaY() 

Source Link

Document

Returns the change in the mouse wheel position along the Y-axis; positive if the mouse wheel is moving north (toward the top of the screen) or negative if the mouse wheel is moving south (toward the bottom of the screen).

Usage

From source file:org.vectomatic.client.rep.view.DrawingView.java

License:Open Source License

public DrawingView(RepresentationController repController, DrawingModel model, int width, int height) {
    super(width, height);
    saveContext();/*from  w  w  w  . j av  a 2s .c  om*/
    _t = new Point();
    _s = new Point(Point.UNIT);
    _m = new TransformMatrix();

    _repController = repController;
    _model = model;
    _mInv = new TransformMatrix();
    _compass = new Compass(this);
    _compass.setPosition(new Point(width - 70, 50));
    _compass.setRadius(45);
    _renderer = new RenderVisitor(this);
    _picker = new PickVisitor(this);
    addMouseListener(new MouseListenerAdapter() {
        Point p = new Point();

        @Override
        public void onMouseDown(Widget sender, int x, int y) {
            p.x = x;
            p.y = y;
            //RepApplication.app.debugArea.setText(toModelCoordinates(p, new Point()).toString());
            if (_compass.pick(p) != Compass.NONE) {
                _compassMode = true;
                _compass.mouseDown(p);
            } else {
                _compassMode = false;
                //p.transform(_mInv);
                RepApplication.app.debugPrint("x=" + p.x + " y=" + p.y);
                _controller.mouseDown(DrawingView.this, p, modifiers);
            }
        }

        @Override
        public void onMouseMove(Widget sender, int x, int y) {
            p.x = x;
            p.y = y;
            if (_compassMode) {
                _compass.mouseMove(p);
            } else {
                _compass.pick(p);
                //p.transform(_mInv);
                _controller.mouseMove(DrawingView.this, p, modifiers);
            }
        }

        @Override
        public void onMouseUp(Widget sender, int x, int y) {
            p.x = x;
            p.y = y;
            if (_compassMode) {
                _compass.mouseUp();
                _compassMode = false;
            } else {
                //p.transform(_mInv);
                _controller.mouseUp(DrawingView.this, p, modifiers);
            }
        }
    });
    addKeyboardListener(new KeyboardListener() {
        public void onKeyDown(Widget sender, char keyCode, int modifiers) {
            _controller.keyDown(DrawingView.this, keyCode, modifiers);
        }

        public void onKeyPress(Widget sender, char keyCode, int modifiers) {
            _controller.keyPress(DrawingView.this, keyCode, modifiers);
        }

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            _controller.keyUp(DrawingView.this, keyCode, modifiers);
        }
    });
    addMouseWheelListener(new MouseWheelListener() {
        Point p = new Point();

        public void onMouseWheel(Widget sender, MouseWheelVelocity velocity) {
            int delta = 10 * velocity.getDeltaY();
            if ((modifiers & KeyboardListener.MODIFIER_CTRL) != 0) {
                if (delta > 0) {
                    float s = _compass.getScaling();
                    _compass.setScaling(s + 0.1f * (1 - s));
                } else {
                    float s = _compass.getScaling();
                    _compass.setScaling(s - 0.1f * s);
                }
            } else {
                if ((modifiers & KeyboardListener.MODIFIER_ALT) != 0) {
                    p.x = delta;
                    p.y = 0f;
                } else {
                    p.x = 0f;
                    p.y = delta;
                }
                _compass.translate(p);
            }
        }
    });
}