List of usage examples for java.awt.event KeyEvent consume
public void consume()
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);// w w w . ja v a 2s.com } } 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(); } }