jal-842; sequence transmitting to Varna included
authorjanengelhardt <engelhardt87@googlemail.com>
Wed, 22 Jun 2011 23:18:00 +0000 (01:18 +0200)
committerjanengelhardt <engelhardt87@googlemail.com>
Mon, 25 Jul 2011 12:58:33 +0000 (14:58 +0200)
Change-Id: Icaeb82a75040a5854658f1d77c6dd9bc57c1a36f

src/jalview/gui/AppVarna.java
src/jalview/gui/AppVarnaBinding.java
src/jalview/gui/PopupMenu.java

index d0173d0..19b19cd 100644 (file)
@@ -38,31 +38,39 @@ public class AppVarna extends JInternalFrame // implements Runnable,SequenceStru
 {
   AppVarnaBinding vab;
 
-  JPanel scriptWindow;
+  JPanel varnaPanel;
 
-  JSplitPane splitPane;
+  //JSplitPane splitPane;
 
   //RenderPanel renderPanel;
 
-  AlignmentPanel ap;
+  //AlignmentPanel ap;
 
-  Vector atomsPicked = new Vector();
+  //Vector atomsPicked = new Vector();
   
   public AppVarna(){
+         vab = new AppVarnaBinding(); 
          initVarna();
   }
   
+  public AppVarna(String seq){
+         vab = new AppVarnaBinding(seq);
+         initVarna();    
+  }
+  
   public void initVarna(){
          //vab.setFinishedInit(false);
-         //renderPanel = new RenderPanel();
-         // TODO: consider waiting until the structure/view is fully loaded before
-         // displaying
-         //this.getContentPane().add(renderPanel, java.awt.BorderLayout.CENTER);
-         //jalview.gui.Desktop.addInternalFrame(this,"test",300,300);
-         AppVarnaBinding d = new AppVarnaBinding();
-         d.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-         d.pack();
-         d.setVisible(true);
+         varnaPanel=vab.vp;
+         this.getContentPane().add(varnaPanel);
+         jalview.gui.Desktop.addInternalFrame(this,"test",200,200);
+         showPanel(true);
+  }
+  
+  public void showPanel(boolean show){
+         //vab.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+         //vab.pack();
+         //vab.setVisible(show);
+         varnaPanel.setVisible(show);
   }
   
   private boolean _started = false;
index ac9a880..389efd1 100644 (file)
@@ -87,7 +87,7 @@ public class AppVarnaBinding extends JFrame implements DropTargetListener, Inter
        // private static final String DEFAULT_STRUCTURE2 =
        // "((((..(((....)))..))))";
 
-       private VARNAPanel _vp;
+       public VARNAPanel vp;
 
        private JPanel _tools = new JPanel();
        private JPanel _input = new JPanel();
@@ -130,6 +130,11 @@ public class AppVarnaBinding extends JFrame implements DropTargetListener, Inter
                initVarna(this.DEFAULT_SEQUENCE,this.DEFAULT_STRUCTURE1);
        }
        
+       public AppVarnaBinding(String seq){
+               super("VARNA in Jalview");
+               initVarna(seq,this.DEFAULT_STRUCTURE1);
+       }
+       
        
        
        private void initVarna(String seq, String str){
@@ -151,8 +156,8 @@ public class AppVarnaBinding extends JFrame implements DropTargetListener, Inter
                                if (!_sideList.isSelectionEmpty() && !arg0.getValueIsAdjusting())
                                {
                                        FullBackup  sel = (FullBackup) _sideList.getSelectedValue();
-                                       Mapping map = Mapping.DefaultOutermostMapping(_vp.getRNA().getSize(), sel.rna.getSize());
-                                       _vp.showRNAInterpolated(sel.rna,sel.config,map);
+                                       Mapping map = Mapping.DefaultOutermostMapping(vp.getRNA().getSize(), sel.rna.getSize());
+                                       vp.showRNAInterpolated(sel.rna,sel.config,map);
                                        _seq.setText(sel.rna.getSeq());
                                        _str.setText(sel.rna.getStructDBN());
                                }
@@ -163,27 +168,27 @@ public class AppVarnaBinding extends JFrame implements DropTargetListener, Inter
                RNA _RNA1 = new RNA("User defined 1");
                
                try {
-                       _vp = new VARNAPanel("0",".");
+                       vp = new VARNAPanel("0",".");
                        _RNA1.setRNA(seq, str);
-                       _RNA1.drawRNARadiate(_vp.getConfig());
+                       _RNA1.drawRNARadiate(vp.getConfig());
                } catch (ExceptionNonEqualLength e) {
-                       _vp.errorDialog(e);
+                       vp.errorDialog(e);
                } catch (ExceptionUnmatchedClosingParentheses e2) {
                e2.printStackTrace();
                } catch (ExceptionFileFormatOrSyntax e3) {
                e3.printStackTrace();
                }
-               _vp.setPreferredSize(new Dimension(400, 400));
-               _rnaList.add(_vp.getConfig().clone(),_RNA1,generateDefaultName(),true);
+               vp.setPreferredSize(new Dimension(400, 400));
+               _rnaList.add(vp.getConfig().clone(),_RNA1,generateDefaultName(),true);
 
                setBackground(_backgroundColor);
-               _vp.setBackground(_backgroundColor);
+               vp.setBackground(_backgroundColor);
 
                getContentPane().setLayout(new BorderLayout());
-               getContentPane().add(_vp, BorderLayout.CENTER);
+               getContentPane().add(vp, BorderLayout.CENTER);
 
                setVisible(true);
-               _vp.addVARNAListener(this);
+               vp.addVARNAListener(this);
        }
 
        private void RNAPanelDemoInit() 
@@ -209,8 +214,8 @@ public class AppVarnaBinding extends JFrame implements DropTargetListener, Inter
                                if (!_sideList.isSelectionEmpty() && !arg0.getValueIsAdjusting())
                                {
                                        FullBackup  sel = (FullBackup) _sideList.getSelectedValue();
-                                       Mapping map = Mapping.DefaultOutermostMapping(_vp.getRNA().getSize(), sel.rna.getSize());
-                                       _vp.showRNAInterpolated(sel.rna,sel.config,map);
+                                       Mapping map = Mapping.DefaultOutermostMapping(vp.getRNA().getSize(), sel.rna.getSize());
+                                       vp.showRNAInterpolated(sel.rna,sel.config,map);
                                        _seq.setText(sel.rna.getSeq());
                                        _str.setText(sel.rna.getStructDBN());
                                }
@@ -221,27 +226,27 @@ public class AppVarnaBinding extends JFrame implements DropTargetListener, Inter
                RNA _RNA1 = new RNA("User defined 1");
                RNA _RNA2 = new RNA("User defined 2");
                try {
-                       _vp = new VARNAPanel("0",".");
+                       vp = new VARNAPanel("0",".");
                        _RNA1.setRNA(DEFAULT_SEQUENCE, DEFAULT_STRUCTURE1);
-                       _RNA1.drawRNARadiate(_vp.getConfig());
+                       _RNA1.drawRNARadiate(vp.getConfig());
                        _RNA2.setRNA(DEFAULT_SEQUENCE, DEFAULT_STRUCTURE2);
-                       _RNA2.drawRNARadiate(_vp.getConfig());
+                       _RNA2.drawRNARadiate(vp.getConfig());
                } catch (ExceptionNonEqualLength e) {
-                       _vp.errorDialog(e);
+                       vp.errorDialog(e);
                } catch (ExceptionUnmatchedClosingParentheses e2) {
                e2.printStackTrace();
                } catch (ExceptionFileFormatOrSyntax e3) {
                e3.printStackTrace();
                }
-               _vp.setPreferredSize(new Dimension(400, 400));
-           _rnaList.add(_vp.getConfig().clone(),_RNA2,generateDefaultName());
-           _rnaList.add(_vp.getConfig().clone(),_RNA1,generateDefaultName(),true);
+               vp.setPreferredSize(new Dimension(400, 400));
+           _rnaList.add(vp.getConfig().clone(),_RNA2,generateDefaultName());
+           _rnaList.add(vp.getConfig().clone(),_RNA1,generateDefaultName(),true);
 
            JScrollPane listScroller = new JScrollPane(_sideList);
            listScroller.setPreferredSize(new Dimension(150, 0));
 
                setBackground(_backgroundColor);
-               _vp.setBackground(_backgroundColor);
+               vp.setBackground(_backgroundColor);
 
 
                Font textFieldsFont = Font.decode("MonoSpaced-PLAIN-12");
@@ -256,12 +261,12 @@ public class AppVarnaBinding extends JFrame implements DropTargetListener, Inter
                                try {
                                RNA nRNA = new RNA(generateDefaultName());
                                nRNA.setRNA(_seq.getText(), _str.getText());
-                               nRNA.drawRNARadiate(_vp.getConfig());
+                               nRNA.drawRNARadiate(vp.getConfig());
                                _rnaList.add(new VARNAConfig(),nRNA,true);
                                } catch (ExceptionUnmatchedClosingParentheses e1) {
-                                       JOptionPane.showMessageDialog(_vp, e1.getMessage(),"Error", JOptionPane.ERROR_MESSAGE);
+                                       JOptionPane.showMessageDialog(vp, e1.getMessage(),"Error", JOptionPane.ERROR_MESSAGE);
                                } catch (ExceptionFileFormatOrSyntax e1) {
-                                       JOptionPane.showMessageDialog(_vp, e1.getMessage(),"Error", JOptionPane.ERROR_MESSAGE);
+                                       JOptionPane.showMessageDialog(vp, e1.getMessage(),"Error", JOptionPane.ERROR_MESSAGE);
                                }
                        }
                });
@@ -297,7 +302,7 @@ public class AppVarnaBinding extends JFrame implements DropTargetListener, Inter
                });
                _duplicateButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
-                                       _rnaList.add((VARNAConfig)_vp.getConfig().clone(),_vp.getRNA().clone(),_vp.getRNA().getName()+"-"+DateFormat.getTimeInstance(DateFormat.LONG).format(new Date()),true); 
+                                       _rnaList.add((VARNAConfig)vp.getConfig().clone(),vp.getRNA().clone(),vp.getRNA().getName()+"-"+DateFormat.getTimeInstance(DateFormat.LONG).format(new Date()),true); 
                        }});
                
                JPanel ops = new JPanel();
@@ -314,15 +319,15 @@ public class AppVarnaBinding extends JFrame implements DropTargetListener, Inter
 
                goPanel.add(_createButton, BorderLayout.CENTER);
 
-               JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,_listPanel,_vp);
+               JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,_listPanel,vp);
                getContentPane().setLayout(new BorderLayout());
                getContentPane().add(split, BorderLayout.CENTER);
                getContentPane().add(_tools, BorderLayout.NORTH);
 
                setVisible(true);
-               DropTarget dt = new DropTarget(_vp, this);
+               DropTarget dt = new DropTarget(vp, this);
                
-               _vp.addVARNAListener(this);
+               vp.addVARNAListener(this);
        }
        
        public static String generateDefaultName()
@@ -347,7 +352,7 @@ public class AppVarnaBinding extends JFrame implements DropTargetListener, Inter
        }
 
        public void init() {
-               _vp.setBackground(_backgroundColor);
+               vp.setBackground(_backgroundColor);
                _error = true;
        }
 
@@ -367,11 +372,11 @@ public class AppVarnaBinding extends JFrame implements DropTargetListener, Inter
        }
 
        public VARNAPanel get_varnaPanel() {
-               return _vp;
+               return vp;
        }
 
        public void set_varnaPanel(VARNAPanel surface) {
-               _vp = surface;
+               vp = surface;
        }
 
 
@@ -559,8 +564,8 @@ public class AppVarnaBinding extends JFrame implements DropTargetListener, Inter
                                  } catch (ExceptionUnmatchedClosingParentheses e1) {
                                  } catch (ExceptionFileFormatOrSyntax e1) {
                                  }
-                                 _vp.showRNA(r);
-                                 _vp.repaint();
+                                 vp.showRNA(r);
+                                 vp.repaint();
                          }
                          else
                          {  
index a2b4ee3..7db6c23 100644 (file)
@@ -256,14 +256,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();
+
          menuItem = new JMenuItem();
          menuItem.setText("RNA structure");
           menuItem.addActionListener(new java.awt.event.ActionListener()
           {
             public void actionPerformed(ActionEvent e)
             {
-               System.out.println("Call Varna");
-               new AppVarna();
+               System.out.println("Call Varna "+seqI.getSequenceAsString());
+               new AppVarna(seqI.getSequenceAsString());
                
             }
           });