Search in sources :

Example 1 with MouseEvent

use of com.jogamp.newt.event.MouseEvent in project narchy by automenta.

the class NEWTKBD method HandleEvents.

private void HandleEvents() {
    int key;
    Jake2InputEvent event;
    while ((event = InputListener.nextEvent()) != null) {
        Window eventWin = null;
        Object source = event.ev.getSource();
        if (source instanceof Window) {
            eventWin = (Window) source;
        }
        switch(event.type) {
            case Jake2InputEvent.KeyPress:
            case Jake2InputEvent.KeyRelease:
                Do_Key_Event(XLateKeyCode((KeyEvent) event.ev), event.type == Jake2InputEvent.KeyPress);
                break;
            case Jake2InputEvent.MotionNotify:
                // }
                if (IN.mouse_active) {
                    mx = (((MouseEvent) event.ev).getX() - win_w2) * 2;
                    my = (((MouseEvent) event.ev).getY() - win_h2) * 2;
                } else {
                    mx = 0;
                    my = 0;
                }
                break;
            case Jake2InputEvent.ButtonPress:
                key = mouseEventToKey((MouseEvent) event.ev);
                Do_Key_Event(key, true);
                break;
            case Jake2InputEvent.ButtonRelease:
                key = mouseEventToKey((MouseEvent) event.ev);
                Do_Key_Event(key, false);
                break;
            case Jake2InputEvent.WheelMoved:
                float dir = ((MouseEvent) event.ev).getRotation()[0];
                if (dir > 0) {
                    Do_Key_Event(Key.K_MWHEELDOWN, true);
                    Do_Key_Event(Key.K_MWHEELDOWN, false);
                } else {
                    Do_Key_Event(Key.K_MWHEELUP, true);
                    Do_Key_Event(Key.K_MWHEELUP, false);
                }
                break;
            case Jake2InputEvent.CreateNotify:
            case Jake2InputEvent.ConfigureNotify:
                handleCreateAndConfigureNotify(eventWin);
                break;
        }
    }
    if (mx != 0 || my != 0) {
        // move the mouse to the window center again
        c.warpPointer(c.getWidth() / 2, c.getHeight() / 2);
    }
}
Also used : Window(com.jogamp.newt.Window) KeyEvent(com.jogamp.newt.event.KeyEvent) MouseEvent(com.jogamp.newt.event.MouseEvent)

Example 2 with MouseEvent

use of com.jogamp.newt.event.MouseEvent in project gephi by gephi.

the class GLAbstractListener method initArchitecture.

@Override
public void initArchitecture() {
    this.engine = VizController.getInstance().getEngine();
    this.scheduler = VizController.getInstance().getScheduler();
    this.graphIO = VizController.getInstance().getGraphIO();
    cameraLocation = vizController.getVizConfig().getDefaultCameraPosition();
    cameraTarget = vizController.getVizConfig().getDefaultCameraTarget();
    // Mouse events
    if (vizController.getVizConfig().isReduceFpsWhenMouseOut() || vizController.getVizConfig().isPauseLoopWhenMouseOut()) {
        graphMouseAdapter = new GraphMouseAdapter();
        if (window != null) {
            graphMouseAdapterNewt = new MouseAdapter() {

                @Override
                public void mouseEntered(MouseEvent e) {
                    graphMouseAdapter.mouseEntered();
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    graphMouseAdapter.mouseExited();
                }
            };
            window.addMouseListener(graphMouseAdapterNewt);
        } else {
            graphMouseAdapterCanvas = new java.awt.event.MouseAdapter() {

                @Override
                public void mouseEntered(java.awt.event.MouseEvent e) {
                    graphMouseAdapter.mouseEntered();
                }

                @Override
                public void mouseExited(java.awt.event.MouseEvent e) {
                    graphMouseAdapter.mouseExited();
                }
            };
            graphComponent.addMouseListener(graphMouseAdapterCanvas);
        }
    }
}
Also used : MouseEvent(com.jogamp.newt.event.MouseEvent) MouseAdapter(com.jogamp.newt.event.MouseAdapter)

Aggregations

MouseEvent (com.jogamp.newt.event.MouseEvent)2 Window (com.jogamp.newt.Window)1 KeyEvent (com.jogamp.newt.event.KeyEvent)1 MouseAdapter (com.jogamp.newt.event.MouseAdapter)1