Example usage for java.awt.event KeyEvent getModifiersEx

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

Introduction

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

Prototype

public int getModifiersEx() 

Source Link

Document

Returns the extended modifier mask for this event.

Usage

From source file:org.forester.archaeopteryx.TreePanel.java

final private void keyPressedCalls(final KeyEvent e) {
    if (isOvOn() && (getMousePosition() != null) && (getMousePosition().getLocation() != null)) {
        if (inOvVirtualRectangle(getMousePosition().x, getMousePosition().y)) {
            if (!isInOvRect()) {
                setInOvRect(true);//from  www . j  a  v a2s .co m
            }
        } else if (isInOvRect()) {
            setInOvRect(false);
        }
    }
    if (e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK) {
        if ((e.getKeyCode() == KeyEvent.VK_DELETE) || (e.getKeyCode() == KeyEvent.VK_HOME)
                || (e.getKeyCode() == KeyEvent.VK_F)) {
            getMainPanel().getTreeFontSet().mediumFonts();
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(true);
        } else if ((e.getKeyCode() == KeyEvent.VK_SUBTRACT) || (e.getKeyCode() == KeyEvent.VK_MINUS)) {
            getMainPanel().getTreeFontSet().decreaseFontSize();
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(true);
        } else if (plusPressed(e.getKeyCode())) {
            getMainPanel().getTreeFontSet().increaseFontSize();
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(true);
        }
    } else {
        if ((e.getKeyCode() == KeyEvent.VK_DELETE) || (e.getKeyCode() == KeyEvent.VK_HOME)
                || (e.getKeyCode() == KeyEvent.VK_F)) {
            getControlPanel().showWhole();
        } else if ((e.getKeyCode() == KeyEvent.VK_UP) || (e.getKeyCode() == KeyEvent.VK_DOWN)
                || (e.getKeyCode() == KeyEvent.VK_LEFT) || (e.getKeyCode() == KeyEvent.VK_RIGHT)) {
            if (e.getModifiersEx() == InputEvent.SHIFT_DOWN_MASK) {
                if (e.getKeyCode() == KeyEvent.VK_UP) {
                    getMainPanel().getControlPanel().zoomInY(Constants.WHEEL_ZOOM_IN_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                    getMainPanel().getControlPanel().zoomOutY(Constants.WHEEL_ZOOM_OUT_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
                    getMainPanel().getControlPanel().zoomOutX(Constants.WHEEL_ZOOM_OUT_FACTOR,
                            Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
                    getMainPanel().getControlPanel().zoomInX(Constants.WHEEL_ZOOM_IN_FACTOR,
                            Constants.WHEEL_ZOOM_IN_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                }
            } else {
                final int d = 80;
                int dx = 0;
                int dy = -d;
                if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                    dy = d;
                } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
                    dx = -d;
                    dy = 0;
                } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
                    dx = d;
                    dy = 0;
                }
                final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport()
                        .getViewPosition();
                scroll_position.x = scroll_position.x + dx;
                scroll_position.y = scroll_position.y + dy;
                if (scroll_position.x <= 0) {
                    scroll_position.x = 0;
                } else {
                    final int max_x = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar()
                            .getMaximum()
                            - getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getVisibleAmount();
                    if (scroll_position.x >= max_x) {
                        scroll_position.x = max_x;
                    }
                }
                if (scroll_position.y <= 0) {
                    scroll_position.y = 0;
                } else {
                    final int max_y = getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getMaximum()
                            - getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getVisibleAmount();
                    if (scroll_position.y >= max_y) {
                        scroll_position.y = max_y;
                    }
                }
                repaint();
                getMainPanel().getCurrentScrollPane().getViewport().setViewPosition(scroll_position);
            }
        } else if ((e.getKeyCode() == KeyEvent.VK_SUBTRACT) || (e.getKeyCode() == KeyEvent.VK_MINUS)) {
            getMainPanel().getControlPanel().zoomOutY(Constants.WHEEL_ZOOM_OUT_FACTOR);
            getMainPanel().getControlPanel().zoomOutX(Constants.WHEEL_ZOOM_OUT_FACTOR,
                    Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR);
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
        } else if (plusPressed(e.getKeyCode())) {
            getMainPanel().getControlPanel().zoomInX(Constants.WHEEL_ZOOM_IN_FACTOR,
                    Constants.WHEEL_ZOOM_IN_FACTOR);
            getMainPanel().getControlPanel().zoomInY(Constants.WHEEL_ZOOM_IN_FACTOR);
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
        } else if (e.getKeyCode() == KeyEvent.VK_S) {
            if ((getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED)
                    || (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR)) {
                setStartingAngle((getStartingAngle() % TWO_PI) + ANGLE_ROTATION_UNIT);
                getControlPanel().displayedPhylogenyMightHaveChanged(false);
            }
        } else if (e.getKeyCode() == KeyEvent.VK_A) {
            if ((getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED)
                    || (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR)) {
                setStartingAngle((getStartingAngle() % TWO_PI) - ANGLE_ROTATION_UNIT);
                if (getStartingAngle() < 0) {
                    setStartingAngle(TWO_PI + getStartingAngle());
                }
                getControlPanel().displayedPhylogenyMightHaveChanged(false);
            }
        } else if (e.getKeyCode() == KeyEvent.VK_D) {
            boolean selected = false;
            if (getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.HORIZONTAL) {
                getOptions().setNodeLabelDirection(NODE_LABEL_DIRECTION.RADIAL);
                selected = true;
            } else {
                getOptions().setNodeLabelDirection(NODE_LABEL_DIRECTION.HORIZONTAL);
            }
            if (getMainPanel().getMainFrame() == null) {
                // Must be "E" applet version.
                final ArchaeopteryxE ae = (ArchaeopteryxE) ((MainPanelApplets) getMainPanel()).getApplet();
                if (ae.getlabelDirectionCbmi() != null) {
                    ae.getlabelDirectionCbmi().setSelected(selected);
                }
            } else {
                getMainPanel().getMainFrame().getlabelDirectionCbmi().setSelected(selected);
            }
            repaint();
        } else if (e.getKeyCode() == KeyEvent.VK_X) {
            switchDisplaygetPhylogenyGraphicsType();
            repaint();
        } else if (e.getKeyCode() == KeyEvent.VK_C) {
            cycleColors();
            repaint();
        } else if (getOptions().isShowOverview() && isOvOn() && (e.getKeyCode() == KeyEvent.VK_O)) {
            MainFrame.cycleOverview(getOptions(), this);
            repaint();
        } else if (getOptions().isShowOverview() && isOvOn() && (e.getKeyCode() == KeyEvent.VK_I)) {
            increaseOvSize();
        } else if (getOptions().isShowOverview() && isOvOn() && (e.getKeyCode() == KeyEvent.VK_U)) {
            decreaseOvSize();
        }
        e.consume();
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

private void checkHotKey(java.awt.event.KeyEvent evt) {
    if ((evt.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0) {
        if (evt.getKeyCode() == KeyEvent.VK_1) {
            showSearch(true);/*from   ww w  . j  av  a 2 s .co m*/
        } else if (evt.getKeyCode() == KeyEvent.VK_2) {
            showMetaData(true);
        }
    } else if ((evt.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0) {
        if (evt.getKeyCode() == KeyEvent.VK_S) {
            showSearch(true);
        } else if (evt.getKeyCode() == KeyEvent.VK_M) {
            showMetaData(true);
        }
    }
    if (evt.getKeyCode() == KeyEvent.VK_F5) {
        depositPresenter.refreshFileList();
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

private void treeStructMapKeyPressed(java.awt.event.KeyEvent evt) {
    if ((evt.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            moveItem(false);/*from  w  w  w  .  j a  va 2  s  .co  m*/
        } else if (evt.getKeyCode() == KeyEvent.VK_UP) {
            moveItem(true);
        }
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

private void treeFileSystemKeyTyped(java.awt.event.KeyEvent evt) {
    if ((evt.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0) {
        processFileSystemKey(evt.getKeyChar());
    }//w ww  .j  av a2 s .c om
    stopEditingTree();
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

private void treeEntitiesKeyTyped(java.awt.event.KeyEvent evt) {
    if (evt.getKeyChar() == KeyEvent.VK_DELETE) {
        depositPresenter.deleteEntity();
    } else {//  ww w . ja v a 2s  .  c  om
        if ((evt.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0) {
            if (evt.getKeyChar() == 's') {
                depositPresenter.createAutoStructItem(false);
            } else if (evt.getKeyChar() == 'r') {
                depositPresenter.createAutoStructItem(true);
            }
            processFileSystemKey(evt.getKeyChar());
        }
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

private void treeEntitiesKeyPressed(java.awt.event.KeyEvent evt) {
    if ((evt.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            moveItem(false);/*from  w ww.  j av a2 s  . c  om*/
        } else if (evt.getKeyCode() == KeyEvent.VK_UP) {
            moveItem(true);
        }
    }
}

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;/*from   www .  j av a2 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:org.kontalk.view.View.java

void setHotkeys() {
    final boolean enterSends = Config.getInstance().getBoolean(Config.MAIN_ENTER_SENDS);

    for (KeyListener l : mSendTextArea.getKeyListeners())
        mSendTextArea.removeKeyListener(l);
    mSendTextArea.addKeyListener(new KeyListener() {
        @Override/*from   w ww. ja  v a 2s. com*/
        public void keyPressed(KeyEvent e) {
            if (enterSends && e.getKeyCode() == KeyEvent.VK_ENTER
                    && e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK) {
                e.consume();
                mSendTextArea.append(System.getProperty("line.separator"));
            }
            if (enterSends && e.getKeyCode() == KeyEvent.VK_ENTER && e.getModifiers() == 0) {
                // only ignore
                e.consume();
            }
        }

        @Override
        public void keyReleased(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }
    });

    mSendButton.removeHotkeys();
    HotkeyData sendHotkey = enterSends ? Hotkey.ENTER : Hotkey.CTRL_ENTER;
    mSendButton.addHotkey(sendHotkey, TooltipWay.up);
}

From source file:tufts.vue.RichTextBox.java

private static boolean isFinishEditKeyPress(KeyEvent e) {
    // if we hit return key either on numpad ("enter" key), or
    // with any modifier down except a shift alone (in case of
    // caps lock) complete the edit.
    return e.getKeyCode() == KeyEvent.VK_ENTER && (e.getKeyLocation() == KeyEvent.KEY_LOCATION_NUMPAD
            || (e.getModifiersEx() != 0 && !e.isShiftDown())) == true;
    //== false; // reversed logic of below description
}