Example usage for java.awt.event KeyEvent VK_LEFT

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

Introduction

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

Prototype

int VK_LEFT

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

Click Source Link

Document

Constant for the non-numpad left arrow key.

Usage

From source file:CopyAreaPerformance.java

/**
 * Arrow keys scroll the view around. The 'c' key toggles clip area
 * optimization. The 'a' key toggles copyArea optimization.
 *///from   ww  w  . j  a  v  a  2 s . c o m
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
        scroll(SCROLL_SIZE, 0);
    } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
        scroll(-SCROLL_SIZE, 0);
    } else if (e.getKeyCode() == KeyEvent.VK_UP) {
        scroll(0, -SCROLL_SIZE);
    } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
        scroll(0, SCROLL_SIZE);
    } else if (e.getKeyCode() == KeyEvent.VK_C) {
        useClip = !useClip;
        System.out.println("useClip = " + useClip);
    } else if (e.getKeyCode() == KeyEvent.VK_A) {
        useCopyArea = !useCopyArea;
        prevVX = -10000;
        System.out.println("useCopyArea = " + useCopyArea);
    }
}

From source file:com.tradedesksoftware.ets.client.charting.ChartShiftController.java

/**
 * Pan/Shifts a plot if the arrow keys are pressed.
 * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
 *//*from   ww  w  .j a v a  2  s  .co  m*/
public void keyPressed(KeyEvent e) {
    if (!plotSupported)
        return;

    int keyCode = e.getKeyCode();

    // we're only interested in arrows (code 37,38,39,40)
    if ((keyCode < 37) || (keyCode > 40))
        return;

    // The axis we're gonna shift
    ValueAxis axis = null;

    // Delta is the amount we'll shift in axis units.
    double delta;

    boolean domainShift = false; // used for PAN_FIXED
    // Calculations for the domain axis
    if ((keyCode == KeyEvent.VK_LEFT) || (keyCode == KeyEvent.VK_RIGHT)) {
        axis = getPlotAxis(chartPanel.getChart(), !axesSwaped);
        domainShift = true;
    }
    // Calculations for the range axis
    else {
        axis = getPlotAxis(chartPanel.getChart(), axesSwaped);
    }

    // Let's calculate 'delta', the amount by which we'll shift the plot
    switch (shiftType) {
    case SHIFT_PERCENTUAL:
        delta = (axis.getUpperBound() - axis.getLowerBound()) / 100.0;
        break;
    case SHIFT_FIXED:
        delta = (domainShift ? fixedDomainShiftUnits : fixedRangeShiftUnits);
        break;
    case SHIFT_PIXEL: // also the default
    default:
        // Let's find out what's the range for 1 pixel.
        final Rectangle scaledDataArea = chartPanel.getScreenDataArea();
        delta = axis.getRange().getLength() / (scaledDataArea.width);
        break;
    }

    // Shift modifier multiplies delta by 10
    if (e.isShiftDown()) {
        delta *= 10;
    }

    switch (keyCode) {
    case KeyEvent.VK_LEFT:
    case KeyEvent.VK_DOWN:
        axis.setRange(axis.getLowerBound() - delta, axis.getUpperBound() - delta);
        break;
    case KeyEvent.VK_UP:
    case KeyEvent.VK_RIGHT:
        axis.setRange(axis.getLowerBound() + delta, axis.getUpperBound() + delta);
        break;
    }
}

From source file:net.rptools.tokentool.ui.TokenCompositionPanel.java

public void keyReleased(KeyEvent e) {
    switch (e.getKeyCode()) {
    case java.awt.event.KeyEvent.VK_UP:
        tokenOffsetY += -1;//from  w ww  . j  a  v a 2 s .  c o  m
        repaint();
        fireCompositionChanged();
        break;
    case java.awt.event.KeyEvent.VK_DOWN:
        tokenOffsetY += 1;
        repaint();
        fireCompositionChanged();
        break;
    case java.awt.event.KeyEvent.VK_LEFT:
        tokenOffsetX += -1;
        repaint();
        fireCompositionChanged();
        break;
    case java.awt.event.KeyEvent.VK_RIGHT:
        tokenOffsetX += 1;
        repaint();
        fireCompositionChanged();
    }

}

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);/*from w w w.j av  a2 s .co  m*/
        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:Text2DTest.java

/**
 * Process a keyboard event to move or rotate the viewer.
 *//*from  w w  w .j a  va 2s .c om*/
void processManualEvent(AWTEvent[] events) {

    for (int i = 0; i < events.length; ++i) {
        if (events[i] instanceof KeyEvent) {
            KeyEvent event = (KeyEvent) events[i];
            if (event.getKeyCode() == KeyEvent.VK_EQUALS) {
                continue;
            }
            Transform3D t = new Transform3D();
            viewTransformGroup.getTransform(t);
            Vector3f viewDir = new Vector3f(0f, 0f, -1f);
            Vector3f translation = new Vector3f();
            t.get(translation);
            t.transform(viewDir);
            if (event.getKeyCode() == KeyEvent.VK_UP) {
                translation.x += viewDir.x;
                translation.y += viewDir.y;
                translation.z += viewDir.z;
            } else if (event.getKeyCode() == KeyEvent.VK_DOWN) {
                translation.x -= viewDir.x;
                translation.y -= viewDir.y;
                translation.z -= viewDir.z;
            } else if (event.getKeyCode() == KeyEvent.VK_RIGHT) {
                rotation += -.1;
            } else if (event.getKeyCode() == KeyEvent.VK_LEFT) {
                rotation += .1;
            }
            t.rotY(rotation);
            t.setTranslation(translation);
            viewTransformGroup.setTransform(t);
        }
    }
}

From source file:it.unibo.alchemist.boundary.monitors.Generic2DDisplay.java

private void bindKeys() {
    bindKey(KeyEvent.VK_S, () -> {
        if (status == ViewStatus.SELECTING) {
            resetStatus();//from  w  w w  . j  ava 2  s . c  o m
            this.selectedNodes.clear();
        } else if (!isInteracting()) {
            this.status = ViewStatus.SELECTING;
        }
        this.repaint();
    });
    bindKey(KeyEvent.VK_O, () -> {
        if (status == ViewStatus.SELECTING) {
            this.status = ViewStatus.MOVING;
        }
    });
    bindKey(KeyEvent.VK_C, () -> {
        if (status == ViewStatus.SELECTING) {
            this.status = ViewStatus.CLONING;
        }
    });
    bindKey(KeyEvent.VK_E, () -> {
        if (status == ViewStatus.SELECTING) {
            this.status = ViewStatus.MOLECULING;
            final JFrame mol = Generic2DDisplay.makeFrame("Moleculing",
                    new MoleculeInjectorGUI<>(selectedNodes));
            mol.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            mol.addWindowListener(new WindowAdapter() {
                @Override
                public void windowClosed(final WindowEvent e) {
                    selectedNodes.clear();
                    resetStatus();
                }
            });
        }
    });
    bindKey(KeyEvent.VK_D, () -> {
        if (status == ViewStatus.SELECTING) {
            this.status = ViewStatus.DELETING;
            for (final Node<T> n : selectedNodes) {
                currentEnv.removeNode(n);
            }
            final Simulation<T> sim = currentEnv.getSimulation();
            sim.schedule(() -> update(currentEnv, sim.getTime()));
            resetStatus();
        }
    });
    bindKey(KeyEvent.VK_M, () -> setMarkCloserNode(!isCloserNodeMarked()));
    bindKey(KeyEvent.VK_L, () -> setDrawLinks(!paintLinks));
    bindKey(KeyEvent.VK_P, () -> Optional.ofNullable(currentEnv.getSimulation()).ifPresent(sim -> {
        if (sim.getStatus() == Status.RUNNING) {
            sim.pause();
        } else {
            sim.play();
        }
    }));
    bindKey(KeyEvent.VK_R, () -> setRealTime(!isRealTime()));
    bindKey(KeyEvent.VK_LEFT, () -> setStep(Math.max(1, st - Math.max(st / 10, 1))));
    bindKey(KeyEvent.VK_RIGHT, () -> setStep(Math.max(st, st + Math.max(st / 10, 1))));
}

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 a v a2 s  .  co m
        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:Console.java

public void keyPressed(KeyEvent e) {
    int code = e.getKeyCode();
    if (code == KeyEvent.VK_BACK_SPACE || code == KeyEvent.VK_LEFT) {
        if (outputMark == getCaretPosition()) {
            e.consume();/*from w w w  .  j a va 2s .  co  m*/
        }
    } else if (code == KeyEvent.VK_HOME) {
        int caretPos = getCaretPosition();
        if (caretPos == outputMark) {
            e.consume();
        } else if (caretPos > outputMark) {
            if (!e.isControlDown()) {
                if (e.isShiftDown()) {
                    moveCaretPosition(outputMark);
                } else {
                    setCaretPosition(outputMark);
                }
                e.consume();
            }
        }
    } else if (code == KeyEvent.VK_ENTER) {
        returnPressed();
        e.consume();
    } else if (code == KeyEvent.VK_UP) {
        historyIndex--;
        if (historyIndex >= 0) {
            if (historyIndex >= history.size()) {
                historyIndex = history.size() - 1;
            }
            if (historyIndex >= 0) {
                String str = history.elementAt(historyIndex);
                int len = getDocument().getLength();
                replaceRange(str, outputMark, len);
                int caretPos = outputMark + str.length();
                select(caretPos, caretPos);
            } else {
                historyIndex++;
            }
        } else {
            historyIndex++;
        }
        e.consume();
    } else if (code == KeyEvent.VK_DOWN) {
        int caretPos = outputMark;
        if (history.size() > 0) {
            historyIndex++;
            if (historyIndex < 0) {
                historyIndex = 0;
            }
            int len = getDocument().getLength();
            if (historyIndex < history.size()) {
                String str = history.elementAt(historyIndex);
                replaceRange(str, outputMark, len);
                caretPos = outputMark + str.length();
            } else {
                historyIndex = history.size();
                replaceRange("", outputMark, len);
            }
        }
        select(caretPos, caretPos);
        e.consume();
    }
}

From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java

/**
 * Creates new form MapFrame/* www  .j  a v a 2s.c  o m*/
 */
DSWorkbenchMainFrame() {
    initComponents();
    setAlwaysOnTop(false);
    if (!GlobalOptions.isMinimal()) {
        setTitle("DS Workbench " + Constants.VERSION + Constants.VERSION_ADDITION);
    } else {
        setTitle("DS Workbench Mini " + Constants.VERSION + Constants.VERSION_ADDITION);
    }

    jExportDialog.pack();
    jAddROIDialog.pack();

    JOutlookBar outlookBar = new JOutlookBar();
    outlookBar.addBar("Navigation", jNavigationPanel);
    outlookBar.addBar("Information", jInformationPanel);
    outlookBar.addBar("Karte", jMapPanel);
    outlookBar.addBar("ROI", jROIPanel);
    outlookBar.setVisibleBar(1);
    jSettingsScrollPane.setViewportView(outlookBar);

    mAbout = new AboutDialog(this, true);
    mAbout.pack();
    chooser.setDialogTitle("Speichern unter...");
    chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() {

        @Override
        public boolean accept(File f) {
            return (f != null) && (f.isDirectory() || f.getName().endsWith(".png"));
        }

        @Override
        public String getDescription() {
            return "PNG Image (*.png)";
        }
    });

    chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() {

        @Override
        public boolean accept(File f) {
            return (f != null) && (f.isDirectory() || f.getName().endsWith(".jpeg"));
        }

        @Override
        public String getDescription() {
            return "JPEG Image (*.jpeg)";
        }
    });

    //Schedule Backup
    new Timer("BackupTimer", true).schedule(new BackupTask(), 60 * 10000, 60 * 10000);

    //give focus to map panel if mouse enters map
    jMapPanelHolder.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent e) {
            jMapPanelHolder.requestFocusInWindow();
        }
    });

    getContentPane().setBackground(Constants.DS_BACK);
    pack();
    capabilityInfoPanel1.addActionListener(MapPanel.getSingleton());

    // <editor-fold defaultstate="collapsed" desc=" Add global KeyListener ">
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {

        @Override
        public void eventDispatched(AWTEvent event) {
            if (event.getID() == KeyEvent.KEY_PRESSED) {
                KeyEvent e = (KeyEvent) event;
                if (DSWorkbenchMainFrame.getSingleton().isActive()) {
                    //move shortcuts
                    if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                        scroll(0.0, 2.0);
                    } else if (e.getKeyCode() == KeyEvent.VK_UP) {
                        scroll(0.0, -2.0);
                    } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
                        scroll(-2.0, 0.0);
                    } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
                        scroll(2.0, 0.0);
                    } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //shot minimap tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_AXE);
                    } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack axe tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_RAM);
                    } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack ram tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SNOB);
                    } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack snob tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SPY);
                    } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack sword tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_LIGHT);
                    } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack light tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_HEAVY);
                    } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack heavy tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SWORD);
                    } else if ((e.getKeyCode() == KeyEvent.VK_S) && e.isControlDown() && !e.isAltDown()) {
                        //search frame shortcut
                        DSWorkbenchSearchFrame.getSingleton()
                                .setVisible(!DSWorkbenchSearchFrame.getSingleton().isVisible());
                    }
                }

                //misc shortcuts
                if ((e.getKeyCode() == KeyEvent.VK_0) && e.isAltDown()) {
                    //no tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_DEFAULT);
                } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //measure tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MEASURE);
                } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //mark tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MARK);
                } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //tag tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_TAG);
                } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SUPPORT);
                } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SELECTION);
                } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_RADAR);
                } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_INGAME);
                } else if ((e.getKeyCode() == KeyEvent.VK_8) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //res ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SEND_RES_INGAME);
                } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //move minimap tool shortcut
                    MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MOVE);
                } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //zoom minimap tool shortcut
                    MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ZOOM);
                } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //shot minimap tool shortcut
                    MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SHOT);
                } else if ((e.getKeyCode() == KeyEvent.VK_T) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //search time shortcut
                    ClockFrame.getSingleton().setVisible(!ClockFrame.getSingleton().isVisible());
                } else if ((e.getKeyCode() == KeyEvent.VK_S) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    planMapshot();
                } else if (e.getKeyCode() == KeyEvent.VK_F2) {
                    DSWorkbenchAttackFrame.getSingleton()
                            .setVisible(!DSWorkbenchAttackFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F3) {
                    DSWorkbenchMarkerFrame.getSingleton()
                            .setVisible(!DSWorkbenchMarkerFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F4) {
                    DSWorkbenchTroopsFrame.getSingleton()
                            .setVisible(!DSWorkbenchTroopsFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F5) {
                    DSWorkbenchRankFrame.getSingleton()
                            .setVisible(!DSWorkbenchRankFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F6) {
                    DSWorkbenchFormFrame.getSingleton()
                            .setVisible(!DSWorkbenchFormFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F7) {
                    if (ServerSettings.getSingleton().isChurch()) {
                        DSWorkbenchChurchFrame.getSingleton()
                                .setVisible(!DSWorkbenchChurchFrame.getSingleton().isVisible());
                    }
                } else if (e.getKeyCode() == KeyEvent.VK_F8) {
                    DSWorkbenchConquersFrame.getSingleton()
                            .setVisible(!DSWorkbenchConquersFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F9) {
                    DSWorkbenchNotepad.getSingleton()
                            .setVisible(!DSWorkbenchNotepad.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F10) {
                    DSWorkbenchTagFrame.getSingleton()
                            .setVisible(!DSWorkbenchTagFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F11) {
                    DSWorkbenchStatsFrame.getSingleton()
                            .setVisible(!DSWorkbenchStatsFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F12) {
                    DSWorkbenchSettingsDialog.getSingleton().setVisible(true);
                } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 1
                    centerROI(0);
                } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 2
                    centerROI(1);
                } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 3
                    centerROI(2);
                } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 4
                    centerROI(3);
                } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 5
                    centerROI(4);
                } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 6
                    centerROI(5);
                } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 7
                    centerROI(6);
                } else if ((e.getKeyCode() == KeyEvent.VK_8) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 8
                    centerROI(7);
                } else if ((e.getKeyCode() == KeyEvent.VK_9) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 9
                    centerROI(8);
                } else if ((e.getKeyCode() == KeyEvent.VK_0) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 10
                    centerROI(9);
                } else if (e.getKeyCode() == KeyEvent.VK_SPACE) {
                    jMapPanelHolder.requestFocusInWindow();
                    MapPanel.getSingleton().setSpaceDown(true);
                } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
                    jMapPanelHolder.requestFocusInWindow();
                    MapPanel.getSingleton().setShiftDown(true);
                }
            } else if (event.getID() == KeyEvent.KEY_RELEASED) {
                KeyEvent e = (KeyEvent) event;
                if (e.getKeyCode() == KeyEvent.VK_SPACE) {
                    MapPanel.getSingleton().setSpaceDown(false);
                } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
                    MapPanel.getSingleton().setShiftDown(false);
                }
            }
        }
    }, AWTEvent.KEY_EVENT_MASK);
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Load UI Icons ">
    try {
        jOnlineLabel.setIcon(new ImageIcon("./graphics/icons/online.png"));
        jEnableClipboardWatchButton.setIcon(new ImageIcon("./graphics/icons/watch_clipboard.png"));
        jCenterIngameButton
                .setIcon(new ImageIcon(DSWorkbenchMainFrame.class.getResource("/res/ui/center_ingame.png")));
        jRefreshButton.setIcon(new ImageIcon("./graphics/icons/refresh.png"));
        jCenterCoordinateIngame.setIcon(new ImageIcon("./graphics/icons/center.png"));
    } catch (Exception e) {
        logger.error("Failed to load status icon(s)", e);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Check for desktop support ">
    if (!Desktop.isDesktopSupported()) {
        jCenterIngameButton.setEnabled(false);
        jCenterCoordinateIngame.setEnabled(false);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Restore last map position ">
    try {
        String x = GlobalOptions.getSelectedProfile().getProperty("last.x");
        String y = GlobalOptions.getSelectedProfile().getProperty("last.y");
        centerPosition(Double.parseDouble(x), Double.parseDouble(y));
    } catch (Exception e) {
        centerPosition(ServerSettings.getSingleton().getMapDimension().getCenterX(),
                ServerSettings.getSingleton().getMapDimension().getCenterY());
    }

    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Restore other settings ">
    jShowMapPopup.setSelected(GlobalOptions.getProperties().getBoolean("show.map.popup"));
    jShowMouseOverInfo.setSelected(GlobalOptions.getProperties().getBoolean("show.mouseover.info"));
    jIncludeSupport.setSelected(GlobalOptions.getProperties().getBoolean("include.support"));
    jHighlightTribeVillages.setSelected(GlobalOptions.getProperties().getBoolean("highlight.tribes.villages"));
    jShowRuler.setSelected(GlobalOptions.getProperties().getBoolean("show.ruler"));
    jDisplayChurch.setSelected(GlobalOptions.getProperties().getBoolean("show.church"));
    jDisplayWatchtower.setSelected(GlobalOptions.getProperties().getBoolean("show.watchtower"));
    jDisplayChurch.setEnabled(ServerSettings.getSingleton().isChurch());
    jDisplayWatchtower.setEnabled(ServerSettings.getSingleton().isWatchtower());
    ServerSettings.getSingleton().addListener(new ServerSettingsListener() {
        @Override
        public void fireServerSettingsChanged() {
            jDisplayChurch.setEnabled(ServerSettings.getSingleton().isChurch());
            jDisplayWatchtower.setEnabled(ServerSettings.getSingleton().isWatchtower());
        }
    });
    int r = GlobalOptions.getProperties().getInt("radar.size");
    int hour = r / 60;
    jHourField.setText(Integer.toString(hour));
    jMinuteField.setText(Integer.toString(r - hour * 60));
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Skin Setup">
    DefaultComboBoxModel gpModel = new DefaultComboBoxModel(GlobalOptions.getAvailableSkins());
    jGraphicPacks.setModel(gpModel);
    String skin = GlobalOptions.getProperty("default.skin");
    if (gpModel.getIndexOf(skin) != -1) {
        jGraphicPacks.setSelectedItem(skin);
    } else {
        jGraphicPacks.setSelectedItem("default");
    }
    //</editor-fold>

    minZoom = GlobalOptions.getProperties().getDouble("map.zoom.min");
    maxZoom = GlobalOptions.getProperties().getDouble("map.zoom.max");
    dZoomInOutFactor = GlobalOptions.getProperties().getDouble("map.zoom.in.out.factor");

    mNotificationHideThread = new NotificationHideThread();
    mNotificationHideThread.start();
    SystrayHelper.installSystrayIcon();
    //update online state
    onlineStateChanged();
    restoreProperties();
}

From source file:com.net2plan.gui.GUINet2Plan.java

private static JPanel showAbout() {
    final JPanel aboutPanel = new JPanel();

    ImageIcon image = new ImageIcon(
            ImageUtils.readImageFromURL(GUINet2Plan.class.getResource("/resources/gui/logo.png")));
    JLabel label = new JLabel("", image, JLabel.CENTER);

    aboutPanel.setLayout(new MigLayout("insets 0 0 0 0", "[grow]", "[grow][grow]"));
    aboutPanel.add(label, "alignx center, aligny bottom, wrap");
    aboutPanel.add(new JLabel(ABOUT_TEXT), "alignx center, aligny top");
    aboutPanel.setFocusable(true);//from w  ww  .  j  a  va 2 s . c  om
    aboutPanel.requestFocusInWindow();

    aboutPanel.addKeyListener(new KeyAdapter() {
        private final int[] sequence = new int[] { KeyEvent.VK_UP, KeyEvent.VK_UP, KeyEvent.VK_DOWN,
                KeyEvent.VK_DOWN, KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT, KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT,
                KeyEvent.VK_A, KeyEvent.VK_B };
        private int currentButton = 0;

        @Override
        public void keyPressed(KeyEvent e) {
            int keyPressed = e.getKeyCode();

            if (keyPressed == sequence[currentButton]) {
                currentButton++;

                if (currentButton == sequence.length) {
                    ErrorHandling.setDebug(true);
                    aboutPanel.removeKeyListener(this);
                }
            } else {
                currentButton = 0;
            }
        }
    });

    return aboutPanel;
}