View Javadoc

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 static javax.swing.SwingUtilities.windowForComponent;
27  import static org.dishevelled.venn.cytoscape.VennDiagramsUtils.installCloseKeyBinding;
28  
29  import java.awt.Component;
30  import java.awt.event.ActionEvent;
31  
32  import javax.swing.AbstractAction;
33  import javax.swing.Action;
34  import javax.swing.JDialog;
35  import javax.swing.JFrame;
36  
37  import cytoscape.Cytoscape;
38  
39  import cytoscape.plugin.CytoscapePlugin;
40  
41  /**
42   * Cytoscape plugin for venn diagrams.
43   *
44   * @author  Michael Heuer
45   * @version $Revision$ $Date$
46   */
47  public final class VennDiagrams
48      extends CytoscapePlugin
49  {
50      /** Venn diagrams action. */
51      private final Action vennDiagrams = new AbstractAction("Venn Diagrams...")
52          {
53              /** {@inheritDoc} */
54              public void actionPerformed(final ActionEvent event)
55              {
56                  JFrame frame = (JFrame) windowForComponent((Component) event.getSource());
57                  JDialog dialog = new JDialog(frame, "Venn/Euler Diagrams"); // i18n
58                  dialog.setContentPane(new GroupsView());
59                  dialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
60                  installCloseKeyBinding(dialog);
61                  dialog.setBounds(200, 200, 400, 400);
62                  dialog.setVisible(true);
63              }
64          };
65  
66  
67      /**
68       * Create a new cytoscape plugin for venn diagrams.
69       */
70      public VennDiagrams()
71      {
72          // todo:  check if on AWT event thread
73          Cytoscape.getDesktop().getCyMenus().getOperationsMenu().add(vennDiagrams);
74      }
75  }