+
+
+
+ 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.setModel(dlm);
+ _sideList.addMouseListener(this);
+ _sideList.setSelectionModel(m);
+ _sideList.setPreferredSize(new Dimension(100, 0));
+ _sideList.addListSelectionListener( new ListSelectionListener(){
+ public void valueChanged(ListSelectionEvent arg0) {
+ 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);
+ _seq.setText(sel.rna.getSeq());
+ _str.setText(sel.rna.getStructDBN());
+ }
+ }
+ });
+
+ _rnaList = new BackupHolder(dlm,_sideList);
+ RNA _RNA1 = new RNA("User defined 1");
+
+ try {
+ _vp = new VARNAPanel("0",".");
+ _RNA1.setRNA(seq, str);
+ _RNA1.drawRNARadiate(_vp.getConfig());
+ } catch (ExceptionNonEqualLength 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);
+
+ setBackground(_backgroundColor);
+ _vp.setBackground(_backgroundColor);
+
+ getContentPane().setLayout(new BorderLayout());
+ getContentPane().add(_vp, BorderLayout.CENTER);
+
+ setVisible(true);
+ _vp.addVARNAListener(this);
+ }
+
+ private void RNAPanelDemoInit()
+ {
+ DefaultListModel dlm = new DefaultListModel();
+
+
+ int marginTools = 40;
+
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ m.setLeadAnchorNotificationEnabled(false);
+
+
+ _sideList = new ReorderableJList();
+ _sideList.setModel(dlm);
+ _sideList.addMouseListener(this);
+ _sideList.setSelectionModel(m);
+ _sideList.setPreferredSize(new Dimension(100, 0));
+ _sideList.addListSelectionListener( new ListSelectionListener(){
+ public void valueChanged(ListSelectionEvent arg0) {
+ //System.out.println(arg0);
+ 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);
+ _seq.setText(sel.rna.getSeq());
+ _str.setText(sel.rna.getStructDBN());
+ }
+ }
+ });
+
+ _rnaList = new BackupHolder(dlm,_sideList);
+ RNA _RNA1 = new RNA("User defined 1");
+ RNA _RNA2 = new RNA("User defined 2");
+ try {
+ _vp = new VARNAPanel("0",".");
+ _RNA1.setRNA(DEFAULT_SEQUENCE, DEFAULT_STRUCTURE1);
+ _RNA1.drawRNARadiate(_vp.getConfig());
+ _RNA2.setRNA(DEFAULT_SEQUENCE, DEFAULT_STRUCTURE2);
+ _RNA2.drawRNARadiate(_vp.getConfig());
+ } catch (ExceptionNonEqualLength 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);
+
+ JScrollPane listScroller = new JScrollPane(_sideList);
+ listScroller.setPreferredSize(new Dimension(150, 0));
+
+ setBackground(_backgroundColor);
+ _vp.setBackground(_backgroundColor);
+
+
+ Font textFieldsFont = Font.decode("MonoSpaced-PLAIN-12");
+
+ _seqLabel.setHorizontalTextPosition(JLabel.LEFT);
+ _seqLabel.setPreferredSize(new Dimension(marginTools, 15));
+ _seq.setFont(textFieldsFont);
+ _seq.setText(DEFAULT_SEQUENCE);
+
+ _createButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ try {
+ RNA nRNA = new RNA(generateDefaultName());
+ nRNA.setRNA(_seq.getText(), _str.getText());
+ nRNA.drawRNARadiate(_vp.getConfig());
+ _rnaList.add(new VARNAConfig(),nRNA,true);
+ } catch (ExceptionUnmatchedClosingParentheses e1) {
+ JOptionPane.showMessageDialog(_vp, e1.getMessage(),"Error", JOptionPane.ERROR_MESSAGE);
+ } catch (ExceptionFileFormatOrSyntax e1) {
+ JOptionPane.showMessageDialog(_vp, e1.getMessage(),"Error", JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ });
+
+
+ _seqPanel.setLayout(new BorderLayout());
+ _seqPanel.add(_seqLabel, BorderLayout.WEST);
+ _seqPanel.add(_seq, BorderLayout.CENTER);
+
+ _strLabel.setPreferredSize(new Dimension(marginTools, 15));
+ _strLabel.setHorizontalTextPosition(JLabel.LEFT);
+ _str.setFont(textFieldsFont);
+ _strPanel.setLayout(new BorderLayout());
+ _strPanel.add(_strLabel, BorderLayout.WEST);
+ _strPanel.add(_str, BorderLayout.CENTER);
+
+ _input.setLayout(new GridLayout(2, 0));
+ _input.add(_seqPanel);
+ _input.add(_strPanel);
+
+ JPanel goPanel = new JPanel();
+ goPanel.setLayout(new BorderLayout());
+
+ _tools.setLayout(new BorderLayout());
+ _tools.add(_input, BorderLayout.CENTER);
+ _tools.add(_info, BorderLayout.SOUTH);
+ _tools.add(goPanel, BorderLayout.EAST);
+
+ _deleteButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ _rnaList.removeSelected();
+ }
+ });
+ _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);
+ }});
+
+ JPanel ops = new JPanel();
+ ops.setLayout(new GridLayout(1,2));
+ ops.add(_deleteButton);
+ ops.add(_duplicateButton);
+
+ JLabel j = new JLabel("Structures Manager",JLabel.CENTER);
+ _listPanel.setLayout(new BorderLayout());
+
+ _listPanel.add(ops,BorderLayout.SOUTH);
+ _listPanel.add(j,BorderLayout.NORTH);
+ _listPanel.add(listScroller,BorderLayout.CENTER);
+
+ goPanel.add(_createButton, BorderLayout.CENTER);
+
+ 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);