Example usage for java.awt.event KeyEvent VK_PAGE_UP

List of usage examples for java.awt.event KeyEvent VK_PAGE_UP

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_PAGE_UP.

Prototype

int VK_PAGE_UP

To view the source code for java.awt.event KeyEvent VK_PAGE_UP.

Click Source Link

Document

Constant for the PAGE_UP virtual key.

Usage

From source file:net.sf.jabref.gui.AutoCompleteListener.java

@Override
public void keyPressed(KeyEvent e) {
    if ((toSetIn != null) && (e.getKeyCode() == KeyEvent.VK_ENTER)) {
        JTextComponent comp = (JTextComponent) e.getSource();

        // replace typed characters by characters from completion
        lastBeginning = lastCompletions[lastShownCompletion];

        int end = comp.getSelectionEnd();
        comp.select(end, end);//from  w w w.  j  a va  2  s  .co m
        toSetIn = null;
        if (consumeEnterKey) {
            e.consume();
        }
    }
    // Cycle through alternative completions when user presses PGUP/PGDN:
    else if ((e.getKeyCode() == KeyEvent.VK_PAGE_DOWN) && (toSetIn != null)) {
        cycle((JTextComponent) e.getSource(), 1);
        e.consume();
    } else if ((e.getKeyCode() == KeyEvent.VK_PAGE_UP) && (toSetIn != null)) {
        cycle((JTextComponent) e.getSource(), -1);
        e.consume();
    }
    //        else if ((e.getKeyCode() == KeyEvent.VK_BACK_SPACE)) {
    //           StringBuffer currentword = getCurrentWord((JTextComponent) e.getSource());
    //           // delete last char to obey semantics of back space
    //           currentword.deleteCharAt(currentword.length()-1);
    //           doCompletion(currentword, e);
    //        }
    else if (e.getKeyChar() == KeyEvent.CHAR_UNDEFINED) {
        if (e.getKeyCode() != KeyEvent.VK_SHIFT) {
            // shift is OK, everyhting else leads to a reset
            resetAutoCompletion();
        } else {
            LOGGER.debug("Special case: shift pressed. No action.");
        }
    } else {
        LOGGER.debug("Special case: defined character, but not caught above");
    }
}

From source file:net.sf.jabref.gui.autocompleter.AutoCompleteListener.java

@Override
public void keyPressed(KeyEvent e) {
    if ((toSetIn != null) && (e.getKeyCode() == KeyEvent.VK_ENTER)) {
        JTextComponent comp = (JTextComponent) e.getSource();

        // replace typed characters by characters from completion
        lastBeginning = lastCompletions.get(lastShownCompletion);

        int end = comp.getSelectionEnd();
        comp.select(end, end);/*w w  w  . j  a va  2s .  c om*/
        toSetIn = null;
        if (consumeEnterKey) {
            e.consume();
        }
    }
    // Cycle through alternative completions when user presses PGUP/PGDN:
    else if ((e.getKeyCode() == KeyEvent.VK_PAGE_DOWN) && (toSetIn != null)) {
        cycle((JTextComponent) e.getSource(), 1);
        e.consume();
    } else if ((e.getKeyCode() == KeyEvent.VK_PAGE_UP) && (toSetIn != null)) {
        cycle((JTextComponent) e.getSource(), -1);
        e.consume();
    }
    //        else if ((e.getKeyCode() == KeyEvent.VK_BACK_SPACE)) {
    //           StringBuffer currentword = getCurrentWord((JTextComponent) e.getSource());
    //           // delete last char to obey semantics of back space
    //           currentword.deleteCharAt(currentword.length()-1);
    //           doCompletion(currentword, e);
    //        }
    else if (e.getKeyChar() == KeyEvent.CHAR_UNDEFINED) {
        if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
            // shift is OK, everything else leads to a reset
            LOGGER.debug("Special case: shift pressed. No action.");
        } else {
            resetAutoCompletion();
        }
    } else {
        LOGGER.debug("Special case: defined character, but not caught above");
    }
}

From source file:com.nbt.TileCanvas.java

protected void keyPressed(KeyEvent e) {
    final int keyCode = e.getKeyCode();
    switch (keyCode) {
    case KeyEvent.VK_UP:
        int z = getTileZ();
        setTileZ(z - 1);// w  ww.j a v  a  2s . c  om
        break;
    case KeyEvent.VK_DOWN:
        z = getTileZ();
        setTileZ(z + 1);
        break;
    case KeyEvent.VK_LEFT:
        int x = getTileX();
        setTileX(x - 1);
        break;
    case KeyEvent.VK_RIGHT:
        x = getTileX();
        setTileX(x + 1);
        break;
    case KeyEvent.VK_PAGE_UP:
        int altitude = getAltitude();
        setAltitude(altitude + 1);
        break;
    case KeyEvent.VK_PAGE_DOWN:
        altitude = getAltitude();
        setAltitude(altitude - 1);
        break;
    }

    updateXYZ();
    doRepaint();
    save();
}

From source file:com.netease.dagger.BrowserEmulator.java

/**
 * Close previous tab in browser//  w w w  . j  a va  2  s.  c  o m
 */
public void closePreviousTAB() {
    pause(stepInterval);
    try {
        Robot robot = new Robot();
        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_PAGE_UP);
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.keyRelease(KeyEvent.VK_PAGE_UP);
        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_W);
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.keyRelease(KeyEvent.VK_W);
    } catch (Exception e) {
        e.printStackTrace();
        handleFailure("Failed to close previous TAB");
    }
    logger.info("Success to close previous TAB");
}

From source file:com.mirth.connect.client.ui.components.rsta.RSTAPreferences.java

private void setDefaultKeyStrokeMap() {
    keyStrokeMap = new HashMap<String, KeyStroke>();

    boolean isOSX = RTextArea.isOSX();
    int defaultModifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    int ctrl = InputEvent.CTRL_MASK;
    int alt = InputEvent.ALT_MASK;
    int shift = InputEvent.SHIFT_MASK;
    int defaultShift = defaultModifier | shift;
    int moveByWordMod = isOSX ? alt : defaultModifier;
    int moveByWordModShift = moveByWordMod | shift;

    putKeyStroke(ActionInfo.UNDO, KeyEvent.VK_Z, defaultModifier);

    if (isOSX) {/*from  w w w  .j av a2 s .  com*/
        putKeyStroke(ActionInfo.REDO, KeyEvent.VK_Z, defaultShift);
    } else {
        putKeyStroke(ActionInfo.REDO, KeyEvent.VK_Y, defaultModifier);
    }

    putKeyStroke(ActionInfo.CUT, KeyEvent.VK_X, defaultModifier);
    putKeyStroke(ActionInfo.COPY, KeyEvent.VK_C, defaultModifier);
    putKeyStroke(ActionInfo.PASTE, KeyEvent.VK_V, defaultModifier);
    putKeyStroke(ActionInfo.DELETE, KeyEvent.VK_DELETE, 0);
    putKeyStroke(ActionInfo.DELETE_REST_OF_LINE, KeyEvent.VK_DELETE, defaultModifier);
    putKeyStroke(ActionInfo.DELETE_LINE, KeyEvent.VK_D, defaultModifier);
    putKeyStroke(ActionInfo.JOIN_LINE, KeyEvent.VK_J, defaultModifier);
    putKeyStroke(ActionInfo.SELECT_ALL, KeyEvent.VK_A, defaultModifier);
    putKeyStroke(ActionInfo.FIND_REPLACE, KeyEvent.VK_F, defaultModifier);
    putKeyStroke(ActionInfo.FIND_NEXT, KeyEvent.VK_G, defaultModifier);
    putKeyStroke(ActionInfo.CLEAR_MARKED_OCCURRENCES, KeyEvent.VK_ESCAPE, 0);
    putKeyStroke(ActionInfo.FOLD_COLLAPSE, KeyEvent.VK_SUBTRACT, defaultModifier);
    putKeyStroke(ActionInfo.FOLD_EXPAND, KeyEvent.VK_ADD, defaultModifier);
    putKeyStroke(ActionInfo.FOLD_COLLAPSE_ALL, KeyEvent.VK_DIVIDE, defaultModifier);
    putKeyStroke(ActionInfo.FOLD_COLLAPSE_ALL_COMMENTS, KeyEvent.VK_DIVIDE, defaultShift);
    putKeyStroke(ActionInfo.FOLD_EXPAND_ALL, KeyEvent.VK_MULTIPLY, defaultModifier);
    putKeyStroke(ActionInfo.GO_TO_MATCHING_BRACKET, KeyEvent.VK_OPEN_BRACKET, defaultModifier);
    putKeyStroke(ActionInfo.TOGGLE_COMMENT, KeyEvent.VK_SLASH, defaultModifier);
    putKeyStroke(ActionInfo.AUTO_COMPLETE, KeyEvent.VK_SPACE, ctrl);

    if (isOSX) {
        putKeyStroke(ActionInfo.DOCUMENT_START, KeyEvent.VK_HOME, 0);
        putKeyStroke(ActionInfo.DOCUMENT_END, KeyEvent.VK_END, 0);
        putKeyStroke(ActionInfo.DOCUMENT_SELECT_START, KeyEvent.VK_HOME, shift);
        putKeyStroke(ActionInfo.DOCUMENT_SELECT_END, KeyEvent.VK_END, shift);
        putKeyStroke(ActionInfo.LINE_START, KeyEvent.VK_LEFT, defaultModifier);
        putKeyStroke(ActionInfo.LINE_END, KeyEvent.VK_RIGHT, defaultModifier);
        putKeyStroke(ActionInfo.LINE_SELECT_START, KeyEvent.VK_LEFT, defaultShift);
        putKeyStroke(ActionInfo.LINE_SELECT_END, KeyEvent.VK_RIGHT, defaultShift);
    } else {
        putKeyStroke(ActionInfo.DOCUMENT_START, KeyEvent.VK_HOME, defaultModifier);
        putKeyStroke(ActionInfo.DOCUMENT_END, KeyEvent.VK_END, defaultModifier);
        putKeyStroke(ActionInfo.DOCUMENT_SELECT_START, KeyEvent.VK_HOME, defaultShift);
        putKeyStroke(ActionInfo.DOCUMENT_SELECT_END, KeyEvent.VK_END, defaultShift);
        putKeyStroke(ActionInfo.LINE_START, KeyEvent.VK_HOME, 0);
        putKeyStroke(ActionInfo.LINE_END, KeyEvent.VK_END, 0);
        putKeyStroke(ActionInfo.LINE_SELECT_START, KeyEvent.VK_HOME, shift);
        putKeyStroke(ActionInfo.LINE_SELECT_END, KeyEvent.VK_END, shift);
    }

    putKeyStroke(ActionInfo.MOVE_LEFT, KeyEvent.VK_LEFT, 0);
    putKeyStroke(ActionInfo.MOVE_LEFT_SELECT, KeyEvent.VK_LEFT, shift);
    putKeyStroke(ActionInfo.MOVE_LEFT_WORD, KeyEvent.VK_LEFT, moveByWordMod);
    putKeyStroke(ActionInfo.MOVE_LEFT_WORD_SELECT, KeyEvent.VK_LEFT, moveByWordModShift);
    putKeyStroke(ActionInfo.MOVE_RIGHT, KeyEvent.VK_RIGHT, 0);
    putKeyStroke(ActionInfo.MOVE_RIGHT_SELECT, KeyEvent.VK_RIGHT, shift);
    putKeyStroke(ActionInfo.MOVE_RIGHT_WORD, KeyEvent.VK_RIGHT, moveByWordMod);
    putKeyStroke(ActionInfo.MOVE_RIGHT_WORD_SELECT, KeyEvent.VK_RIGHT, moveByWordModShift);
    putKeyStroke(ActionInfo.MOVE_UP, KeyEvent.VK_UP, 0);
    putKeyStroke(ActionInfo.MOVE_UP_SELECT, KeyEvent.VK_UP, shift);
    putKeyStroke(ActionInfo.MOVE_UP_SCROLL, KeyEvent.VK_UP, defaultModifier);
    putKeyStroke(ActionInfo.MOVE_UP_LINE, KeyEvent.VK_UP, alt);
    putKeyStroke(ActionInfo.MOVE_DOWN, KeyEvent.VK_DOWN, 0);
    putKeyStroke(ActionInfo.MOVE_DOWN_SELECT, KeyEvent.VK_DOWN, shift);
    putKeyStroke(ActionInfo.MOVE_DOWN_SCROLL, KeyEvent.VK_DOWN, defaultModifier);
    putKeyStroke(ActionInfo.MOVE_DOWN_LINE, KeyEvent.VK_DOWN, alt);
    putKeyStroke(ActionInfo.PAGE_UP, KeyEvent.VK_PAGE_UP, 0);
    putKeyStroke(ActionInfo.PAGE_UP_SELECT, KeyEvent.VK_PAGE_UP, shift);
    putKeyStroke(ActionInfo.PAGE_LEFT_SELECT, KeyEvent.VK_PAGE_UP, defaultShift);
    putKeyStroke(ActionInfo.PAGE_DOWN, KeyEvent.VK_PAGE_DOWN, 0);
    putKeyStroke(ActionInfo.PAGE_DOWN_SELECT, KeyEvent.VK_PAGE_DOWN, shift);
    putKeyStroke(ActionInfo.PAGE_RIGHT_SELECT, KeyEvent.VK_PAGE_DOWN, defaultShift);
    putKeyStroke(ActionInfo.INSERT_LF_BREAK, KeyEvent.VK_ENTER, 0);
    putKeyStroke(ActionInfo.INSERT_CR_BREAK, KeyEvent.VK_ENTER, shift);
    putKeyStroke(ActionInfo.MACRO_BEGIN, KeyEvent.VK_B, defaultShift);
    putKeyStroke(ActionInfo.MACRO_END, KeyEvent.VK_N, defaultShift);
    putKeyStroke(ActionInfo.MACRO_PLAYBACK, KeyEvent.VK_M, defaultShift);
}

From source file:org.slage.tests.ImageTest.java

/** Hard-code a pause key click */
public void makePauseHandler() {
    addKeyHandler(new PauseHandler(this), KeyEvent.VK_F10);
    addKeyHandler(new QuitHandler(), KeyEvent.VK_Q, false, true, false);

    // toggle debug mode (bounding shapes, etc)
    addKeyHandler(new ToggleDebugHandler(this), KeyEvent.VK_TAB);

    // cycle toolbar rendering
    addKeyHandler(new CycleRenderHandler(this), KeyEvent.VK_EQUALS);

    addKeyHandler(new FocusConsoleHandler(this), KeyEvent.VK_ENTER);

    // manual scrolling
    addKeyHandler(new ScrollHandler(this, 5, 0), KeyEvent.VK_PAGE_UP);
    addKeyHandler(new ScrollHandler(this, -5, 0), KeyEvent.VK_PAGE_DOWN);

    // toggle scroll lock
    addKeyHandler(new LockViewportHandler(this, tryTheSpecial), java.awt.event.KeyEvent.VK_HOME);
    addKeyHandler(new LockViewportHandler(this), java.awt.event.KeyEvent.VK_END);

    addKeyHandler(new PrintHistory(this), java.awt.event.KeyEvent.VK_F1);

    // open imagetest in the editor
    addKeyHandler(new LaunchEditorHandler(this), java.awt.event.KeyEvent.VK_SCROLL_LOCK);

    // play a sound when space is pressed
    addKeyHandler(/*from   w  w  w.  j av a 2s .co  m*/
            new PlaySoundHandler(this, Tools.GetFile("org.slage.tests.content", "congratulations-escaped.ogg")),
            java.awt.event.KeyEvent.VK_SPACE);

    // save the game
    addKeyHandler(new SaveWithChooserDialog(this), java.awt.event.KeyEvent.VK_F5);

    // inventory dialog, we hope
    addKeyHandler(new ShowInventoryHandler(getPlayer()), java.awt.event.KeyEvent.VK_F4);
    addKeyHandler(new CloseInventoryHandler(getPlayer()), java.awt.event.KeyEvent.VK_ESCAPE);

}

From source file:statechum.analysis.learning.Visualiser.java

protected void setVisualiserKeyBindings() {
    persistAction = new graphAction("saveLayout", "save the layout of the visible graph") {

        /** Serial number. */
        private static final long serialVersionUID = 1L;

        @Override//  w  w  w  .j  av  a 2 s .  co  m
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            XMLEncoder encoder = null;
            try {
                if (propName >= 0) {
                    String fileName = getLayoutFileName(graphs.get(currentGraph));
                    encoder = new XMLEncoder(new FileOutputStream(fileName));
                    Map<Integer, DoublePair> layout = ((XMLPersistingLayout) viewer.getModel().getGraphLayout())
                            .persist();
                    encoder.writeObject(layout);
                    XMLAffineTransformSerialised trV = new XMLAffineTransformSerialised();
                    trV.setFromAffineTransform(viewer.getViewTransformer().getTransform());
                    encoder.writeObject(trV);
                    XMLAffineTransformSerialised trL = new XMLAffineTransformSerialised();
                    trL.setFromAffineTransform(viewer.getLayoutTransformer().getTransform());
                    encoder.writeObject(trL);
                    ((XMLModalGraphMouse) viewer.getGraphMouse()).store(encoder);
                    encoder.writeObject(layoutOptions.get(currentGraph));
                    encoder.close();
                    encoder = null;
                }
            } catch (Exception e1) {
                e1.printStackTrace();
            } finally {
                if (encoder != null) {
                    encoder.close();
                    encoder = null;
                }
            }
        }
    };
    keyToActionMap.put(KeyEvent.VK_F2, persistAction);
    keyToActionMap.put(KeyEvent.VK_F3,
            new graphAction("loadLayout", "loads the previously saved layout into the visible graph") {

                /** Serial number. */
                private static final long serialVersionUID = 2L;

                @Override
                public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
                    reloadLayout(false, true);
                }
            });
    keyToActionMap.put(KeyEvent.VK_F9,
            new graphAction("loadPreviousLayout", "loads the layout of the previous graph in the list") {

                /** Serial number. */
                private static final long serialVersionUID = 3L;

                @Override
                public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
                    if (currentGraph > 0) {
                        restoreLayout(false, currentGraph - 1);
                    }
                }
            });

    pickAction = new graphAction("pick", "Switches Jung into picking mode") {

        /** Serial number. */
        private static final long serialVersionUID = 7L;

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            ((XMLModalGraphMouse) viewer.getGraphMouse()).setMode(ModalGraphMouse.Mode.PICKING);
        }
    };
    keyToActionMap.put(KeyEvent.VK_F11, pickAction);

    transformAction = new graphAction("transform", "Switches Jung into transformation mode") {

        /** Serial number. */
        private static final long serialVersionUID = 8L;

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            ((XMLModalGraphMouse) viewer.getGraphMouse()).setMode(ModalGraphMouse.Mode.TRANSFORMING);
        }
    };
    keyToActionMap.put(KeyEvent.VK_F12, transformAction);

    keyToActionMap.put(KeyEvent.VK_UP, new graphAction("previous", "loads the previous graph") {

        /** Serial number. */
        private static final long serialVersionUID = 9L;

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            if (currentGraph > 0) {
                --currentGraph;
                reloadLayout(false, true);
            }
        }
    });
    keyToActionMap.put(KeyEvent.VK_DOWN, new graphAction("next", "loads the next graph") {

        /** Serial number. */
        private static final long serialVersionUID = 10L;

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            if (currentGraph < graphs.size() - 1) {
                ++currentGraph;
                reloadLayout(false, true);
            }
        }
    });

    keyToActionMap.put(KeyEvent.VK_F, new graphAction("negatives", "toggles negatives on or off") {

        /** Serial number. */
        private static final long serialVersionUID = 11L;

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            LayoutOptions options = layoutOptions.get(currentGraph);
            if (options != null) {
                options.showNegatives = !options.showNegatives;
                reloadLayout(false, false);
            }
        }
    });
    keyToActionMap.put(KeyEvent.VK_I, new graphAction("ignored states", "toggles ignored states on or off") {

        /** Serial number. */
        private static final long serialVersionUID = 12L;

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            LayoutOptions options = layoutOptions.get(currentGraph);
            if (options != null) {
                options.showIgnored = !options.showIgnored;
                reloadLayout(false, false);
            }
        }
    });
    keyToActionMap.put(KeyEvent.VK_PAGE_DOWN, new graphAction("refine", "reduces the abstraction level") {

        /** Serial number. */
        private static final long serialVersionUID = 13L;

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            LayoutOptions options = layoutOptions.get(currentGraph);
            if (options != null && options.componentsToPick < Integer.MAX_VALUE) {
                options.componentsToPick++;
                reloadLayout(false, false);
            }
        }
    });
    keyToActionMap.put(KeyEvent.VK_PAGE_UP, new graphAction("abstract", "increases abstraction level") {

        /** Serial number. */
        private static final long serialVersionUID = 14L;

        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
            LayoutOptions options = layoutOptions.get(currentGraph);
            if (options != null && options.componentsToPick != Integer.MAX_VALUE
                    && options.componentsToPick > 0) {
                --options.componentsToPick;
                reloadLayout(false, false);
            }
        }
    });
}

From source file:org.deegree.tools.rendering.InteractiveWPVS.java

@Override
public void keyPressed(KeyEvent ev) {

    int k = ev.getKeyCode();

    float scale = 1.01f;
    if ((ev.getModifiersEx()
            & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == InputEvent.SHIFT_DOWN_MASK) {
        // SHIFT (and not CTRL)
        scale = 1.10f;/*w w w .ja v a  2 s. co  m*/
    } else if ((ev.getModifiersEx()
            & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == InputEvent.CTRL_DOWN_MASK) {
        // CTRL (and not SHIFT)
        scale /= 1.001;
    }

    switch (k) {
    case KeyEvent.VK_U: {
        this.updateLODStructure = !updateLODStructure;
        break;
    }
    case KeyEvent.VK_F11: {
        lodAnalyzerFrame.setVisible(!lodAnalyzerFrame.isVisible());
        this.setEnabled(true);
        break;
    }
    case KeyEvent.VK_T: {
        if (this.availableDatasets.contains("trees")) {
            renderTrees = !renderTrees;
            if (renderTrees) {
                this.currentDatasets.add(currentDatasets.size() - 1, "trees");
            } else {
                this.currentDatasets.remove("trees");
            }
        }
        break;
    }
    case KeyEvent.VK_C: {
        if (!this.availableColorMaps.isEmpty()) {
            this.currentColormap++;
            if (this.currentColormap >= this.availableColorMaps.size()) {
                this.currentColormap = -1;
            }
            if (this.currentColormap >= 0) {
                String title = this.availableColorMaps.get(currentColormap);
                List<String> cm = new ArrayList<String>(1);
                cm.add(title);
                this.activeColormap = new Pair<String, Colormap>(title,
                        this.perspectiveViewService.getColormap(cm, null));
                this.currentDatasets.add(title);
            } else {
                if (this.activeColormap != null) {
                    this.currentDatasets.remove(this.activeColormap.first);
                }
                this.activeColormap = null;
            }

        }
        break;
    }
    case KeyEvent.VK_B: {
        if (this.availableDatasets.contains("buildings")) {
            renderBuildings = !renderBuildings;
            renderTrees = !renderTrees;
            if (renderBuildings) {
                this.currentDatasets.add(currentDatasets.size() - 1, "buildings");
            } else {
                this.currentDatasets.remove("buildings");
            }
        }
        break;
    }
    case KeyEvent.VK_G: {
        getImage = true;
        break;
    }
    case KeyEvent.VK_1: {
        disableElevationModel = !disableElevationModel;
        if (disableElevationModel) {
            this.currentDatasets.remove("dem");
        } else {
            this.currentDatasets.add("dem");
        }
        break;
    }
    case KeyEvent.VK_2: {
        if (activeTextureManagers.length >= 1) {
            activeTextureManagers[0] = !activeTextureManagers[0];
            if (activeTextureManagers[0]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 1), this.availableDatasets.get(1));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(1));
            }
        }
        break;
    }
    case KeyEvent.VK_3: {
        if (activeTextureManagers.length >= 2) {
            activeTextureManagers[1] = !activeTextureManagers[1];
            if (activeTextureManagers[1]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 2), this.availableDatasets.get(2));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(2));
            }
        }
        break;
    }
    case KeyEvent.VK_4: {
        if (activeTextureManagers.length >= 3) {
            activeTextureManagers[2] = !activeTextureManagers[2];
            if (activeTextureManagers[2]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 3), this.availableDatasets.get(3));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(3));
            }
        }
        break;
    }
    case KeyEvent.VK_5: {
        if (activeTextureManagers.length >= 4) {
            activeTextureManagers[3] = !activeTextureManagers[3];
            if (activeTextureManagers[3]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 4), this.availableDatasets.get(4));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(4));
            }

        }
        break;
    }
    case KeyEvent.VK_6: {
        if (activeTextureManagers.length >= 5) {
            activeTextureManagers[4] = !activeTextureManagers[4];
            if (activeTextureManagers[4]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 5), this.availableDatasets.get(5));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(5));
            }

        }
        break;
    }
    case KeyEvent.VK_7: {
        if (activeTextureManagers.length >= 6) {
            activeTextureManagers[5] = !activeTextureManagers[5];
            if (activeTextureManagers[5]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 6), this.availableDatasets.get(6));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(6));
            }
        }
        break;
    }
    case KeyEvent.VK_8: {
        if (activeTextureManagers.length >= 7) {
            activeTextureManagers[6] = !activeTextureManagers[6];
            if (activeTextureManagers[6]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 7), this.availableDatasets.get(7));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(7));
            }

        }
        break;
    }
    case KeyEvent.VK_9: {
        if (activeTextureManagers.length >= 8) {
            activeTextureManagers[7] = !activeTextureManagers[7];
            if (activeTextureManagers[7]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 8), this.availableDatasets.get(8));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(8));
            }

        }
        break;
    }
    case KeyEvent.VK_PAGE_DOWN: {
        glRenderContext.setTerrainScale(glRenderContext.getTerrainScale() / scale);
        break;
    }
    case KeyEvent.VK_PAGE_UP: {
        glRenderContext.setTerrainScale(glRenderContext.getTerrainScale() * scale);
        break;
    }
    }
}

From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java

private void formKeyPressed(KeyEvent evt) {
    if (lockView) {
        return;//from   www  .ja v a2 s  . co m
    }

    double dAngle = Math.PI / 144;
    double dScale = 129. / 128.;
    if (storingFrames) {
        dAngle = Math.PI / 360;
        dScale = 513. / 512.;
    }
    if ((evt.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
        dAngle = Math.PI / 2;
    }
    if ((evt.getModifiers() & KeyEvent.SHIFT_MASK) != 0) {
        dAngle = Math.PI / 6;
    }
    objRotate.getTransform(tempTransform);
    Transform3D rot = new Transform3D();
    switch (evt.getKeyCode()) {
    case KeyEvent.VK_NUMPAD5:
        reset();
        break;
    case KeyEvent.VK_DOWN:
    case KeyEvent.VK_KP_DOWN:
    case KeyEvent.VK_NUMPAD2:
        rot.rotX(dAngle);
        break;
    case KeyEvent.VK_UP:
    case KeyEvent.VK_KP_UP:
    case KeyEvent.VK_NUMPAD8:
        rot.rotX(-dAngle);
        break;
    case KeyEvent.VK_LEFT:
    case KeyEvent.VK_KP_LEFT:
    case KeyEvent.VK_NUMPAD4:
        rot.rotY(-dAngle);
        break;
    case KeyEvent.VK_RIGHT:
    case KeyEvent.VK_KP_RIGHT:
    case KeyEvent.VK_NUMPAD6:
        rot.rotY(dAngle);
        break;
    case KeyEvent.VK_PAGE_UP:
    case KeyEvent.VK_NUMPAD9:
        rot.rotZ(dAngle);
        break;
    case KeyEvent.VK_PAGE_DOWN:
    case KeyEvent.VK_NUMPAD3:
        rot.rotZ(-dAngle);
        break;
    }
    rot.mul(tempTransform);
    objRotate.setTransform(rot);

    switch (evt.getKeyCode()) {
    case KeyEvent.VK_HOME:
    case KeyEvent.VK_NUMPAD7:
        mouseScale *= dScale;
        break;
    case KeyEvent.VK_END:
    case KeyEvent.VK_NUMPAD1:
        mouseScale /= dScale;
        break;
    }
    tempTransform = new Transform3D(new Matrix3d(1., 0., 0., 0., 1., 0., 0., 0., 1.),
            //sceneCenter,
            new Vector3d(0.0, 0.0, 0.0), externScale * mouseScale);
    objScale.setTransform(tempTransform);
    switch (evt.getKeyCode()) {

    case CAMERA_UP_KEY:
        cameraUpKeyPressed = true;
        processCameraKeys(evt);
        break;
    case CAMERA_DOWN_KEY:
        cameraDownKeyPressed = true;
        processCameraKeys(evt);
        break;
    case CAMERA_LEFT_KEY:
        cameraLeftKeyPressed = true;
        processCameraKeys(evt);
        break;
    case CAMERA_RIGHT_KEY:
        cameraRightKeyPressed = true;
        processCameraKeys(evt);
        break;
    case CAMERA_FORWARD_KEY:
        cameraForwardKeyPressed = true;
        processCameraKeys(evt);
        break;
    case CAMERA_BACKWARD_KEY:
        cameraBackwardKeyPressed = true;
        processCameraKeys(evt);
        break;

    // TODO milimetr: delete the code below after testing
    case '8':
        pickObject.setPickModuleMode(1);
        break;
    case '9':
        pickObject.setPickModuleMode(2);
        break;
    case '0':
        pickObject.setPickModuleMode(3);
        break;

    default:
        break;
    }
}

From source file:com.floreantpos.jasperreport.swing.JRViewerPanel.java

protected void keyNavigate(KeyEvent evt) {
    boolean refresh = true;
    switch (evt.getKeyCode()) {
    case KeyEvent.VK_DOWN:
    case KeyEvent.VK_PAGE_DOWN:
        dnNavigate(evt);//from ww  w . j  a  va  2 s . com
        break;
    case KeyEvent.VK_UP:
    case KeyEvent.VK_PAGE_UP:
        upNavigate(evt);
        break;
    case KeyEvent.VK_HOME:
        homeEndNavigate(0);
        break;
    case KeyEvent.VK_END:
        homeEndNavigate(viewerContext.getPageCount() - 1);
        break;
    default:
        refresh = false;
    }

    if (refresh) {
        viewerContext.refreshPage();
    }
}