本文整理汇总了Java中com.jogamp.newt.event.KeyEvent类的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent类的具体用法?Java KeyEvent怎么用?Java KeyEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyEvent类属于com.jogamp.newt.event包,在下文中一共展示了KeyEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpShortcuts
import com.jogamp.newt.event.KeyEvent; //导入依赖的package包/类
/**
* Set up the keyboard-shortcuts.
*/
private void setUpShortcuts(TileBasedMapViewer viewer) {
/* Use <Esc> and <Q> as shortcuts to stop and exit */
viewer.addKeyCommand(KeyEvent.EVENT_KEY_PRESSED, KeyEvent.VK_ESCAPE, (e) -> shutdown());
viewer.addKeyCommand(KeyEvent.EVENT_KEY_PRESSED, KeyEvent.VK_Q, (e) -> shutdown());
/* Use <C> and as shortcut to reset the view */
viewer.addKeyCommand(KeyEvent.EVENT_KEY_PRESSED, KeyEvent.VK_C, (e) -> viewer.resetView());
/* Use <W> and <Ctrl-S> as shortcuts to save the current map to a binary file */
viewer.addKeyCommand(KeyEvent.EVENT_KEY_PRESSED, KeyEvent.VK_W, (e) -> store());
viewer.addKeyCommand(KeyEvent.EVENT_KEY_PRESSED, KeyEvent.VK_S, (e) -> {
if (e.isControlDown()) {
store();
}
});
/* Use <E> and <Ctrl-O> as shortcuts to load binary or osm (xml) file */
viewer.addKeyCommand(KeyEvent.EVENT_KEY_PRESSED, KeyEvent.VK_E, (e) -> load());
viewer.addKeyCommand(KeyEvent.EVENT_KEY_PRESSED, KeyEvent.VK_O, (e) -> {
if (e.isControlDown()) {
load();
}
});
}
示例2: resolve
import com.jogamp.newt.event.KeyEvent; //导入依赖的package包/类
/**
* Resolves the given event by distributing it to the overlays and the top-level controller. The
* distribution-process stops as soon as any overlay fully consumes the event (i.e. the callback of this event
* returns {@code true}) and thus blocks subsequent overlays from receiving this event.
*
* @param e the event to resolveKeyEvent.
* @param fn the function to be executed for each overlay.
* @param toplevel the top-level receiver of the event.
*/
private void resolve(KeyEvent e, KeyListenerFunction fn, Consumer<KeyEvent> toplevel) {
ArrayList<KeyListener> listeners = getAllOverlays().stream()
.filter(Overlay::isEnabled)
.map(Overlay::getKeyListener)
.filter(Objects::nonNull)
.collect(Collectors.toCollection(ArrayList::new));
for (int i = listeners.size() - 1; i >= 0; i--) {
fn.call(listeners.get(i), e);
if (e.isConsumed())
return;
}
toplevel.accept(e);
}
示例3: createVisualization
import com.jogamp.newt.event.KeyEvent; //导入依赖的package包/类
@Override
public void createVisualization() {
/* set up layer and tile provider */
layerProvider = createLayerProvider(style.getLayers());
TileProvider provider = new PreRenderedTileProvider(layerProvider);
/* create a new visualization object */
visualization = new TileBasedVisualization(
getInitialWindowWidth(),
getInitialWindowHeight(),
provider,
numTileWorkers);
/* apply the style (background color) */
visualization.apply(style);
/* add some key commands */
visualization.getKeyController().addKeyCommand(
KeyEvent.EVENT_KEY_PRESSED,
KeyEvent.VK_F12,
e -> Utils.asyncScreenshot(visualization.getRenderContext()));
/* set an exception handler, catching all unhandled exceptions on the render thread (for debugging purposes) */
visualization.getRenderContext().setUncaughtExceptionHandler(new Utils.DebugExceptionHandler());
}
示例4: keyPressed
import com.jogamp.newt.event.KeyEvent; //导入依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
int code = e.getKeyCode();
if (code == KeyEvent.VK_BACK_SPACE || code == KeyEvent.VK_DELETE) {
if (activeIndex >= 0) {
annotateables.remove(activeIndex);
}
activeIndex = annotateables.size() - 1;
Displayer.display();
} else if (code == KeyEvent.VK_N && activeIndex >= 0) {
activeIndex++;
activeIndex %= annotateables.size();
Displayer.display();
}
}
示例5: keyReleased
import com.jogamp.newt.event.KeyEvent; //导入依赖的package包/类
@Override
public void keyReleased(KeyEvent e) {
int code = e.getKeyCode();
switch (code) {
case 0xd:
code = java.awt.event.KeyEvent.VK_ENTER;
break;
case 0x95:
code = java.awt.event.KeyEvent.VK_LEFT;
break;
case 0x97:
code = java.awt.event.KeyEvent.VK_RIGHT;
break;
default:
break;
}
KeyStroke keyStroke = KeyStroke.getKeyStroke(code, e.getModifiers());
if (KeyShortcuts.handleKeyStroke(keyStroke, e.getSource(), java.awt.event.KeyEvent.KEY_PRESSED))
return;
ImageViewerGui.getCurrentInteraction().keyReleased(e);
for (KeyListener listener : keyListeners)
listener.keyReleased(e);
}
示例6: keyReleased
import com.jogamp.newt.event.KeyEvent; //导入依赖的package包/类
@Override
public void keyReleased(final KeyEvent e) {
if( !e.isPrintableKey() || e.isAutoRepeat() ) {
return;
}
if(userInput) {
final short k = e.getKeySymbol();
if( KeyEvent.VK_ENTER == k ) {
userInput = false;
setIgnoreInput(false);
} else if( KeyEvent.VK_BACK_SPACE == k && userString.length()>0) {
userString.deleteCharAt(userString.length()-1);
} else {
final char c = e.getKeyChar();
if( font.isPrintableChar( c ) ) {
userString.append(c);
}
}
}
}
示例7: keyPressed
import com.jogamp.newt.event.KeyEvent; //导入依赖的package包/类
public void keyPressed(KeyEvent event) {
// fake mouse moved event to hide current mouse overs
fakeMouseMovedEvent();
//
lockEvents();
GUIKeyboardEvent guiKeyboardEvent = keyboardEventsPool.allocate();
guiKeyboardEvent.setTime(System.currentTimeMillis());
guiKeyboardEvent.setType(GUIKeyboardEvent.Type.KEY_PRESSED);
guiKeyboardEvent.setKeyCode(event.getKeyCode());
guiKeyboardEvent.setKeyChar(event.getKeyChar());
guiKeyboardEvent.setMetaDown(event.isMetaDown());
guiKeyboardEvent.setControlDown(event.isControlDown());
guiKeyboardEvent.setAltDown(event.isAltDown());
guiKeyboardEvent.setShiftDown(event.isShiftDown());
guiKeyboardEvent.setProcessed(false);
keyboardEvents.add(guiKeyboardEvent);
unlockEvents();
}
示例8: keyReleased
import com.jogamp.newt.event.KeyEvent; //导入依赖的package包/类
public void keyReleased(KeyEvent event) {
// fake mouse moved event to hide current mouse overs
fakeMouseMovedEvent();
//
lockEvents();
GUIKeyboardEvent guiKeyboardEvent = keyboardEventsPool.allocate();
guiKeyboardEvent.setTime(System.currentTimeMillis());
guiKeyboardEvent.setType(GUIKeyboardEvent.Type.KEY_RELEASED);
guiKeyboardEvent.setKeyCode(event.getKeyCode());
guiKeyboardEvent.setKeyChar(event.getKeyChar());
guiKeyboardEvent.setMetaDown(event.isMetaDown());
guiKeyboardEvent.setControlDown(event.isControlDown());
guiKeyboardEvent.setAltDown(event.isAltDown());
guiKeyboardEvent.setShiftDown(event.isShiftDown());
guiKeyboardEvent.setProcessed(false);
keyboardEvents.add(guiKeyboardEvent);
unlockEvents();
}
示例9: keyPressed
import com.jogamp.newt.event.KeyEvent; //导入依赖的package包/类
@Override
public void keyPressed(KeyEvent ke) {
float step = 0.05f;
switch(ke.getKeyCode()){
case KeyEvent.VK_A:
float ambientIntensity = Tutorial17.instance.getDirectionalLight().getAmbientIntensity();
ambientIntensity += step;
Tutorial17.instance.getDirectionalLight().setAmbientIntensity(ambientIntensity);
break;
case KeyEvent.VK_S:
ambientIntensity = Tutorial17.instance.getDirectionalLight().getAmbientIntensity();
ambientIntensity -= step;
Tutorial17.instance.getDirectionalLight().setAmbientIntensity(ambientIntensity);
break;
}
}
示例10: keyReleased
import com.jogamp.newt.event.KeyEvent; //导入依赖的package包/类
public void keyReleased(KeyEvent e) {
System.out.println("hmd.getHSWDisplayState().Displayed=" + hmd.getHSWDisplayState().Displayed);
if (!hswDone && hmd.getHSWDisplayState().Displayed == 1) {
hmd.dismissHSWDisplay();
hswDone = true;
}
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
shutdown();
}
if (e.getKeyCode() == KeyEvent.VK_F5) {
// new Thread() {
// public void run() {
// glWindow.setFullscreen(!glWindow.isFullscreen());
// }
// }.start();
}
if (e.getKeyCode() == KeyEvent.VK_R) {
recenterView();
}
}
示例11: convertToNiftyKeyCode
import com.jogamp.newt.event.KeyEvent; //导入依赖的package包/类
public int convertToNiftyKeyCode(int key_code, int location) {
// manually map positioned keys
// Note: currently JOGL does not separate between left and right keys here so we map everything to left for now
switch (key_code) {
case KeyEvent.VK_ALT: // fall through
return KeyboardInputEvent.KEY_LMENU;
case KeyEvent.VK_WINDOWS:
case KeyEvent.VK_META:
return KeyboardInputEvent.KEY_LMETA;
case KeyEvent.VK_SHIFT:
return KeyboardInputEvent.KEY_LSHIFT;
case KeyEvent.VK_CONTROL:
return KeyboardInputEvent.KEY_LCONTROL;
default:
return KEY_MAP[key_code];
}
}
示例12: update
import com.jogamp.newt.event.KeyEvent; //导入依赖的package包/类
@Override
public void update(float deltaTime)
{
if(Input.getKey(KeyEvent.VK_RIGHT))
camera.setPosition(camera.getX()+100f*deltaTime, camera.getY());
if(Input.getKey(KeyEvent.VK_LEFT))
camera.setPosition(camera.getX()-100f*deltaTime, camera.getY());
if(Input.getKey(KeyEvent.VK_UP))
camera.setPosition(camera.getX(), camera.getY()+100f*deltaTime);
if(Input.getKey(KeyEvent.VK_DOWN))
camera.setPosition(camera.getX(), camera.getY()-100f*deltaTime);
Vector2I mouseLoc = Input.getMouseLoc();
Vector3 lightLoc = camera.screenToWorldLoc(mouseLoc.x, mouseLoc.y, 0);
pl.setX(lightLoc.x);
pl.setY(lightLoc.y);
}
示例13: update
import com.jogamp.newt.event.KeyEvent; //导入依赖的package包/类
@Override
public void update(float deltaTime)
{
if(Input.getKey(KeyEvent.VK_RIGHT))
sl.incRotation(-180*deltaTime);
if(Input.getKey(KeyEvent.VK_LEFT))
sl.incRotation(180*deltaTime);
if(Input.getKey(KeyEvent.VK_UP))
sl.setSpotAngle(sl.getSpotAngle() + 180*deltaTime);
if(Input.getKey(KeyEvent.VK_DOWN))
sl.setSpotAngle(sl.getSpotAngle() - 180*deltaTime);
Vector2I mouseLoc = Input.getMouseLoc();
Vector3 lightLoc = camera.screenToWorldLoc(mouseLoc.x, mouseLoc.y, 0);
sl.setX(lightLoc.x);
sl.setY(lightLoc.y);
}
示例14: keyPressed
import com.jogamp.newt.event.KeyEvent; //导入依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
synchronized (this.keys) {
if (this.keys.containsKey(keyCode)) {
this.keys.get(keyCode).press();
}
}
// e.consume();
}
示例15: keyReleased
import com.jogamp.newt.event.KeyEvent; //导入依赖的package包/类
@Override
public void keyReleased(KeyEvent e) {
int keyCode = e.getKeyCode();
synchronized (this.keys) {
if (this.keys.containsKey(keyCode)) {
if (keyCode == KeyEvent.VK_SHIFT) {
this.keys.get(keyCode).reset();
} else {
this.keys.get(keyCode).release();
}
}
}
// e.consume();
}