JAL-1015 equivalent menu items for applet - not visible at moment (need solution...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 31 Aug 2012 10:53:21 +0000 (11:53 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 31 Aug 2012 10:53:21 +0000 (11:53 +0100)
src/jalview/appletgui/APopupMenu.java

index acdae46..fe1700b 100755 (executable)
@@ -28,6 +28,7 @@ import jalview.datamodel.*;
 import jalview.schemes.*;
 import jalview.util.UrlLink;
 import jalview.io.AppletFormatAdapter;
+import jalview.io.SequenceAnnotationReport;
 
 public class APopupMenu extends java.awt.PopupMenu implements
         ActionListener, ItemListener
@@ -107,7 +108,11 @@ public class APopupMenu extends java.awt.PopupMenu implements
   MenuItem sequenceFeature = new MenuItem("Create Sequence Feature");
 
   MenuItem editSequence = new MenuItem("Edit Sequence");
+  
+  MenuItem sequenceDetails = new MenuItem("Sequence Details ...");
 
+  MenuItem selSeqDetails = new MenuItem("Sequence Details ...");
+  
   Sequence seq;
 
   MenuItem revealAll = new MenuItem();
@@ -450,6 +455,14 @@ public class APopupMenu extends java.awt.PopupMenu implements
     {
       editName();
     }
+    else if (source == sequenceDetails)
+    {
+      showSequenceDetails();
+    }
+    else if (source == selSeqDetails)
+    {
+      showSequenceSelectionDetails();
+    }
     else if (source == pdb)
     {
       addPDB();
@@ -608,6 +621,7 @@ public class APopupMenu extends java.awt.PopupMenu implements
 
   }
 
+
   void outputText(ActionEvent e)
   {
     CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame);
@@ -625,6 +639,41 @@ public class APopupMenu extends java.awt.PopupMenu implements
             ap.av.showJVSuffix));
 
   }
+  protected void showSequenceSelectionDetails()
+  {
+    createSequenceDetailsReport(ap.av.getSequenceSelection());
+  }
+
+  protected void showSequenceDetails()
+  {
+    createSequenceDetailsReport(new SequenceI[]{seq});
+  }
+  public void createSequenceDetailsReport(SequenceI[] sequences)
+  {
+
+    CutAndPasteTransfer cap = new CutAndPasteTransfer(false, ap.alignFrame);
+    
+    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>");
+    }
+    Frame frame = new Frame();
+    frame.add(cap);
+    jalview.bin.JalviewLite.addFrame(frame,
+            "Sequence Details for " + (sequences.length==1 ? sequences[0].getDisplayId(true) : "Selection")
+            , 600, 500);
+    cap.setText("<html>" + contents.toString() + "</html>");
+  }
 
   void editName()
   {
@@ -685,6 +734,8 @@ public class APopupMenu extends java.awt.PopupMenu implements
     showBoxes.setState(true);
     showBoxes.addItemListener(this);
     sequenceName.addActionListener(this);
+    sequenceDetails.addActionListener(this);
+    selSeqDetails.addActionListener(this);
     displayNonconserved.setLabel("Show Nonconserved");
     displayNonconserved.setState(false);
     displayNonconserved.addItemListener(this);
@@ -705,6 +756,7 @@ public class APopupMenu extends java.awt.PopupMenu implements
     this.add(hideSeqs);
     this.add(revealSeq);
     this.add(revealAll);
+    // groupMenu.add(selSeqDetails);
     groupMenu.add(editGroupName);
     groupMenu.add(editMenu);
     groupMenu.add(outputmenu);
@@ -771,6 +823,8 @@ public class APopupMenu extends java.awt.PopupMenu implements
     toLower.addActionListener(this);
     editMenu.add(toggleCase);
     seqMenu.add(sequenceName);
+    // seqMenu.add(sequenceDetails);
+    
     if (!ap.av.applet.useXtrnalSviewer)
     {
       seqMenu.add(pdb);