Example usage for java.awt.event KeyEvent VK_RIGHT

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

Introduction

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

Prototype

int VK_RIGHT

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

Click Source Link

Document

Constant for the non-numpad right arrow key.

Usage

From source file:org.jannocessor.ui.RenderPreviewDialog.java

private void initialize() {
    logger.debug("Initializing UI...");
    DefaultSyntaxKit.initKit();//from w  w  w . j  av a  2 s  .  com

    JEditorPane.registerEditorKitForContentType("text/java_template", "org.jannocessor.syntax.JavaTemplateKit",
            getClass().getClassLoader());

    JEditorPane.registerEditorKitForContentType("text/java_output", "org.jannocessor.syntax.JavaOutputKit",
            getClass().getClassLoader());

    setTitle("JAnnocessor - Java Annotation Processor");
    setLayout(new BorderLayout(5, 5));

    listFiles();

    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();
    double width = screenSize.getWidth() * 0.9;
    double height = screenSize.getHeight() * 0.8;

    // Font font = new Font("Courier New", Font.PLAIN, 14);

    input = createInput();
    JScrollPane scroll1 = new JScrollPane(input, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    input.setContentType("text/java_template");

    input.setText("");

    scroll1.setMinimumSize(new Dimension(200, 200));
    scroll1.setPreferredSize(new Dimension((int) (width * 0.5), (int) height));
    add(scroll1, BorderLayout.CENTER);

    output = Box.createVerticalBox();

    scroll2 = new JScrollPane(output, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll2.setMinimumSize(new Dimension(200, 200));
    scroll2.setPreferredSize(new Dimension((int) (width * 0.5), (int) height));
    add(scroll2, BorderLayout.EAST);

    combo = createCombo();

    combo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            load((File) combo.getSelectedItem());
        }
    });

    add(combo, BorderLayout.NORTH);
    JLabel help = new JLabel(
            " Choose a template from the drop-down box to edit it. Navigation: Alt + Left & Alt + Right; Refresh = F5, Close = Esc",
            JLabel.CENTER);

    help.setForeground(Color.WHITE);
    help.setBackground(Color.BLACK);
    help.setOpaque(true);
    help.setFont(new Font("Courier New", Font.BOLD, 14));
    add(help, BorderLayout.SOUTH);

    keyListener = new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_F5) {
                e.consume();
                processElements();
                refresh();
            } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                e.consume();
                dispose();
            } else if (e.getKeyCode() == KeyEvent.VK_LEFT && e.isAltDown()) {
                e.consume();
                moveBackward();
            } else if (e.getKeyCode() == KeyEvent.VK_RIGHT && e.isAltDown()) {
                e.consume();
                moveForward();
            } else if (e.getKeyCode() == KeyEvent.VK_S && e.isControlDown()) {
                e.consume();
                save();
            } else if (e.getKeyCode() == KeyEvent.VK_I && e.isControlDown()) {
                e.consume();
                increase();
            } else if (e.getKeyCode() == KeyEvent.VK_D && e.isControlDown()) {
                e.consume();
                decrease();
            }
        }
    };

    input.addKeyListener(keyListener);
    combo.addKeyListener(keyListener);

    setActive(0);

    pack();
    setModal(true);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

    input.requestFocus();
    logger.debug("Initialized UI.");
}

From source file:org.jcurl.core.gui.SimpleKeys.java

public void keyPressed(KeyEvent e) {
    switch (e.getKeyCode()) {
    case KeyEvent.VK_SPACE:
        if (worker == null || !worker.isAlive()) {
            worker = new Thread(player, player.getClass().getName());
            worker.start();/*from  w  ww. j a  v  a 2s  .c  o m*/
        } else {
            worker.interrupt();
            worker = null;
        }
        break;
    case KeyEvent.VK_LEFT:
        player.setTimeScale(-1);
        break;
    case KeyEvent.VK_RIGHT:
        player.setTimeScale(1);
        break;
    }
}

From source file:org.nuclos.client.ui.collect.CollectController.java

protected void setupShortcutsForTabs(MainFrameTab ifrm) {
    final Action actSelectSearchTab = new AbstractAction() {

        @Override//  ww w  .ja  v  a  2s  .  c  o  m
        public void actionPerformed(ActionEvent ev) {
            if (getCollectPanel().isTabbedPaneEnabledAt(CollectPanel.TAB_SEARCH)) {
                getCollectPanel().setTabbedPaneSelectedComponent(getSearchPanel());
            }
        }
    };

    final Action actSelectResultTab = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent ev) {
            if (getCollectPanel().isTabbedPaneEnabledAt(CollectPanel.TAB_RESULT)) {
                getCollectPanel().setTabbedPaneSelectedComponent(getResultPanel());
            }
        }
    };

    final Action actSelectDetailsTab = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent ev) {
            if (getCollectPanel().isTabbedPaneEnabledAt(CollectPanel.TAB_DETAILS)) {
                getCollectPanel().setTabbedPaneSelectedComponent(getDetailsPanel());
            }
        }
    };

    final String sKeySelectSearchTab = "SelectSearchTab";
    ifrm.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), sKeySelectSearchTab);
    ifrm.getRootPane().getActionMap().put(sKeySelectSearchTab, actSelectSearchTab);

    final String sKeySelectResultTab = "SelectResultTab";
    ifrm.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), sKeySelectResultTab);
    ifrm.getRootPane().getActionMap().put(sKeySelectResultTab, actSelectResultTab);

    /**
     * inner class SelectTabAction
     */
    class SelectTabAction extends AbstractAction {

        private int iDirection;

        /**
         * @param iDirection -1 for previous tab, +1 for next tab
         */
        SelectTabAction(int iDirection) {
            this.iDirection = iDirection;
        }

        @Override
        public void actionPerformed(ActionEvent ev) {
            int iExternalTabIndex = getCollectPanel().getTabbedPaneSelectedIndex();

            // try to find the next enabled tab in the given direction.
            // If the selected tab is the only enabled tab, do nothing:
            for (int i = 0; i < getCollectPanel().getTabCount() - 1; ++i) {
                int iInternalTabIndex = getCollectPanel().getTabIndexOf(iExternalTabIndex);
                iInternalTabIndex = (iInternalTabIndex + iDirection + getCollectPanel().getTabCount())
                        % getCollectPanel().getTabCount();
                iExternalTabIndex = getCollectPanel().getExternalTabIndexOf(iInternalTabIndex);
                if (getCollectPanel().isTabbedPaneEnabledAt(iExternalTabIndex)) {
                    getCollectPanel().setTabbedPaneSelectedIndex(iExternalTabIndex);
                    break;
                }
            }
        }
    } // inner class SelectTabAction

    final String sKeySelectPreviousTab = "SelectPreviousTab";
    ifrm.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.ALT_DOWN_MASK), sKeySelectPreviousTab);
    ifrm.getRootPane().getActionMap().put(sKeySelectPreviousTab, new SelectTabAction(-1));

    final String sKeySelectNextTab = "SelectNextTab";
    ifrm.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.ALT_DOWN_MASK), sKeySelectNextTab);
    ifrm.getRootPane().getActionMap().put(sKeySelectNextTab, new SelectTabAction(+1));
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.browser.BrowserUI.java

/** 
 * Helper method to create the trees hosting the display. 
 * /*from  w  w w  .j av a2  s. co  m*/
 * @param exp The logged in experimenter.
 */
private void createTrees(ExperimenterData exp) {
    treeDisplay = new DnDTree(model.getUserID(), TreeViewerAgent.isAdministrator());
    treeDisplay.addPropertyChangeListener(this);
    String key = "meta pressed A";
    if (UIUtilities.isWindowsOS())
        key = "ctrl pressed A";
    KeyStroke ks = KeyStroke.getKeyStroke(key);
    treeDisplay.getInputMap().put(ks, "none");
    treeDisplay.setVisible(true);
    treeDisplay.setRootVisible(false);
    ToolTipManager.sharedInstance().registerComponent(treeDisplay);
    treeDisplay.setCellRenderer(new TreeCellRenderer(model.getUserID()));
    treeDisplay.setShowsRootHandles(true);
    TreeImageSet root = new TreeImageSet("");
    treeDisplay.setModel(new DefaultTreeModel(root));
    if (model.getBrowserType() != Browser.ADMIN_EXPLORER) {
        TreeImageDisplay node = buildTreeNodes(exp);
        if (node != null)
            treeDisplay.collapsePath(new TreePath(node.getPath()));
    }
    //Add Listeners
    //treeDisplay.requestFocus();
    treeDisplay.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            mousePressedTime = e.getWhen();
            rightClickPad = UIUtilities.isMacOS() && SwingUtilities.isLeftMouseButton(e) && e.isControlDown();
            rightClickButton = SwingUtilities.isRightMouseButton(e);
            ctrl = e.isControlDown();
            if (UIUtilities.isMacOS())
                ctrl = e.isMetaDown();
            leftMouseButton = SwingUtilities.isLeftMouseButton(e);
            if (UIUtilities.isMacOS() || UIUtilities.isLinuxOS())
                onClick(e, false);
        }

        public void mouseReleased(MouseEvent e) {
            leftMouseButton = SwingUtilities.isLeftMouseButton(e);
            if (UIUtilities.isWindowsOS())
                onClick(e, true);
        }

        // public void mouseMoved(MouseEvent e) { rollOver(e); }
    });
    treeDisplay.addMouseMotionListener(new MouseMotionAdapter() {

        public void mouseMoved(MouseEvent e) {
            rollOver(e);
        }
    });
    treeDisplay.addTreeExpansionListener(listener);
    selectionListener = new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            event = e;
            eventHandledTime = System.currentTimeMillis();

            if (delayedHandlingTreeSelection)
                /* mouse click delayed handling until this event occurred */
                handleTreeSelection();

            switch (keyEvent) {
            case KeyEvent.VK_DOWN:
            case KeyEvent.VK_UP:
                TreePath[] paths = treeDisplay.getSelectionPaths();
                if (paths != null)
                    controller.onClick(Arrays.asList(paths));
                else
                    controller.onClick(new ArrayList<TreePath>());
                break;
            }
        }
    };
    treeDisplay.addTreeSelectionListener(selectionListener);
    //remove standard behaviour
    treeDisplay.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            ctrl = false;
            switch (e.getKeyCode()) {
            case KeyEvent.VK_ENTER:
                ViewCmd cmd = new ViewCmd(model.getParentModel(), true);
                cmd.execute();
                break;
            case KeyEvent.VK_DELETE:
                switch (model.getState()) {
                case Browser.LOADING_DATA:
                case Browser.LOADING_LEAVES:
                    //case Browser.COUNTING_ITEMS:  
                    break;
                default:
                    model.delete();
                }
                break;
            case KeyEvent.VK_CONTROL:
                if (!UIUtilities.isMacOS())
                    ctrl = true;
                break;
            case KeyEvent.VK_META:
                if (UIUtilities.isMacOS())
                    ctrl = true;
                break;
            case KeyEvent.VK_A:
                if (UIUtilities.isWindowsOS() && e.isControlDown()
                        || !UIUtilities.isWindowsOS() && e.isMetaDown()) {
                    handleMultiSelection();
                }
                break;
            case KeyEvent.VK_DOWN:
            case KeyEvent.VK_UP:
            case KeyEvent.VK_RIGHT:
                keyEvent = e.getKeyCode();
                break;
            case KeyEvent.VK_LEFT:
                TreePath[] paths = treeDisplay.getSelectionPaths();
                TreeImageDisplay node;
                Object o;
                for (int i = 0; i < paths.length; i++) {
                    o = paths[i].getLastPathComponent();
                    if (o instanceof TreeImageDisplay) {
                        node = (TreeImageDisplay) o;
                        if (node.isExpanded())
                            node.setExpanded(false);
                    }
                }
            }
        }

        public void keyReleased(KeyEvent e) {
            ctrl = false;
            keyEvent = -1;
        }

    });
}

From source file:org.pdfsam.guiclient.commons.panels.JVisualPdfPageSelectionPanel.java

private void initKeyListener() {
    //key listener
    thumbnailList.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_UP)) {
                moveUpButton.doClick();/*from   w w w  .  j  a v a2 s. co m*/
            } else if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_DOWN)) {
                moveDownButton.doClick();
            } else if ((e.getKeyCode() == KeyEvent.VK_DELETE)) {
                removeButton.doClick();
            } else if (drawDeletedItems && (e.isControlDown()) && (e.getKeyCode() == KeyEvent.VK_Z)) {
                undeleteButton.doClick();
            } else if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_RIGHT)) {
                rotateButton.doClick();
            } else if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_LEFT)) {
                rotateAntiButton.doClick();
            }
        }
    });
}

From source file:org.pmedv.blackboard.components.BoardEditor.java

/**
 * Wire needed actions with the keyboard
 */// w w  w.  j a va 2s .  c om
@SuppressWarnings("serial")
private void initActions() {

    // keyboard associations

    ApplicationWindow window = AppContext.getBean(ApplicationWindow.class);
    //      
    //      window.getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "upAction");
    //      window.getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "downAction");
    //      window.getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "leftAction");
    //      window.getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "rightAction");
    //
    //      window.getRootPane().getActionMap().put("upAction", new AbstractAction() {
    //         public void actionPerformed(ActionEvent event) {
    //            moveItemByKey("up");
    //         }
    //      });
    //      window.getRootPane().getActionMap().put("downAction", new AbstractAction() {
    //         public void actionPerformed(ActionEvent event) {
    //            moveItemByKey("down");
    //         }
    //      });
    //      window.getRootPane().getActionMap().put("leftAction", new AbstractAction() {
    //         public void actionPerformed(ActionEvent event) {
    //            moveItemByKey("left");
    //         }
    //      });
    //      window.getRootPane().getActionMap().put("rightAction", new AbstractAction() {
    //         public void actionPerformed(ActionEvent event) {
    //            moveItemByKey("right");
    //         }
    //      });

    registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            moveItemByKey("up");
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);

    registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            moveItemByKey("down");
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);

    registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            moveItemByKey("left");
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);

    registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            moveItemByKey("right");
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);

}

From source file:org.safs.selenium.webdriver.lib.WDLibrary.java

/**
 * Convert a Java KEYCODE to a Selenium WebDriver Keys Enum
 * @param keycode int, a java keycode//  ww  w.ja va2  s  .c o  m
 * @return Keys enum for (primarily) non-printable (control) characters, or null.
 */
public static Keys convertToKeys(int keycode) {
    Keys key = null;
    switch (keycode) {
    case java.awt.event.KeyEvent.VK_ADD:
        key = Keys.ADD;
        break;
    case java.awt.event.KeyEvent.VK_ALT:
        key = Keys.ALT;
        break;
    case java.awt.event.KeyEvent.VK_KP_DOWN:
        key = Keys.ARROW_DOWN;
        break;
    case java.awt.event.KeyEvent.VK_KP_LEFT:
        key = Keys.ARROW_LEFT;
        break;
    case java.awt.event.KeyEvent.VK_KP_RIGHT:
        key = Keys.ARROW_RIGHT;
        break;
    case java.awt.event.KeyEvent.VK_KP_UP:
        key = Keys.ARROW_UP;
        break;
    case java.awt.event.KeyEvent.VK_BACK_SPACE:
        key = Keys.BACK_SPACE;
        break;
    case java.awt.event.KeyEvent.VK_CANCEL:
        key = Keys.CANCEL;
        break;
    case java.awt.event.KeyEvent.VK_CLEAR:
        key = Keys.CLEAR;
        break;
    case java.awt.event.KeyEvent.VK_WINDOWS:
        key = Keys.COMMAND;
        break;
    case java.awt.event.KeyEvent.VK_CONTROL:
        key = Keys.CONTROL;
        break;
    case java.awt.event.KeyEvent.VK_DECIMAL:
        key = Keys.DECIMAL;
        break;
    case java.awt.event.KeyEvent.VK_DELETE:
        key = Keys.DELETE;
        break;
    case java.awt.event.KeyEvent.VK_DIVIDE:
        key = Keys.DIVIDE;
        break;
    case java.awt.event.KeyEvent.VK_DOWN:
        key = Keys.DOWN;
        break;
    case java.awt.event.KeyEvent.VK_END:
        key = Keys.END;
        break;
    case java.awt.event.KeyEvent.VK_ENTER:
        key = Keys.ENTER;
        break;
    case java.awt.event.KeyEvent.VK_EQUALS:
        key = Keys.EQUALS;
        break;
    case java.awt.event.KeyEvent.VK_ESCAPE:
        key = Keys.ESCAPE;
        break;
    case java.awt.event.KeyEvent.VK_F1:
        key = Keys.F1;
        break;
    case java.awt.event.KeyEvent.VK_F2:
        key = Keys.F2;
        break;
    case java.awt.event.KeyEvent.VK_F3:
        key = Keys.F3;
        break;
    case java.awt.event.KeyEvent.VK_F4:
        key = Keys.F4;
        break;
    case java.awt.event.KeyEvent.VK_F5:
        key = Keys.F5;
        break;
    case java.awt.event.KeyEvent.VK_F6:
        key = Keys.F6;
        break;
    case java.awt.event.KeyEvent.VK_F7:
        key = Keys.F7;
        break;
    case java.awt.event.KeyEvent.VK_F8:
        key = Keys.F8;
        break;
    case java.awt.event.KeyEvent.VK_F9:
        key = Keys.F9;
        break;
    case java.awt.event.KeyEvent.VK_F10:
        key = Keys.F10;
        break;
    case java.awt.event.KeyEvent.VK_F11:
        key = Keys.F11;
        break;
    case java.awt.event.KeyEvent.VK_F12:
        key = Keys.F12;
        break;
    case java.awt.event.KeyEvent.VK_HELP:
        key = Keys.HELP;
        break;
    case java.awt.event.KeyEvent.VK_HOME:
        key = Keys.HOME;
        break;
    case java.awt.event.KeyEvent.VK_INSERT:
        key = Keys.INSERT;
        break;
    case java.awt.event.KeyEvent.VK_LEFT:
        key = Keys.LEFT;
        break;
    case java.awt.event.KeyEvent.VK_META:
        key = Keys.META;
        break;
    case java.awt.event.KeyEvent.VK_MULTIPLY:
        key = Keys.MULTIPLY;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD0:
        key = Keys.NUMPAD0;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD1:
        key = Keys.NUMPAD1;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD2:
        key = Keys.NUMPAD2;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD3:
        key = Keys.NUMPAD3;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD4:
        key = Keys.NUMPAD4;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD5:
        key = Keys.NUMPAD5;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD6:
        key = Keys.NUMPAD6;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD7:
        key = Keys.NUMPAD7;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD8:
        key = Keys.NUMPAD8;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD9:
        key = Keys.NUMPAD9;
        break;
    case java.awt.event.KeyEvent.VK_PAGE_DOWN:
        key = Keys.PAGE_DOWN;
        break;
    case java.awt.event.KeyEvent.VK_PAGE_UP:
        key = Keys.PAGE_UP;
        break;
    case java.awt.event.KeyEvent.VK_PAUSE:
        key = Keys.PAUSE;
        break;
    case java.awt.event.KeyEvent.VK_RIGHT:
        key = Keys.RIGHT;
        break;
    case java.awt.event.KeyEvent.VK_SEMICOLON:
        key = Keys.SEMICOLON;
        break;
    case java.awt.event.KeyEvent.VK_SEPARATOR:
        key = Keys.SEPARATOR;
        break;
    case java.awt.event.KeyEvent.VK_SHIFT:
        key = Keys.SHIFT;
        break;
    case java.awt.event.KeyEvent.VK_SPACE:
        key = Keys.SPACE;
        break;
    case java.awt.event.KeyEvent.VK_SUBTRACT:
        key = Keys.SUBTRACT;
        break;
    case java.awt.event.KeyEvent.VK_TAB:
        key = Keys.TAB;
        break;
    case java.awt.event.KeyEvent.VK_UP:
        key = Keys.UP;
        break;
    }
    return key;
}

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

/** Initialize the stuff */
public void initialize() {
    super.initialize();

    // Make a VSL, and add it to the game
    VerbSynonymList takelist = new VerbSynonymList("take");
    takelist.add("grab");
    takelist.add("pick up");
    takelist.add("snatch");
    this.applyVerbSynonymList(takelist);

    // every game needs a player
    SlagePlayer player = new SlagePlayer("Roger Wilco", "SQ7 Testing Team");
    player.setSceneImage(new SlageImage("org?slage?tests?content?roger_eva.jpg"));
    player.setClickBoundary(new Boundary(player.getSceneImage(), 10));
    player.setZ(10);//  www. j a v  a2  s  . co m
    player.useClickBoundaryForCollision();

    AsyncKeyAction akaN = new AsyncKeyAction("North", new TranslateHandler(player, 0, -4));
    akaN.addKey(KeyEvent.VK_UP);

    AsyncKeyAction akaS = new AsyncKeyAction("South", new TranslateHandler(player, 0, 4));
    akaS.addKey(KeyEvent.VK_DOWN);

    AsyncKeyAction akaW = new AsyncKeyAction("West", new TranslateHandler(player, -4, 0));
    akaW.addKey(KeyEvent.VK_LEFT);

    AsyncKeyAction akaE = new AsyncKeyAction("East", new TranslateHandler(player, 4, 0));
    akaE.addKey(KeyEvent.VK_RIGHT);

    addAsyncAction(akaN);
    addAsyncAction(akaW);
    addAsyncAction(akaE);
    addAsyncAction(akaS);

    setPlayer(player);

    setAttribute("Debug Mode", new Boolean(false));

    ResponseHandler rlook = new ResponseHandler(player, "It's you!", null);
    rlook.addVerb("look");
    player.addHandler(rlook);
    ResponseHandler rlick = new ResponseHandler(player, "You lick yourself.", null);
    rlick.addVerb("Lick");
    rlick.addVerb("Kiss");
    player.addHandler(rlick);
    ResponseHandler rtake = new ResponseHandler(player, "This is a family game!", null);
    rtake.addVerb("Take");
    rtake.addVerb("Touch");
    player.addHandler(rtake);

    // set the default cursor
    getToolbar().setDefaultCursor(new SlageImage("org?slage?tests?content?sqcursor.PNG"));

    // make a fake Room
    room = new Room("Monolith Burger");
    room.setSceneImage(new SlageImage("org?slage?tests?content?monolith_scrollhall.jpg"));
    room.addObject(player);

    ResponseHandler look = new ResponseHandler(room,
            "A Monolith Burger! You haven't seen one of these in two or three sequels!", strMonolith);
    ResponseHandler lick = new ResponseHandler(room,
            "Having worked in a Monolith Burger once, you should know they are not sanitary enough to lick.",
            null);
    look.addVerb("look");
    look.addVerb("examine");
    lick.addVerb("lick");
    lick.addVerb("taste");
    room.addHandler(look);
    room.addHandler(lick);

    tryTheSpecial = new TextObject("Try the special!", new Font("Arial", 1, 14), Color.BLACK,
            new Point3D(0, room.getDimensions().height - 300, 0));
    room.addObject(tryTheSpecial);

    // build objects
    makeDuke();
    makePope();
    makeToolButtons();
    makeBathrooms();
    makeBuckazoid();
    makeArcade();
    makeCandy();

    makePauseHandler();

    // set up scheduling
    makeEvents();

    // set current room and add objects in it to draw list
    addObject(room);
    setRoom(room);

    loadSound(strMonolith, false);
}

From source file:org.squidy.nodes.GestureRecognizerShake.java

public void gestureReceived(GestureEvent event) {
    // DataGesture dataGesture = null;
    DataString dataString = null;//from   w  w w  .ja  v  a2 s  .c  om

    DataKey dataKeyUp = null;
    DataKey dataKeyDown = null;
    DataButton dataButtonUp = null;
    DataButton dataButtonDown = null;
    if (event.isValid() && event.getProbability() > 0.8) {
        if (gesturesLoaded.containsKey(event.getId())) {
            System.out.println("New Gesture Event \"" + gesturesLoaded.get(event.getId()).getGesture()
                    + "\" with ID " + event.getId() + " and Probability " + event.getProbability()
                    + " from Source " + event.getSource());
            String gesture = gesturesLoaded.get(event.getId()).getGesture();
            if (gesture.contains("right")) {
                dataKeyUp = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_RIGHT, true);
                dataKeyDown = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_RIGHT, false);
                dataButtonUp = new DataButton(GestureRecognizerShake.class, MouseEvent.BUTTON1, true);
                dataButtonUp = new DataButton(GestureRecognizerShake.class, MouseEvent.BUTTON1, false);
            } else if (gesture.contains("left")) {
                dataKeyUp = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_LEFT, true);
                dataKeyDown = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_LEFT, false);
            } else if (gesture.contains("circle")) {
                dataKeyUp = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_F5, true);
                dataKeyDown = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_F5, false);
            }
            dataString = new DataString(GestureRecognizerShake.class,
                    gesturesLoaded.get(event.getId()).getGesture());
        } else {
            LOG.info("New Gesture Event (not loaded) with ID " + event.getId() + " and Probability "
                    + event.getProbability() + " from Source " + event.getSource());

            dataString = new DataString(GestureRecognizerShake.class,
                    gesturesLoaded.get(event.getId()).getGesture());
        }
        dataString.setAttribute(DataConstant.SESSION_ID, event.getId());

        if (dataString != null)
            publish(dataString);
        if (dataKeyUp != null)
            publish(dataKeyUp);
        if (dataKeyDown != null)
            publish(dataKeyDown);
    }
}

From source file:org.squidy.nodes.Wiimote.java

/**
 * Adds a <code>CoreButtonListener</code> to the parameter mote.
 * //from   w w  w  . ja  va2s.  co  m
 * @param mote
 *            The mote that gets the core button listener.
 */
private CoreButtonListener createCoreButtonListener() {
    return new CoreButtonListener() {

        /*
         * (non-Javadoc)
         * 
         * @see motej.event.CoreButtonListener#buttonPressed(motej.event.CoreButtonEvent)
         */
        public void buttonPressed(CoreButtonEvent evt) {
            // Propagate buttons as button events.
            publish(new DataButton(Wiimote.class, DataButton.BUTTON_1, evt.isButtonAPressed()));
            // TODO Roman: Change button back to BUTTON_3.
            publish(new DataButton(Wiimote.class, DataButton.BUTTON_10, evt.isButtonBPressed()));

            publish(new DataButton(Wiimote.class, DataButton.BUTTON_A, evt.isButtonAPressed()));
            publish(new DataButton(Wiimote.class, DataButton.BUTTON_B, evt.isButtonBPressed()));

            // Home button pressed results in a VK_H key event.
            publish(new DataKey(Wiimote.class, KeyEvent.VK_H, evt.isButtonHomePressed()));

            // Propagate pad keys. -> UP, RIGHT, DOWN, LEFT result in VK_UP,
            // VK_RIGHT, VK_DOWN, VK_LEFT.
            publish(new DataKey(Wiimote.class, KeyEvent.VK_UP, evt.isDPadUpPressed()));
            publish(new DataKey(Wiimote.class, KeyEvent.VK_RIGHT, evt.isDPadRightPressed()));
            publish(new DataKey(Wiimote.class, KeyEvent.VK_DOWN, evt.isDPadDownPressed()));
            publish(new DataKey(Wiimote.class, KeyEvent.VK_LEFT, evt.isDPadLeftPressed()));

            // Button (-) and (+) pressed -> result in VK_MINUS and VK_PLUS
            // key event.
            publish(new DataKey(Wiimote.class, KeyEvent.VK_MINUS, evt.isButtonMinusPressed()));
            publish(new DataKey(Wiimote.class, KeyEvent.VK_PLUS, evt.isButtonPlusPressed()));
            publish(new DataButton(Wiimote.class, DataButton.BUTTON_PLUS, evt.isButtonPlusPressed()));

            // Button (1) and (2) pressed -> result in VK_1 and VK_2 key
            // event.
            publish(new DataKey(Wiimote.class, KeyEvent.VK_1, evt.isButtonOnePressed()));
            publish(new DataKey(Wiimote.class, KeyEvent.VK_2, evt.isButtonTwoPressed()));
        }
    };
}