/*
* Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
* Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Jalview. If not, see .
*/
package jalview.gui;
import java.util.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.io.*;
import jalview.api.SequenceStructureBinding;
import jalview.bin.Cache;
import jalview.datamodel.*;
import jalview.gui.ViewSelectionMenu.ViewSetProvider;
import jalview.structure.*;
import jalview.io.*;
import jalview.schemes.*;
import fr.orsay.lri.varna.VARNAPanel;
import fr.orsay.lri.varna.exceptions.ExceptionFileFormatOrSyntax;
import fr.orsay.lri.varna.exceptions.ExceptionNonEqualLength;
import fr.orsay.lri.varna.exceptions.ExceptionUnmatchedClosingParentheses;
import fr.orsay.lri.varna.interfaces.InterfaceVARNAListener;
import fr.orsay.lri.varna.models.VARNAConfig;
import fr.orsay.lri.varna.models.rna.RNA;
public class AppVarna extends JInternalFrame implements InterfaceVARNAListener// implements Runnable,SequenceStructureBinding, ViewSetProvider
{
AppVarnaBinding vab;
VARNAPanel varnaPanel;
String name;
/*public AppVarna(){
vab = new AppVarnaBinding();
initVarna();
}*/
public AppVarna(String seq,String struc,String name){
ArrayList rnaList = new ArrayList();
RNA rna1 = new RNA(name);
try {
rna1.setRNA(seq,struc);
} catch (ExceptionUnmatchedClosingParentheses e2) {
e2.printStackTrace();
} catch (ExceptionFileFormatOrSyntax e3) {
e3.printStackTrace();
}
rnaList.add(rna1);
vab = new AppVarnaBinding(rnaList);
//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.get_varnaPanel();
setBackground(Color.white);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(varnaPanel, BorderLayout.CENTER);
varnaPanel.addVARNAListener(this);
jalview.gui.Desktop.addInternalFrame(this,name,getBounds().width, getBounds().height);
this.pack();
this.setVisible(true);
//showPanel(true);
}
public void showPanel(boolean show){
varnaPanel.setVisible(show);
}
private boolean _started = false;
public void run(){
_started = true;
try
{
initVarna();
} catch (OutOfMemoryError oomerror)
{
new OOMWarning("When trying to open the Varna viewer!", oomerror);
} catch (Exception ex)
{
Cache.log.error("Couldn't open Varna viewer!", ex);
}
}
@Override
public void onLayoutChanged() {
// TODO Auto-generated method stub
}
@Override
public void onUINewStructure(VARNAConfig v, RNA r) {
//TODO _rnaList.add(v, r,"",true);
// TODO Auto-generated method stub
}
@Override
public void onWarningEmitted(String s) {
// TODO Auto-generated method stub
}
}