Test out new arrangement
authoramwaterhouse <Andrew Waterhouse>
Mon, 23 Apr 2007 11:49:36 +0000 (11:49 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 23 Apr 2007 11:49:36 +0000 (11:49 +0000)
src/jalview/gui/PopupMenu.java

index 45bf5ed..ef87c2f 100755 (executable)
@@ -82,6 +82,9 @@ public class PopupMenu
   JMenuItem sequenceFeature = new JMenuItem();\r
   JMenuItem textColour = new JMenuItem();\r
   JMenu jMenu1 = new JMenu();\r
+  JMenu structureMenu = new JMenu();\r
+  JMenu viewStructureMenu = new JMenu();\r
+  JMenu colStructureMenu = new JMenu();\r
 \r
   /**\r
    * Creates a new PopupMenu object.\r
@@ -155,12 +158,11 @@ public class PopupMenu
           final PDBEntry pdb = (PDBEntry) e.nextElement();\r
 \r
           menuItem = new JMenuItem();\r
-          menuItem.setText("View PDB entry: " + pdb.getId());\r
+          menuItem.setText(pdb.getId());\r
           menuItem.addActionListener(new java.awt.event.ActionListener()\r
           {\r
             public void actionPerformed(ActionEvent e)\r
             {\r
-\r
               Vector seqs = new Vector();\r
               for (int i = 0; i < ap.av.alignment.getHeight(); i++)\r
               {\r
@@ -178,7 +180,6 @@ public class PopupMenu
 \r
                       continue;\r
                   }\r
-\r
                 }\r
               }\r
 \r
@@ -188,7 +189,18 @@ public class PopupMenu
               new AppJMol(pdb, seqs2, ap);\r
             }\r
           });\r
-          sequenceMenu.add(menuItem);\r
+          viewStructureMenu.add(menuItem);\r
+\r
+          menuItem = new JMenuItem();\r
+          menuItem.setText(pdb.getId());\r
+          menuItem.addActionListener(new java.awt.event.ActionListener()\r
+          {\r
+            public void actionPerformed(ActionEvent e)\r
+            {\r
+              colourByStructure(pdb.getId());\r
+            }\r
+          });\r
+          colStructureMenu.add(menuItem);\r
         }\r
       }\r
 \r
@@ -334,7 +346,7 @@ public class PopupMenu
     if (seq == null)\r
     {\r
       sequenceMenu.setVisible(false);\r
-      pdbMenu.setVisible(false);\r
+      structureMenu.setVisible(false);\r
     }\r
 \r
     if (links != null && links.size() > 0)\r
@@ -551,15 +563,19 @@ public class PopupMenu
       }\r
     });\r
     jMenu1.setText("Group");\r
+    structureMenu.setText("Structure");\r
+    viewStructureMenu.setText("View Structure");\r
+    colStructureMenu.setText("Colour By Structure");\r
+\r
     add(groupMenu);\r
 \r
     add(sequenceMenu);\r
+    this.add(structureMenu);\r
     groupMenu.add(editMenu);\r
     groupMenu.add(outputMenu);\r
     groupMenu.add(sequenceFeature);\r
     groupMenu.add(jMenu1);\r
     sequenceMenu.add(sequenceName);\r
-    sequenceMenu.add(pdbMenu);\r
     colourMenu.add(textColour);\r
     colourMenu.add(noColourmenuItem);\r
     colourMenu.add(clustalColour);\r
@@ -613,6 +629,9 @@ public class PopupMenu
     jMenu1.add(showText);\r
     jMenu1.add(showColourText);\r
     jMenu1.add(outline);\r
+    structureMenu.add(pdbMenu);\r
+    structureMenu.add(viewStructureMenu);\r
+    structureMenu.add(colStructureMenu);\r
     noColourmenuItem.setText("None");\r
     noColourmenuItem.addActionListener(new java.awt.event.ActionListener()\r
     {\r
@@ -1319,8 +1338,13 @@ public class PopupMenu
 \r
   public void discoverPDB_actionPerformed()\r
   {\r
-    new jalview.io.DBRefFetcher(\r
-        ap.av.getAlignment(), ap.alignFrame).fetchDBRefs(false);\r
+    SequenceI[] sequences =\r
+         ap.av.selectionGroup == null ?\r
+           new Sequence[]{sequence}\r
+         : ap.av.selectionGroup.getSequencesInOrder(ap.av.alignment);\r
+\r
+    new jalview.io.DBRefFetcher(sequences,\r
+        ap.alignFrame).fetchDBRefs(false);\r
   }\r
 \r
   public void sequenceFeature_actionPerformed()\r
@@ -1360,4 +1384,23 @@ public class PopupMenu
       new TextColourChooser().chooseColour(ap, sg);\r
     }\r
   }\r
+\r
+  public void colourByStructure(String pdbid)\r
+  {\r
+    Annotation [] anots = jalview.structure.StructureSelectionManager.getStructureSelectionManager()\r
+        .colourSequenceFromStructure(sequence, pdbid);\r
+\r
+    AlignmentAnnotation an = new AlignmentAnnotation(\r
+      "Structure", "Coloured by "+pdbid, anots);\r
+\r
+    ap.av.alignment.addAnnotation(an);\r
+    an.createSequenceMapping(sequence, 0, true);\r
+    //an.adjustForAlignment();\r
+    ap.av.alignment.setAnnotationIndex(an,0);\r
+\r
+    ap.adjustAnnotationHeight();\r
+\r
+    sequence.addAlignmentAnnotation(an);\r
+\r
+    }\r
 }\r