Coverage Report - org.dishevelled.venn.cytoscape.VennDiagramsUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
VennDiagramsUtils
0%
0/10
N/A
1
VennDiagramsUtils$1
0%
0/3
N/A
1
 
 1  
 /*
 2  
 
 3  
     dsh-venn-cytoscape-plugin  Cytoscape plugin for venn diagrams.
 4  
     Copyright (c) 2010-2012 held jointly by the individual authors.
 5  
 
 6  
     This library is free software; you can redistribute it and/or modify it
 7  
     under the terms of the GNU Lesser General Public License as published
 8  
     by the Free Software Foundation; either version 3 of the License, or (at
 9  
     your option) any later version.
 10  
 
 11  
     This library is distributed in the hope that it will be useful, but WITHOUT
 12  
     ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
 13  
     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 14  
     License for more details.
 15  
 
 16  
     You should have received a copy of the GNU Lesser General Public License
 17  
     along with this library;  if not, write to the Free Software Foundation,
 18  
     Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA.
 19  
 
 20  
     > http://www.fsf.org/licensing/licenses/lgpl.html
 21  
     > http://www.opensource.org/licenses/lgpl-license.php
 22  
 
 23  
 */
 24  
 package org.dishevelled.venn.cytoscape;
 25  
 
 26  
 import java.awt.Toolkit;
 27  
 
 28  
 import java.awt.event.ActionEvent;
 29  
 import java.awt.event.KeyEvent;
 30  
 import java.awt.event.WindowEvent;
 31  
 
 32  
 import javax.swing.AbstractAction;
 33  
 import javax.swing.Action;
 34  
 import javax.swing.KeyStroke;
 35  
 import javax.swing.JComponent;
 36  
 import javax.swing.JDialog;
 37  
 import javax.swing.JRootPane;
 38  
 
 39  
 import cytoscape.CyNode;
 40  
 import cytoscape.groups.CyGroup;
 41  
 
 42  
 /**
 43  
  * Utility methods.
 44  
  *
 45  
  * @author  Michael Heuer
 46  
  */
 47  0
 final class VennDiagramsUtils
 48  
 {
 49  
 
 50  
     /**
 51  
      * Return the name of the specified group.
 52  
      *
 53  
      * @param group group
 54  
      * @return the name of the specified group
 55  
      */
 56  
     static String nameOf(final CyGroup group)
 57  
     {
 58  0
         return group.getGroupName();
 59  
     }
 60  
 
 61  
     /**
 62  
      * Return the name of the specified node.
 63  
      *
 64  
      * @param node node
 65  
      * @return the name of the specified node
 66  
      */
 67  
     static String nameOf(final CyNode node)
 68  
     {
 69  0
         return node.toString();
 70  
     }
 71  
 
 72  
     /**
 73  
      * Install a close action binding to <code>Ctrl-C</code>/<code>Command-C</code> for the specified dialog.
 74  
      *
 75  
      * @param dialog dialog, must not be null
 76  
      */
 77  
     static void installCloseKeyBinding(final JDialog dialog)
 78  
     {
 79  0
         Action close = new AbstractAction()
 80  0
             {
 81  
                 /** {@inheritDoc} */
 82  
                 public void actionPerformed(final ActionEvent event)
 83  
                 {
 84  0
                     dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
 85  0
                 }
 86  
             };
 87  0
         int menuKeyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
 88  0
         KeyStroke closeStroke = KeyStroke.getKeyStroke(KeyEvent.VK_W, menuKeyMask);
 89  0
         JRootPane rootPane = dialog.getRootPane();
 90  0
         rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(closeStroke, "close");
 91  0
         rootPane.getActionMap().put("close", close);
 92  0
     }
 93  
 }