Reorganize the class structure, unfortunately breaks the VARNA-Frame
[jalview.git] / src / jalview / gui / AppVarna.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
3  * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
10  * 
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 package jalview.gui;
19
20 import java.util.*;
21 import java.awt.*;
22 import javax.swing.*;
23 import javax.swing.event.*;
24
25 import java.awt.event.*;
26 import java.io.*;
27
28 import jalview.api.SequenceStructureBinding;
29 import jalview.bin.Cache;
30 import jalview.datamodel.*;
31 import jalview.gui.ViewSelectionMenu.ViewSetProvider;
32 import jalview.structure.*;
33 import jalview.io.*;
34 import jalview.schemes.*;
35 import fr.orsay.lri.varna.VARNAPanel;
36 import fr.orsay.lri.varna.exceptions.ExceptionFileFormatOrSyntax;
37 import fr.orsay.lri.varna.exceptions.ExceptionNonEqualLength;
38 import fr.orsay.lri.varna.exceptions.ExceptionUnmatchedClosingParentheses;
39 import fr.orsay.lri.varna.interfaces.InterfaceVARNAListener;
40 import fr.orsay.lri.varna.models.VARNAConfig;
41 import fr.orsay.lri.varna.models.rna.RNA;
42
43
44 public class AppVarna extends JInternalFrame implements InterfaceVARNAListener// implements Runnable,SequenceStructureBinding, ViewSetProvider
45
46 {
47   AppVarnaBinding vab;
48
49   VARNAPanel varnaPanel;
50   
51   String name;
52
53   //JSplitPane splitPane;
54
55   //RenderPanel renderPanel;
56
57   //AlignmentPanel ap;
58
59   //Vector atomsPicked = new Vector();
60   
61   /*public AppVarna(){
62           vab = new AppVarnaBinding(); 
63           initVarna();
64   }*/
65   
66   public AppVarna(String seq,String struc,String name){
67           ArrayList<RNA> rnaList = new ArrayList<RNA>();
68           RNA rna1 = new RNA(name);
69           try {
70                   rna1.setRNA(seq,struc);
71          } catch (ExceptionUnmatchedClosingParentheses e2) {
72                 e2.printStackTrace();
73           } catch (ExceptionFileFormatOrSyntax e3) {
74                 e3.printStackTrace();
75           }
76           rnaList.add(rna1);
77           
78           //vab = new AppVarnaBinding(rnaList);
79           vab = new AppVarnaBinding(seq,struc);
80           name=this.name;
81           initVarna();    
82   }
83   
84   public void initVarna(){
85           //TODO: Why is it not possible to include varnaPanel in the AppVarna-Jframe?
86           //vab.setFinishedInit(false);
87           varnaPanel=vab.get_varnaPanel();
88           setBackground(Color.white);
89           System.out.println("vp: "+vab.get_varnaPanel().getName());
90           //varnaPanel.setVisible(true);
91           getContentPane().setLayout(new BorderLayout());
92           getContentPane().add(varnaPanel, BorderLayout.CENTER);
93           setVisible(true);
94           varnaPanel.addVARNAListener(this);
95           jalview.gui.Desktop.addInternalFrame(this,name,getBounds().width, getBounds().height);  
96           //showPanel(true);
97   }
98   
99   public void showPanel(boolean show){
100           //vab.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
101           //vab.pack();
102           //vab.setVisible(show);
103             
104           varnaPanel.setVisible(show);
105   }
106   
107   private boolean _started = false;
108
109   public void run(){
110           _started = true;
111           
112           try
113       {
114         initVarna();
115       } catch (OutOfMemoryError oomerror)
116       {
117         new OOMWarning("When trying to open the Varna viewer!", oomerror);
118       } catch (Exception ex)
119       {
120         Cache.log.error("Couldn't open Varna viewer!", ex);
121       }
122   }
123
124 @Override
125 public void onLayoutChanged() {
126         // TODO Auto-generated method stub
127         
128 }
129
130 @Override
131 public void onUINewStructure(VARNAConfig v, RNA r) {
132         //TODO _rnaList.add(v, r,"",true);
133         // TODO Auto-generated method stub
134         
135 }
136
137 @Override
138 public void onWarningEmitted(String s) {
139         // TODO Auto-generated method stub
140         
141 }
142   
143
144 }