Further structure accessing feature
authorjanengelhardt <engelhardt87@googlemail.com>
Tue, 28 Jun 2011 12:00:27 +0000 (14:00 +0200)
committerjanengelhardt <engelhardt87@googlemail.com>
Mon, 25 Jul 2011 12:58:33 +0000 (14:58 +0200)
Change-Id: Iec6b7f74fad9e7701a2970c3d1287d6c7b595c38

src/jalview/datamodel/AlignmentAnnotation.java
src/jalview/gui/AnnotationLabels.java
src/jalview/gui/AppVarna.java
src/jalview/gui/AppVarnaBinding.java
src/jalview/gui/PopupMenu.java

index 9037008..ad07680 100755 (executable)
@@ -37,7 +37,7 @@ public class AlignmentAnnotation
   public boolean autoCalculated = false;
 
   public String annotationId;
-
+  
   public SequenceI sequenceRef;
 
   /** DOCUMENT ME!! */
@@ -53,6 +53,8 @@ public class AlignmentAnnotation
    * RNA secondary structure contact positions
    */
   public SequenceFeature[] _rnasecstr = null;
+  
+  public String rnaStructure;
 
   /**
    * Updates the _rnasecstr field Determines the positions that base pair and
@@ -64,6 +66,8 @@ public class AlignmentAnnotation
   {
     _rnasecstr = Rna.GetBasePairs(RNAannot);
     Rna.HelixMap(_rnasecstr);
+    
+    setRNAStruc(RNAannot);
 
     if (_rnasecstr != null && _rnasecstr.length > 0)
     {
@@ -73,7 +77,7 @@ public class AlignmentAnnotation
     }
     // System.out.println("featuregroup " + _rnasecstr[0].getFeatureGroup());
   }
-
+  
   public java.util.Hashtable sequenceMapping;
 
   /** DOCUMENT ME!! */
@@ -304,7 +308,15 @@ public class AlignmentAnnotation
     annotationId = this.hashCode() + "";
   }
 
-  /**
+  public void setRNAStruc(String string) {
+       rnaStructure=string;    
+}
+  
+  public String getRNAStruc(){
+         return rnaStructure;
+  }
+
+/**
    * Creates a new AlignmentAnnotation object.
    * 
    * @param label
index 6626016..b8c81ce 100755 (executable)
@@ -58,7 +58,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
   Image image;
 
   AlignmentPanel ap;
-
+  
   AlignViewport av;
 
   boolean resizing = false;
@@ -439,6 +439,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
   public void mouseClicked(MouseEvent evt)
   {
     AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
+        
     if (SwingUtilities.isLeftMouseButton(evt))
     {
       if (selectedRow > -1 && selectedRow < aa.length)
@@ -494,6 +495,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
     JMenuItem item = new JMenuItem(ADDNEW);
     item.addActionListener(this);
     pop.add(item);
+        
     if (selectedRow < 0)
     {
       if (hasHiddenRows)
index be101d0..d1772c7 100644 (file)
@@ -55,25 +55,30 @@ public class AppVarna extends JInternalFrame // implements Runnable,SequenceStru
          initVarna();
   }
   
-  public AppVarna(String seq,String name){
-         vab = new AppVarnaBinding(seq);
+  public AppVarna(String seq,String struc,String name){
+         vab = new AppVarnaBinding(seq,struc);
          name=this.name;
          initVarna();    
   }
   
   public void initVarna(){
+         //TODO: Why is it not possible to include varnaPanel in the AppVarna-Jframe?
          //vab.setFinishedInit(false);
-         varnaPanel=vab.vp;
-         this.getContentPane().add(varnaPanel);
-         jalview.gui.Desktop.addInternalFrame(this,name,getBounds().width, getBounds().height);
+         varnaPanel=vab.get_varnaPanel();
+         //varnaPanel.setVisible(true);
+         //getContentPane().setLayout(new BorderLayout());
+         //getContentPane().add(varnaPanel, BorderLayout.CENTER);
+         //setVisible(true);
+         //jalview.gui.Desktop.addInternalFrame(this,name,getBounds().width, getBounds().height);  
          showPanel(true);
   }
   
   public void showPanel(boolean show){
-         //vab.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-         //vab.pack();
-         //vab.setVisible(show);
-         varnaPanel.setVisible(show);
+         vab.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+         vab.pack();
+         vab.setVisible(show);
+           
+         //varnaPanel.setVisible(show);
   }
   
   private boolean _started = false;
index 389efd1..efc1546 100644 (file)
@@ -130,9 +130,9 @@ public class AppVarnaBinding extends JFrame implements DropTargetListener, Inter
                initVarna(this.DEFAULT_SEQUENCE,this.DEFAULT_STRUCTURE1);
        }
        
-       public AppVarnaBinding(String seq){
+       public AppVarnaBinding(String seq, String struc){
                super("VARNA in Jalview");
-               initVarna(seq,this.DEFAULT_STRUCTURE1);
+               initVarna(seq,struc);
        }
        
        
@@ -140,13 +140,11 @@ public class AppVarnaBinding extends JFrame implements DropTargetListener, Inter
        private void initVarna(String seq, String str){
                DefaultListModel dlm = new DefaultListModel(); 
            
-
                DefaultListSelectionModel m = new DefaultListSelectionModel();
            m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            m.setLeadAnchorNotificationEnabled(false);
            
-           
-               _sideList = new ReorderableJList();
+           _sideList = new ReorderableJList();
                _sideList.setModel(dlm);
                _sideList.addMouseListener(this);
            _sideList.setSelectionModel(m);
index dcf745b..8197688 100644 (file)
@@ -262,7 +262,16 @@ public class PopupMenu extends JPopupMenu
       //TODO: Something to check if it's an RNA
          //like: if(seq.getAnnotation()[0].annotations[0].secondaryStructure == 'S')
          final SequenceI seqI = seq.getDatasetSequence();
-         //ap.getAlignment().get
+         AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
+       
+
+         //for(int i=0; i<aa.length;i++){
+         final String rnastruc=aa[0].getRNAStruc();
+                 if(aa[0]._rnasecstr != null){
+                         System.out.println("Is RNA: "+aa[0].getRNAStruc()+" "+aa.length);
+                         
+                 }             
+         
          menuItem = new JMenuItem();
          menuItem.setText("RNA structure");
       menuItem.addActionListener(new java.awt.event.ActionListener()
@@ -270,11 +279,12 @@ public class PopupMenu extends JPopupMenu
         public void actionPerformed(ActionEvent e)
         {
                System.out.println("Call Varna "+seqI.getSequenceAsString()+" "+seqI.getName());
-               new AppVarna(seqI.getSequenceAsString(),seqI.getName());
+               new AppVarna(seqI.getSequenceAsString(),rnastruc,seqI.getName());
                
         }
-      });
+      });        
       viewStructureMenu.add(menuItem);
+         
       //}