Hide Sequences
authoramwaterhouse <Andrew Waterhouse>
Thu, 16 Mar 2006 15:28:30 +0000 (15:28 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 16 Mar 2006 15:28:30 +0000 (15:28 +0000)
src/jalview/gui/PopupMenu.java

index 3114211..ba178ab 100755 (executable)
@@ -111,28 +111,58 @@ public class PopupMenu extends JPopupMenu
         }\r
 \r
 \r
-        if ((seq != null)\r
-            && seq.getDatasetSequence().getPDBId() != null)\r
+        if (seq != null)\r
         {\r
-          java.util.Enumeration e = seq.getDatasetSequence().getPDBId().elements();\r
-          while(e.hasMoreElements())\r
+          JMenuItem menuItem;\r
+          if( seq.getDatasetSequence().getPDBId() != null)\r
           {\r
-            final PDBEntry pdb = (PDBEntry)e.nextElement();\r
-\r
-            JMenuItem pdbMenuItem = new JMenuItem();\r
-            pdbMenuItem.setText("View PDB entry: "+pdb.getId());\r
-            pdbMenuItem.addActionListener(new java.awt.event.ActionListener()\r
+            java.util.Enumeration e = seq.getDatasetSequence().getPDBId().\r
+                elements();\r
+            while (e.hasMoreElements())\r
             {\r
+              final PDBEntry pdb = (PDBEntry) e.nextElement();\r
+\r
+              menuItem = new JMenuItem();\r
+              menuItem.setText("View PDB entry: " + pdb.getId());\r
+              menuItem.addActionListener(new java.awt.event.ActionListener()\r
+              {\r
                 public void actionPerformed(ActionEvent e)\r
                 {\r
                   new PDBViewer(pdb, sequence, ap.seqPanel.seqCanvas);\r
                 }\r
+              });\r
+              sequenceMenu.add(menuItem);\r
+            }\r
+          }\r
+\r
+          menuItem = new JMenuItem("Hide Sequences");\r
+          menuItem.addActionListener(new java.awt.event.ActionListener()\r
+              {\r
+                public void actionPerformed(ActionEvent e)\r
+                {\r
+                  hideSequences(false);\r
+                }\r
+              });\r
+          sequenceMenu.add(menuItem);\r
+\r
+          if(ap.av.getSelectionGroup() !=null && ap.av.getSelectionGroup().getSize()>1)\r
+          {\r
+            menuItem = new JMenuItem("Represent Group with " + seq.getName());\r
+            menuItem.addActionListener(new java.awt.event.ActionListener()\r
+            {\r
+              public void actionPerformed(ActionEvent e)\r
+              {\r
+                hideSequences(true);\r
+              }\r
             });\r
-            sequenceMenu.add(pdbMenuItem);\r
+            sequenceMenu.add(menuItem);\r
           }\r
 \r
+\r
         }\r
 \r
+\r
+\r
         SequenceGroup sg = ap.av.getSelectionGroup();\r
 \r
         if (sg != null)\r
@@ -245,6 +275,7 @@ public class PopupMenu extends JPopupMenu
         }\r
     }\r
 \r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -928,4 +959,33 @@ public class PopupMenu extends JPopupMenu
         ex.printStackTrace();\r
       }\r
     }\r
+\r
+    void hideSequences(boolean representGroup)\r
+    {\r
+      SequenceGroup sg = ap.av.getSelectionGroup();\r
+      if(sg==null || sg.getSize()<1)\r
+      {\r
+        ap.av.hideSequence(sequence);\r
+        return;\r
+      }\r
+\r
+        int index = 0;\r
+        while(index < sg.sequences.size())\r
+        {\r
+          if(representGroup && sg.getSequenceAt(index)!=sequence)\r
+          {\r
+            sequence.addHiddenSequence(sg.getSequenceAt(index));\r
+            ap.av.hideSequence(sg.getSequenceAt(index));\r
+          }\r
+          else if(!representGroup)\r
+          {\r
+            ap.av.hideSequence(sg.getSequenceAt(index));\r
+          }\r
+          index ++;\r
+        }\r
+\r
+        ap.av.setSelectionGroup(null);\r
+        refresh();\r
+    }\r
+\r
 }\r