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);
}
}
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);
}
}
}
Aggregations