JAL-1015 new menu items in desktop popup menu for creating annotation report for...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 31 Aug 2012 10:52:27 +0000 (11:52 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 31 Aug 2012 10:52:27 +0000 (11:52 +0100)
src/jalview/gui/PopupMenu.java

index c1bbc8d..4a3fb20 100644 (file)
@@ -84,6 +84,9 @@ public class PopupMenu extends JPopupMenu
   JMenu sequenceMenu = new JMenu();
 
   JMenuItem sequenceName = new JMenuItem();
+  
+  JMenuItem sequenceDetails = new JMenuItem();
+  JMenuItem sequenceSelDetails = new JMenuItem();
 
   SequenceI sequence;
 
@@ -895,6 +898,20 @@ public class PopupMenu extends JPopupMenu
         sequenceName_actionPerformed();
       }
     });
+    sequenceDetails.setText("Sequence Details ...");
+    sequenceDetails.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        sequenceDetails_actionPerformed();
+     }});
+    sequenceSelDetails.setText("Sequence Details ...");
+    sequenceSelDetails.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        sequenceSelectionDetails_actionPerformed();
+     }});    
     PIDColour.setFocusPainted(false);
     unGroupMenuItem.setText("Remove Group");
     unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
@@ -1052,15 +1069,15 @@ public class PopupMenu extends JPopupMenu
         editSequence_actionPerformed(actionEvent);
       }
     });
+    
     /*
      * annotationMenuItem.setText("By Annotation");
      * annotationMenuItem.addActionListener(new ActionListener() { public void
      * actionPerformed(ActionEvent actionEvent) {
      * annotationMenuItem_actionPerformed(actionEvent); } });
      */
-
+    groupMenu.add(sequenceSelDetails);
     add(groupMenu);
-
     add(sequenceMenu);
     this.add(structureMenu);
     groupMenu.add(editMenu);
@@ -1068,6 +1085,7 @@ public class PopupMenu extends JPopupMenu
     groupMenu.add(sequenceFeature);
     groupMenu.add(jMenu1);
     sequenceMenu.add(sequenceName);
+    sequenceMenu.add(sequenceDetails);
     colourMenu.add(textColour);
     colourMenu.add(noColourmenuItem);
     colourMenu.add(clustalColour);
@@ -1262,6 +1280,40 @@ public class PopupMenu extends JPopupMenu
             });
   }
 
+  protected void sequenceSelectionDetails_actionPerformed()
+  {
+    createSequenceDetailsReport(ap.av.getSequenceSelection());
+  }
+
+  protected void sequenceDetails_actionPerformed()
+  {
+    createSequenceDetailsReport(new SequenceI[]{sequence});
+  }
+  public void createSequenceDetailsReport(SequenceI[] sequences)
+  {
+    CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
+    StringBuffer contents = new StringBuffer();
+    for (SequenceI seq:sequences)
+    {
+    contents.append("<p><h2>Annotation for "+seq.getDisplayId(true)+"</h2></p><p>");
+    new SequenceAnnotationReport(null)
+            .createSequenceAnnotationReport(
+                    contents,
+                    seq,
+                    true,
+                    true,false, 
+                    (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
+                            : null);
+    contents.append("</p>");
+    }
+    cap.setText("<html>" + contents.toString() + "</html>");
+    
+    Desktop.instance.addInternalFrame(cap, 
+            "Sequence Details for " + (sequences.length==1 ? sequences[0].getDisplayId(true) : "Selection") 
+, 500, 400);
+    
+  }
+
   protected void showNonconserved_actionPerformed()
   {
     getGroup().setShowNonconserved(displayNonconserved.isSelected());