Example usage for java.awt.event KeyEvent VK_MINUS

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

Introduction

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

Prototype

int VK_MINUS

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

Click Source Link

Document

Constant for the minus key, "-"

Usage

From source file:com.projity.pm.graphic.frames.GraphicManager.java

public void setToolBarAndMenus(final Container contentPane) {
    JToolBar toolBar;//  w ww . j av a2  s . c  om
    if (Environment.isRibbonUI()) {
        if (Environment.isNeedToRestart()) {
            contentPane.add(new JLabel(Messages.getString("Error.restart")), BorderLayout.CENTER);
            return;
        }

        setRibbon((JRibbonFrame) container, getMenuManager());

        //         JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR_WITH_NO_SUB_VIEW_OPTION);
        //         topTabs = new TabbedNavigation();
        //         JComponent tabs = topTabs.createContentPanel(getMenuManager(),viewToolBar,0,JTabbedPane.TOP,true);
        //         tabs.setAlignmentX(0.0f); // so it is left justified
        //
        //
        //          Box top = new Box(BoxLayout.Y_AXIS);
        //          JComponent bottom;
        //         top.add(tabs);
        //         bottom = new TabbedNavigation().createContentPanel(getMenuManager(),viewToolBar,1,JTabbedPane.BOTTOM,false);
        //         contentPane.add(top, BorderLayout.BEFORE_FIRST_LINE);
        //         contentPane.add(bottom,BorderLayout.AFTER_LAST_LINE);
        //         if (Environment.isNewLaf())
        //            contentPane.setBackground(Color.WHITE);

        //         if (Environment.isMac()){
        //            //System.setProperty("apple.laf.useScreenMenuBar","true");
        //            //System.setProperty("com.apple.mrj.application.apple.menu.about.name", Messages.getMetaString("Text.ShortTitle"));
        //            JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone()?MenuManager.MAC_STANDARD_MENU:MenuManager.SERVER_STANDARD_MENU);
        //            //((JComponent)menu).setBorder(BorderFactory.createEmptyBorder());
        //
        //            ((JFrame)container).setJMenuBar(menu);
        //            projectListMenu = (JMenu) menu.getComponent(5);
        //         }

    } else if (Environment.isNewLook()) {
        if (Environment.isNeedToRestart()) {
            contentPane.add(new JLabel(Messages.getString("Error.restart")), BorderLayout.CENTER);
            return;
        }

        toolBar = getMenuManager().getToolBar(MenuManager.BIG_TOOL_BAR);
        if (!getLafManager().isToolbarOpaque())
            toolBar.setOpaque(false);
        if (!isApplet())
            getMenuManager().setActionVisible(ACTION_FULL_SCREEN, false);

        if (Environment.isExternal()) // external users only see project team
            getMenuManager().setActionVisible(ACTION_TEAM_FILTER, false);

        toolBar.addSeparator(new Dimension(20, 20));
        toolBar.add(new Box.Filler(new Dimension(0, 0), new Dimension(0, 0),
                new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)));
        toolBar.add(((DefaultFrameManager) getFrameManager()).getProjectComboPanel());
        toolBar.add(Box.createRigidArea(new Dimension(20, 20)));
        if (Environment.isNewLaf())
            toolBar.setBackground(Color.WHITE);
        toolBar.setFloatable(false);
        toolBar.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        Box top;
        JComponent bottom;

        top = new Box(BoxLayout.Y_AXIS);
        toolBar.setAlignmentX(0.0f); // so it is left justified
        top.add(toolBar);

        JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR_WITH_NO_SUB_VIEW_OPTION);
        topTabs = new TabbedNavigation();
        JComponent tabs = topTabs.createContentPanel(getMenuManager(), viewToolBar, 0, JTabbedPane.TOP, true);
        tabs.setAlignmentX(0.0f); // so it is left justified

        top.add(tabs);
        bottom = new TabbedNavigation().createContentPanel(getMenuManager(), viewToolBar, 1, JTabbedPane.BOTTOM,
                false);
        contentPane.add(top, BorderLayout.BEFORE_FIRST_LINE);
        contentPane.add(bottom, BorderLayout.AFTER_LAST_LINE);
        if (Environment.isNewLaf())
            contentPane.setBackground(Color.WHITE);

        if (Environment.isMac()) {
            //System.setProperty("apple.laf.useScreenMenuBar","true");
            //System.setProperty("com.apple.mrj.application.apple.menu.about.name", Messages.getMetaString("Text.ShortTitle"));
            JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone() ? MenuManager.MAC_STANDARD_MENU
                    : MenuManager.SERVER_STANDARD_MENU);
            //((JComponent)menu).setBorder(BorderFactory.createEmptyBorder());

            ((JFrame) container).setJMenuBar(menu);
            projectListMenu = (JMenu) menu.getComponent(5);
        }

    } else {

        toolBar = getMenuManager().getToolBar(
                Environment.isMac() ? MenuManager.MAC_STANDARD_TOOL_BAR : MenuManager.STANDARD_TOOL_BAR);
        filterToolBarManager = FilterToolBarManager.create(getMenuManager());
        filterToolBarManager.addButtons(toolBar);
        contentPane.add(toolBar, BorderLayout.BEFORE_FIRST_LINE);
        JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR);
        viewToolBar.setOrientation(JToolBar.VERTICAL);
        viewToolBar.setRollover(true);
        contentPane.add(viewToolBar, BorderLayout.WEST);

        JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone()
                ? (Environment.isMac() ? MenuManager.MAC_STANDARD_MENU : MenuManager.STANDARD_MENU)
                : MenuManager.SERVER_STANDARD_MENU);

        if (!Environment.isMac()) {
            ((JComponent) menu).setBorder(BorderFactory.createEmptyBorder());
            JMenuItem logo = (JMenuItem) menu.getComponent(0);
            logo.setBorder(BorderFactory.createEmptyBorder());
            logo.setMaximumSize(new Dimension(124, 52));
            logo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        }
        ((JFrame) container).setJMenuBar(menu);
        projectListMenu = (JMenu) menu.getComponent(Environment.isMac() ? 5 : 6);
    }

    //accelerators
    addCtrlAccel(KeyEvent.VK_G, ACTION_GOTO, null);
    addCtrlAccel(KeyEvent.VK_L, ACTION_GOTO, null);
    addCtrlAccel(KeyEvent.VK_F, ACTION_FIND, null);
    addCtrlAccel(KeyEvent.VK_Z, ACTION_UNDO, null); //- Sanhita
    addCtrlAccel(KeyEvent.VK_Y, ACTION_REDO, null);
    addCtrlAccel(KeyEvent.VK_N, ACTION_NEW_PROJECT, null);
    addCtrlAccel(KeyEvent.VK_O, ACTION_OPEN_PROJECT, null);
    addCtrlAccel(KeyEvent.VK_S, ACTION_SAVE_PROJECT, null);
    addCtrlAccel(KeyEvent.VK_P, ACTION_PRINT, null); //-Sanhita
    addCtrlAccel(KeyEvent.VK_I, ACTION_INSERT_TASK, null);
    addCtrlAccel(KeyEvent.VK_PERIOD, ACTION_INDENT, null);
    addCtrlAccel(KeyEvent.VK_COMMA, ACTION_OUTDENT, null);
    addCtrlAccel(KeyEvent.VK_PLUS, ACTION_EXPAND, new ExpandAction());
    addCtrlAccel(KeyEvent.VK_ADD, ACTION_EXPAND, new ExpandAction());
    addCtrlAccel(KeyEvent.VK_EQUALS, ACTION_EXPAND, new ExpandAction());
    addCtrlAccel(KeyEvent.VK_MINUS, ACTION_COLLAPSE, new CollapseAction());
    addCtrlAccel(KeyEvent.VK_SUBTRACT, ACTION_COLLAPSE, new CollapseAction());

    // To force a recalculation. This normally shouldn't be needed.
    addCtrlAccel(KeyEvent.VK_R, ACTION_RECALCULATE, new RecalculateAction());
}

From source file:base.BasePlayer.BedCanvas.java

@Override
public void keyPressed(KeyEvent e) {
    // TODO Auto-generated method stub
    int keyCode = e.getKeyCode();

    if (keyCode == KeyEvent.VK_PLUS || keyCode == 107) {
        heightchanged = true;/*from   w  w w  .  j ava2  s.c om*/
        for (int i = 0; i < bedTrack.size(); i++) {
            if (bedTrack.get(i).nodeHeight < 20) {
                bedTrack.get(i).nodeHeight++;

            }
        }

        repaint();
    }
    if (keyCode == KeyEvent.VK_MINUS || keyCode == 109) {

        heightchanged = true;
        for (int i = 0; i < bedTrack.size(); i++) {
            if (bedTrack.get(i).nodeHeight > 1) {
                bedTrack.get(i).nodeHeight--;
            }
        }
        repaint();
    }
    if (keyCode == KeyEvent.VK_PAGE_UP) {

        if (this.forwardColor.getAlpha() < 255) {
            this.forwardColor = new Color(this.forwardColor.getRed(), this.forwardColor.getGreen(),
                    this.forwardColor.getBlue(), this.forwardColor.getAlpha() + 15);
            this.reverseColor = new Color(this.reverseColor.getRed(), this.reverseColor.getGreen(),
                    this.reverseColor.getBlue(), this.reverseColor.getAlpha() + 15);
            for (int i = 0; i < bedTrack.size(); i++) {

                if (bedTrack.get(i).getColors().size() > 0) {
                    Iterator<Map.Entry<Integer, Color>> it;
                    Map.Entry<Integer, Color> pair;
                    Color color;
                    it = bedTrack.get(i).getColors().entrySet().iterator();
                    while (it.hasNext()) {
                        pair = (Map.Entry<Integer, Color>) it.next();
                        color = pair.getValue();
                        color = new Color(color.getRed(), color.getGreen(), color.getBlue(),
                                color.getAlpha() + 15);
                        bedTrack.get(i).getColors().put(pair.getKey(), color);
                    }
                }
            }

        }

        repaint();
    }
    if (keyCode == KeyEvent.VK_PAGE_DOWN) {

        if (this.forwardColor.getAlpha() > 0) {
            this.forwardColor = new Color(this.forwardColor.getRed(), this.forwardColor.getGreen(),
                    this.forwardColor.getBlue(), this.forwardColor.getAlpha() - 15);
            this.reverseColor = new Color(this.reverseColor.getRed(), this.reverseColor.getGreen(),
                    this.reverseColor.getBlue(), this.reverseColor.getAlpha() - 15);

            for (int i = 0; i < bedTrack.size(); i++) {
                if (bedTrack.get(i).getColors().size() > 0) {
                    Iterator<Map.Entry<Integer, Color>> it;
                    Map.Entry<Integer, Color> pair;
                    Color color;
                    it = bedTrack.get(i).getColors().entrySet().iterator();

                    while (it.hasNext()) {

                        pair = (Map.Entry<Integer, Color>) it.next();
                        color = pair.getValue();

                        color = new Color(color.getRed(), color.getGreen(), color.getBlue(),
                                color.getAlpha() - 15);
                        bedTrack.get(i).getColors().put(pair.getKey(), color);

                    }
                }
            }
        }

        repaint();
    }
}

From source file:base.BasePlayer.Main.java

@Override

public void keyPressed(KeyEvent e) {
    keyCode = e.getKeyCode();/*from w  w  w  . j  a  va2 s  .co  m*/

    if (!Main.shift && (e.getModifiers() & KeyEvent.SHIFT_MASK) != 0) {

        Main.shift = true;
    } else if ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
        Main.drawCanvas.ctrlpressed = 100;

        if (keyCode == KeyEvent.VK_S) {

            if (drawCanvas.drawVariables.projectName.equals("Untitled")) {
                saveProjectAs.doClick();
            } else {
                Serializer ser = new Serializer();
                ser.serialize(drawCanvas.drawVariables.projectFile);
            }
        }
        if (keyCode == KeyEvent.VK_W) {

            //   System.out.println("\n----\n");

            /*
               int[][] array = new int[Main.varsamples][VariantHandler.callSlider.getUpperValue()+1];
                       
                  for(int i = 0; i<array.length; i++) {
                     for(int j = 0; j<array[i].length; j++) {
             array[i][j] = 0;
                     }
                  }
                  /*VarNode node = FileRead.head.getNext();
                  int counter = 0;
                  while(node != null) {
                     if(!drawCanvas.hideNode(node)) {               
             counter++;
             for(int i = 0; i<node.vars.size(); i++) {
                if(!drawCanvas.hideNodeVar(node, node.vars.get(i))) {
                   for(int j = 0;j<node.vars.get(i).getValue().size(); j++) {
                      if(!drawCanvas.hideVar(node.vars.get(i).getValue().get(j), false)) {
                         array[node.vars.get(i).getValue().get(j).getSample().getIndex()][(int)(MethodLibrary.round(node.vars.get(i).getValue().get(j).getAlleleFraction()*100,2))]++;
                      }
                              
                   }
                           
                           
                }                  
             }
                     }
                       
                     node = node.getNext();
                  }*/
            /*   int width = Main.drawCanvas.getWidth()-Main.sidebarWidth;
                    
               JPopupMenu menu = new JPopupMenu();
            Plotter plotter = new Plotter(width);         
            plotter.setPreferredSize(new Dimension(width,400));
            menu.add(plotter);
            menu.pack();
            menu.show(Main.drawCanvas,Main.sidebarWidth, drawScroll.getVerticalScrollBar().getValue());
            */
        }
        if (keyCode == KeyEvent.VK_PLUS || keyCode == 107) {

            //      defaultFontSize++;

            //      setFonts();
        }
        if (keyCode == KeyEvent.VK_M || keyCode == KeyEvent.VK_MINUS || keyCode == 109) {

            //      defaultFontSize--;

            //      setFonts();
        }
        /*   else if(keyCode == KeyEvent.VK_M) {
              VarNode current = FileRead.head.getNext();
               while(current != null) {
                          
                  if(current.getNext() != null && current.getNext().getPosition()-current.getPosition() > 100000) {
        System.out.println(current.getPosition() +" " +(current.getNext().getPosition()-current.getPosition()));
                  }
                  current = current.getNext();
               }
               current = null;
           }
           */
    } else if (keyCode == KeyEvent.VK_DELETE) {
        if (Main.drawCanvas.selectedSample != null) {
            Main.drawCanvas.removeSample(Main.drawCanvas.selectedSample);
        }
    }
    /*   else if(keyCode == KeyEvent.VK_7) {
                  
                  
       }*/
    else if (keyCode == KeyEvent.VK_O && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
        /*   clearData();
                   
           try {
              FileInputStream fin = new FileInputStream("C:/HY-Data/RKATAINE/test.ses");
              ObjectInputStream ois = new ObjectInputStream(fin);
              drawCanvas.sampleList = (ArrayList<Sample>) ois.readObject();
              Main.samples = (short)drawCanvas.sampleList.size();
                      
              drawCanvas.splits = (ArrayList<SplitClass>) ois.readObject();
              for(int i = 0; i<drawCanvas.splits.size(); i++) {
                 drawCanvas.splits.get(i).resetSplits();
              }
              drawCanvas.drawVariables = (DrawVariables)ois.readObject();
                      
              ois.close();
              drawCanvas.resizeCanvas(Main.drawCanvas.getWidth(), Main.drawCanvas.getHeight());
                      
              Draw.setScrollbar(drawCanvas.drawVariables.scrollbarpos);
                      
              for(int i= 0; i<drawCanvas.splits.size(); i++) {
                 drawCanvas.splits.get(i).setCytoImage(null);
                 chromDraw.drawCyto(drawCanvas.splits.get(i));
                 chromDraw.updateExons = true;
                 FileRead.search = true;
                 drawCanvas.gotoPos(drawCanvas.splits.get(i).chrom, drawCanvas.splits.get(i).start, drawCanvas.splits.get(i).end);
                 chromDraw.repaint();
              }
              for(int i = 0 ;i<drawCanvas.sampleList.size(); i++) {
                 for(int r = 0 ;r<drawCanvas.sampleList.size(); r++) {
                    if(drawCanvas.sampleList.get(i).getreadHash().size() > 0) {
          drawCanvas.sampleList.get(i).resetreadHash();
                    }
                 }
              }
                   
           }
           catch(Exception ex) {
              ex.printStackTrace();
           }
           */
    }

    else if (keyCode == KeyEvent.VK_F9) {

        FileRead.head.putNext(null);
        drawCanvas.variantsStart = 0;
        drawCanvas.variantsEnd = 1;
        Draw.updatevars = true;
        Main.drawCanvas.repaint();

    } else if (keyCode == KeyEvent.VK_F11) {

        /*   try {
              BBFileReader reader = new BBFileReader( Main.bedCanvas.bedTrack.get(0).file.getCanonicalPath(),  Main.bedCanvas.bedTrack.get(0));
              int zoomlevel = 1;
              for(int i =2;i<reader.getZoomLevels().getZoomHeaderCount();i++) {
                 if(reader.getZoomLevels().getZoomLevelHeader(i).getReductionLevel() < (Main.drawCanvas.splits.get(0).viewLength/(Main.drawCanvas.splits.get(0).pixel*Main.drawCanvas.splits.get(0).viewLength))) {
                    zoomlevel = i;
                 }
                 else {
                    break;
                 }
              }
                      
                
                         
           }
           catch(Exception ex) {
              ex.printStackTrace();
           }*/
    } else if (keyCode == KeyEvent.VK_F12) {
        /*VarNode next = Main.drawCanvas.current.getNext();
                
        MethodLibrary.makeMultiAlt("2",next.getPosition(), "G", next);
                
           next = null;
        */
        /*   try {
              URL urli = new URL("ftp://ftp.ensembl.org/pub/grch37/update/gff3/homo_sapiens/Homo_sapiens.GRCh37.87.gff3.gz");
              System.out.println(urli.getProtocol() +" " +urli.getHost() +" " +urli.getPath().substring(0,urli.getPath().lastIndexOf("/")+1));
           }
           catch(Exception ex) {
              ex.printStackTrace();
           }*/
    } else if (keyCode == KeyEvent.VK_F8) {

        File file = new File(searchField.getText().replaceAll(" ", ""));
        if (!file.exists()) {
            if (Main.drawCanvas.splits.get(0).viewLength < 1000) {

                Main.getConsSeq();
            }
        } else {
            try {
                /*
                JFileChooser chooser = new JFileChooser(file.getPath());
                chooser.setAcceptAllFileFilterUsed(true);                       
                        
                chooser.setDialogTitle("Save FASTA file as...");
                int returnVal = chooser.showSaveDialog((Component)this.getParent());                   
                        
                if(returnVal == JFileChooser.APPROVE_OPTION) {  
                  String suffix = "";
                  if(!chooser.getSelectedFile().getName().endsWith(".fa") && !chooser.getSelectedFile().getName().endsWith(".fasta")) {
                     suffix = ".fa";
                  }
                          
                   File outfile = new File(chooser.getSelectedFile().getCanonicalPath() +suffix);   
                 //  File outfile = new File("test.fa");   
                   Main.nothread = true;
                  Main.noreadthread = true;
                  FileRead.search = true;   
                  Draw.variantcalculator = true;
                        
                  Seqfetcher fetcher = new Seqfetcher(file, outfile);
                  fetcher.execute();
                           
                }*/
            } catch (Exception ex) {
                ex.printStackTrace();
            }

        }

    } else if (keyCode == KeyEvent.VK_ENTER) {

        if (e.getSource() == searchField) {
            search(searchField.getText());

        }

    }

}

From source file:org.datavyu.views.DatavyuView.java

/**
 * Constructor./*from   w w w .ja  va 2  s.c om*/
 *
 * @param app
 *            The SingleFrameApplication that invoked this main FrameView.
 */
public DatavyuView(final SingleFrameApplication app) {
    super(app);

    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();

    manager.addKeyEventDispatcher(new KeyEventDispatcher() {

        /**
         * Dispatches the keystroke to the correct action.
         *
         * @param evt The event that triggered this action.
         * @return true if the KeyboardFocusManager should take no further
         * action with regard to the KeyEvent; false otherwise.
         */
        @Override
        public boolean dispatchKeyEvent(final KeyEvent evt) {

            // Pass the keyevent onto the keyswitchboard so that it can
            // route it to the correct action.
            //                    spreadsheetMenuSelected(null);

            return Datavyu.getApplication().dispatchKeyEvent(evt);
        }
    });

    // generated GUI builder code
    initComponents();

    // BugzID:492 - Set the shortcut for new cell, so a keystroke that won't
    // get confused for the "carriage return". The shortcut for new cells
    // is handled in Datavyu.java
    newCellMenuItem.setAccelerator(KeyStroke.getKeyStroke('\u21A9'));

    // BugzID:521 + 468 - Define accelerator keys based on Operating system.
    int keyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    weakTemporalOrderMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, keyMask));

    strongTemporalOrderMenuItem
            .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.SHIFT_MASK | keyMask));

    // Set zoom in to keyMask + '+'
    zoomInMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, keyMask));

    // Set zoom out to keyMask + '-'
    zoomOutMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, keyMask));

    // Set reset zoom to keyMask + '0'
    resetZoomMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_0, keyMask));

    // Set the save accelerator to keyMask + 'S'
    saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, keyMask));

    // Set the save as accelerator to keyMask + shift + 'S'
    saveAsMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, keyMask | InputEvent.SHIFT_MASK));

    // Set the open accelerator to keyMask + 'o';
    openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, keyMask));

    // Set the new accelerator to keyMask + 'N';
    newMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, keyMask));

    // Set the new accelerator to keyMask + 'L';
    newCellLeftMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, keyMask));

    // Set the new accelerator to keyMask + 'R';
    newCellRightMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, keyMask));

    // Set the show spreadsheet accelrator to F5.
    showSpreadsheetMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));

    // Set the undo accelerator to keyMask + 'Z';
    undoSpreadSheetMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, keyMask));

    // Set the redo accelerator to keyMask + 'Y'
    redoSpreadSheetMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, keyMask));

    if (panel != null) {
        panel.deregisterListeners();
        panel.removeFileDropEventListener(this);
    }

    panel = new SpreadsheetPanel(Datavyu.getProjectController().getDB(), null);
    panel.registerListeners();
    panel.addFileDropEventListener(this);
    setComponent(panel);

    System.out.println(getComponent());

    // initialize the undo/redo system
    spreadsheetUndoManager = new SpreadsheetUndoManager();
    undoSupport = new UndoableEditSupport();
    undoSupport.addUndoableEditListener(new UndoAdapter());
    refreshUndoRedo();
    //////

    //Jakrabbit Menu
    pushMenuItem.setVisible(false);
    pullMenuItem.setVisible(false);
    jSeparator10.setVisible(false);

}

From source file:org.dishevelled.brainstorm.BrainStorm.java

/**
 * Initialize components./*ww w .  j a  v  a  2 s .com*/
 */
private void initComponents() {
    Font font = new Font(chooseFontName(), Font.PLAIN, fontSize);
    hiddenCursor = createHiddenCursor();
    textArea = new JTextArea() {
        /** {@inheritDoc} */
        protected void paintComponent(final Graphics graphics) {
            Graphics2D g2 = (Graphics2D) graphics;
            g2.setRenderingHint(KEY_FRACTIONALMETRICS, VALUE_FRACTIONALMETRICS_ON);
            g2.setRenderingHint(KEY_TEXT_ANTIALIASING, VALUE_TEXT_ANTIALIAS_LCD_HRGB);
            super.paintComponent(g2);
        }
    };
    textArea.setFont(font);
    textArea.setOpaque(true);
    textArea.setCursor(hiddenCursor);
    textArea.setBackground(backgroundColor);
    textArea.setForeground(textColor);
    textArea.setRows(rows);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);

    // clear all input mappings
    InputMap inputMap = textArea.getInputMap();
    while (inputMap != null) {
        inputMap.clear();
        inputMap = inputMap.getParent();
    }
    // re-add select default input mappings
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "insert-break");
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "insert-tab");
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "delete-previous");
    int keyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, keyMask), "delete-previous-word");

    // add new input mappings
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, keyMask), "increase-font-size");
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, keyMask), "decrease-font-size");
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_S, keyMask), "save");
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "quit");
    textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Q, keyMask), "quit");

    Action increaseFontSizeAction = new IncreaseFontSizeAction();
    Action decreaseFontSizeAction = new DecreaseFontSizeAction();
    Action saveAction = new SaveAction();
    Action quitAction = new QuitAction();

    textArea.getActionMap().put("increase-font-size", increaseFontSizeAction);
    textArea.getActionMap().put("decrease-font-size", decreaseFontSizeAction);
    textArea.getActionMap().put("save", saveAction);
    textArea.getActionMap().put("quit", quitAction);

    placeholder = Box.createGlue();
}

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

/**
 * Adds a <code>CoreButtonListener</code> to the parameter mote.
 * //from   ww w. j  a  va 2 s  . c om
 * @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()));
        }
    };
}

From source file:sc.fiji.kappa.gui.KappaMenuBar.java

/**
 * Creates a menu-bar and adds menu items to it
 *//*from  w  w w  . j  ava 2s  . c o m*/
public KappaMenuBar(Context context, KappaFrame frame) {
    context.inject(this);

    this.frame = frame;

    // File chooser for curve data
    FileNameExtensionFilter kappaFilter = new FileNameExtensionFilter("Kappa Files", "kapp");

    kappaLoad = new JFileChooser();
    kappaLoad.setFileFilter(kappaFilter);
    kappaLoad.setDialogTitle("Load Existing Curve Data");

    kappaSave = new JFileChooser();
    kappaSave.setFileFilter(kappaFilter);
    kappaSave.setDialogTitle("Save Curve Data");

    // Declares the file menu
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('F');

    /*
     * // Menu Items for file operations // Creates a new file chooser. Same native
     * image support as ImageJ since ImageJ // libraries are used. kappaOpen = new
     * JFileChooser(); FileNameExtensionFilter filter = new
     * FileNameExtensionFilter("Image Files", "tif", "tiff", "jpeg", "jpg", "bmp",
     * "fits", "pgm", "ppm", "pbm", "gif", "png", "dic", "dcm", "dicom", "lsm",
     * "avi"); kappaOpen.setFileFilter(filter);
     * 
     * JMenuItem openMenu = new JMenuItem("Open Image File");
     * openMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, DEFAULT_MASK));
     * openMenu.addActionListener(e -> { int returnVal =
     * kappaOpen.showOpenDialog(this.frame); if (returnVal ==
     * JFileChooser.APPROVE_OPTION) { openImageFile(kappaOpen.getSelectedFile()); }
     * }); fileMenu.add(openMenu);
     */

    JMenuItem openActiveMenu = new JMenuItem("Open Active Image");
    openActiveMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, DEFAULT_MASK));
    openActiveMenu.addActionListener(e -> {
        openActiveImage(context);
    });
    fileMenu.add(openActiveMenu);
    fileMenu.addSeparator();

    JMenuItem importROIsAsCurvesMenu = new JMenuItem("Import ROIs as curves");
    importROIsAsCurvesMenu.addActionListener(e -> {
        importROIsAsCurves(context);
    });
    fileMenu.add(importROIsAsCurvesMenu);
    fileMenu.addSeparator();

    JMenuItem loadMenu = new JMenuItem("Load Curve Data");
    loadMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, DEFAULT_MASK));
    loadMenu.addActionListener(e -> {
        // Handle open button action.
        int returnVal = kappaLoad.showOpenDialog(this.frame);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            file = kappaLoad.getSelectedFile();
            loadCurveFile(file);
        }
    });
    fileMenu.add(loadMenu);

    JMenuItem saveMenu = new JMenuItem("Save Curve Data");
    saveMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, DEFAULT_MASK));
    saveMenu.addActionListener(e -> {

        String dirPath = frame.getImageStack().getOriginalFileInfo().directory;
        if (dirPath != null) {
            String kappaPath = FilenameUtils
                    .removeExtension(frame.getImageStack().getOriginalFileInfo().fileName);
            kappaPath += ".kapp";
            File fullPath = new File(dirPath, kappaPath);
            kappaSave.setSelectedFile(fullPath);
        }

        // Handles save button action.
        int returnVal = kappaSave.showSaveDialog(this.frame);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            file = kappaSave.getSelectedFile();
            // Appends a .kapp
            if (!file.getPath().toLowerCase().endsWith(".kapp")) {
                file = new File(file.getPath() + ".kapp");
            }
            saveCurveFile(file);
        }
    });
    fileMenu.add(saveMenu);

    this.add(fileMenu);

    // Menu Items for all the tools
    JMenu toolMenu = new JMenu("Tools");
    for (int i = 0; i < ToolPanel.NO_TOOLS; i++) {
        toolMenuItems[i] = new JMenuItem(ToolPanel.TOOL_MENU_NAMES[i]);
        toolMenuItems[i].setEnabled(false);
        toolMenuItems[i].setAccelerator(KeyStroke.getKeyStroke(ToolPanel.TOOL_MNEMONICS[i], 0));
        final int j = i;
        toolMenuItems[i].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent event) {
                frame.getToolPanel().setSelected(j, true);
                frame.getScrollPane().setCursor(ToolPanel.TOOL_CURSORS[j]);
            }
        });
        toolMenu.add(toolMenuItems[i]);
    }

    // We also add a menu item for deleting Bezier Curves via the Backspace key.
    setDelete(new JMenuItem("Delete Curves"));
    getDelete().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            frame.deleteCurve();
        }
    });
    getDelete().setEnabled(false);
    getDelete().setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
    toolMenu.addSeparator();
    toolMenu.add(getDelete());

    setEnter(new JMenuItem("Enter Curve"));
    getEnter().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            frame.enterCurve();
        }
    });
    getEnter().setEnabled(false);
    getEnter().setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
    toolMenu.add(getEnter());

    fit = new JMenuItem("Fit Curve");
    fit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            frame.fitCurves();
        }
    });
    fit.setEnabled(false);
    fit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, 0));
    toolMenu.add(fit);
    toolMenu.addSeparator();

    // TODO remove this later
    // JMenuItem runTestScript = new JMenuItem ("Run Testing Script");
    // runTestScript.addActionListener (new ActionListener(){
    // public void actionPerformed (ActionEvent event){
    // try{frame.testingScript();}
    // catch(IOException e){System.out.println("Script Error");}
    // }});
    // runTestScript.setAccelerator (KeyStroke.getKeyStroke(KeyEvent.VK_S, 0));
    // toolMenu.add(runTestScript);
    JCheckBoxMenuItem toggleCtrlPtAdjustment = new JCheckBoxMenuItem("Enable Control Point Adjustment");
    toggleCtrlPtAdjustment.setState(frame.isEnableCtrlPtAdjustment());
    toggleCtrlPtAdjustment.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            frame.setEnableCtrlPtAdjustment(!frame.isEnableCtrlPtAdjustment());
            ;
        }
    });
    toggleCtrlPtAdjustment.setEnabled(true);
    toolMenu.add(toggleCtrlPtAdjustment);

    this.add(toolMenu);

    // Navigation Menu
    // TODO FIX action listeners to these.
    JMenu navigateMenu = new JMenu("Navigate");
    prevFrame = new JMenuItem("Previous Frame");
    nextFrame = new JMenuItem("Next Frame");
    prevKeyframe = new JMenuItem("Previous Keyframe");
    nextKeyframe = new JMenuItem("Next Keyframe");
    prevFrame.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.ALT_MASK));
    nextFrame.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ActionEvent.ALT_MASK));
    prevKeyframe.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, DEFAULT_MASK));
    nextKeyframe.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, DEFAULT_MASK));
    prevFrame.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            frame.getControlPanel().getCurrentLayerSlider()
                    .setValue(Math.max(frame.getControlPanel().getCurrentLayerSlider().getValue() - 1,
                            frame.getControlPanel().getCurrentLayerSlider().getMinimum()));
        }
    });
    nextFrame.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            frame.getControlPanel().getCurrentLayerSlider()
                    .setValue(Math.min(frame.getControlPanel().getCurrentLayerSlider().getValue() + 1,
                            frame.getControlPanel().getCurrentLayerSlider().getMaximum()));
        }
    });
    prevKeyframe.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
        }
    });
    nextKeyframe.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
        }
    });
    prevFrame.setEnabled(false);
    nextFrame.setEnabled(false);
    prevKeyframe.setEnabled(false);
    nextKeyframe.setEnabled(false);
    navigateMenu.add(prevFrame);
    navigateMenu.add(nextFrame);
    navigateMenu.add(prevKeyframe);
    navigateMenu.add(nextKeyframe);
    this.add(navigateMenu);

    // Image options.
    JMenu imageMenu = new JMenu("Image");

    // Brightness and Contrast tool. Taken from ImageJ.
    adjustBrightnessContrast = new JMenuItem("Adjust Brightness/Contrast");
    adjustBrightnessContrast.setEnabled(false);
    adjustBrightnessContrast.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ContrastAdjuster c = new ContrastAdjuster(frame);
            c.run("Brightness/Contrast...[C]");
        }
    });
    imageMenu.add(adjustBrightnessContrast);
    this.add(imageMenu);

    // Zoom-In and Zoom-Out Commands
    JMenu viewMenu = new JMenu("View");
    zoomIn = new JMenuItem("Zoom In");
    zoomOut = new JMenuItem("Zoom Out");
    zoomIn.addActionListener(new ZoomInListener(frame.getControlPanel()));
    zoomOut.addActionListener(new ZoomOutListener(frame.getControlPanel()));
    zoomIn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, DEFAULT_MASK));
    zoomOut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, DEFAULT_MASK));
    zoomIn.setEnabled(false);
    zoomOut.setEnabled(false);

    // Menu Item for showing bounding boxes
    setBoundingBoxMenu(new JCheckBoxMenuItem("Show Bounding Boxes"));
    getBoundingBoxMenu().setState(false);
    getBoundingBoxMenu().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent a) {
            frame.drawImageOverlay();
        }
    });
    getBoundingBoxMenu().setEnabled(false);

    // Menu Item for choosing the x-axis values for the curvature and intensity
    // display
    // For instance, you can display x vs. curvature, or current arc length vs
    // curvature, or the point index vs curvature
    // The default is the point index.
    distributionDisplay = DEFAULT_DISTRIBUTION_DISPLAY;
    JMenu xAxisSubmenu = new JMenu("Curve Distribution X-Axis:");
    ButtonGroup xAxisGroup = new ButtonGroup();
    JMenuItem xValue = new JCheckBoxMenuItem("X-Coordinate");
    JMenuItem curveLength = new JCheckBoxMenuItem("Arc Length");
    JMenuItem pointIndex = new JCheckBoxMenuItem("Point Index");
    xAxisGroup.add(xValue);
    xAxisGroup.add(curveLength);
    xAxisGroup.add(pointIndex);
    xAxisSubmenu.add(xValue);
    xAxisSubmenu.add(curveLength);
    xAxisSubmenu.add(pointIndex);
    xValue.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent a) {
            distributionDisplay = 0;
            frame.getInfoPanel().updateHistograms();
        }
    });
    curveLength.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent a) {
            distributionDisplay = 1;
            frame.getInfoPanel().updateHistograms();
        }
    });
    pointIndex.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent a) {
            distributionDisplay = 2;
            frame.getInfoPanel().updateHistograms();
        }
    });
    if (DEFAULT_DISTRIBUTION_DISPLAY == 0) {
        xValue.setSelected(true);
    } else if (DEFAULT_DISTRIBUTION_DISPLAY == 1) {
        curveLength.setSelected(true);
    } else {
        pointIndex.setSelected(true);
    }

    // Menu Item for scaling curve strokes when zooming in or out
    setScaleCurvesMenu(new JCheckBoxMenuItem("Scale Curve Strokes"));
    getScaleCurvesMenu().setState(true);
    getScaleCurvesMenu().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent a) {
            frame.drawImageOverlay();
        }
    });
    getScaleCurvesMenu().setEnabled(false);

    // Menu Item for image antialiasing
    setAntialiasingMenu(new JCheckBoxMenuItem("Enable Antialiasing"));
    getAntialiasingMenu().setState(false);
    getAntialiasingMenu().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent a) {
            frame.setScaledImage(frame.getControlPanel().getScaleSlider().getValue() / 100.0);
            frame.drawImageOverlay();
        }
    });
    getAntialiasingMenu().setEnabled(false);

    // Menu Item for displaying tangent and normal curves.
    setTangentMenu(new JCheckBoxMenuItem("Show Tangent and Normal Vectors"));
    getTangentMenu().setState(false);
    getTangentMenu().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent a) {
            frame.drawImageOverlay();
        }
    });
    getTangentMenu().setEnabled(false);

    viewMenu.add(zoomIn);
    viewMenu.add(zoomOut);
    viewMenu.addSeparator();
    viewMenu.add(xAxisSubmenu);
    viewMenu.addSeparator();
    viewMenu.add(getScaleCurvesMenu());
    viewMenu.add(getTangentMenu());
    viewMenu.add(getBoundingBoxMenu());
    viewMenu.add(getAntialiasingMenu());
    this.add(viewMenu);

    // Sets a "Help" menu list
    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic('H');

    // Adds an "About" option to the menu list
    JMenuItem aboutMenuItem = new JMenuItem("About...", 'A');
    aboutMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            JOptionPane.showMessageDialog(frame, "Developed by the Brouhard lab, 2016-2017.",
                    KappaFrame.APPLICATION_NAME, JOptionPane.INFORMATION_MESSAGE);
        }
    });

    // Adds a link to the User Manual
    JMenuItem userManualLink = new JMenuItem("User Manual");
    userManualLink.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                if (Desktop.isDesktopSupported()) {
                    Desktop.getDesktop().browse(new URI(
                            "https://dl.dropboxusercontent.com/u/157117/KappaFrame%20User%20Manual.pdf"));
                }
            } catch (Exception e) {
                System.out.println("Incorrect URL Syntax");
            }
            ;
        }
    });

    // Adds all newly created menu items to the "Help" list
    helpMenu.add(userManualLink);
    helpMenu.add(aboutMenuItem);
    this.add(helpMenu);
}