2 VARNA is a tool for the automated drawing, visualization and annotation of the secondary structure of RNA, designed as a companion software for web servers and databases.
3 Copyright (C) 2008 Kevin Darty, Alain Denise and Yann Ponty.
4 electronic mail : Yann.Ponty@lri.fr
5 paper mail : LRI, bat 490 Université Paris-Sud 91405 Orsay Cedex France
7 This file is part of VARNA version 3.1.
8 VARNA version 3.1 is free software: you can redistribute it and/or 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.
11 VARNA version 3.1 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along with VARNA version 3.1.
16 If not, see http://www.gnu.org/licenses.
18 package fr.orsay.lri.varna.views;
20 import java.awt.Color;
21 import java.awt.Dimension;
22 import java.awt.GridLayout;
23 import java.util.ArrayList;
24 import java.util.Hashtable;
26 import javax.swing.JComponent;
27 import javax.swing.JOptionPane;
28 import javax.swing.JPanel;
29 import javax.swing.JScrollPane;
30 import javax.swing.JTable;
31 import javax.swing.event.TableModelEvent;
32 import javax.swing.event.TableModelListener;
35 import fr.orsay.lri.varna.VARNAPanel;
36 import fr.orsay.lri.varna.components.BaseSpecialColorEditor;
37 import fr.orsay.lri.varna.components.BaseTableModel;
38 import fr.orsay.lri.varna.components.ColorRenderer;
39 import fr.orsay.lri.varna.models.BaseList;
40 import fr.orsay.lri.varna.models.rna.ModeleBase;
41 import fr.orsay.lri.varna.models.rna.ModeleBaseNucleotide;
43 public class VueBases extends JPanel {
47 private static final long serialVersionUID = 1L;
52 public final static int KIND_MODE = 1;
56 public final static int ALL_MODE = 2;
58 * for base pairs by king
60 public final static int COUPLE_MODE = 3;
64 private VARNAPanel _vp;
66 private ArrayList<BaseList> data = new ArrayList<BaseList>();
68 private Hashtable<String,BaseList> revdata = new Hashtable<String,BaseList>();
72 private BaseTableModel specialTableModel;
74 public VueBases(VARNAPanel vp, int mode) {
75 super(new GridLayout(1, 0));
95 private BaseList locateOrAddList(String caption)
97 if (!revdata.containsKey(caption))
99 BaseList mbl = new BaseList(caption);
100 revdata.put(caption,mbl);
103 return revdata.get(caption);
106 private void coupleMode() {
108 for (int i = 0; i < _vp.getRNA().get_listeBases().size(); i++) {
110 int j = _vp.getRNA().get_listeBases().get(i).getElementStructure();
112 String tmp1 = (_vp.getRNA().get_listeBases().get(i).getContent());
113 String tmp2 = (_vp.getRNA().get_listeBases().get(j).getContent());
114 pairString = tmp1 +"-"+ tmp2;
115 BaseList bl = locateOrAddList(pairString);
116 bl.addBase(_vp.getRNA().get_listeBases().get(i));
117 bl.addBase(_vp.getRNA().get_listeBases().get(j));
123 private void allMode() {
124 for (int i = 0; i < _vp.getRNA().get_listeBases().size(); i++) {
125 ModeleBase mb = _vp.getRNA().get_listeBases().get(i);
126 BaseList bl = locateOrAddList(""+i);
132 private void kindMode() {
133 for (int i = 0; i < _vp.getRNA().get_listeBases().size(); i++) {
134 ModeleBase mb = _vp.getRNA().get_listeBases().get(i);
135 String tmp1 = (mb.getContent());
136 BaseList bl = locateOrAddList(tmp1);
142 private void createView() {
143 specialTableModel = new BaseTableModel(data);
144 table = new JTable(specialTableModel);
145 table.setPreferredScrollableViewportSize(new Dimension(500, 300));
146 // TODO: Find equivalent in JRE 1.5
147 //table.setFillsViewportHeight(true);
148 // Create the scroll pane and add the table to it.
149 JScrollPane scrollPane = new JScrollPane(table);
151 // Set up renderer and editor for the Favorite Color column.
152 table.setDefaultRenderer(Color.class, new ColorRenderer(true));
153 table.setDefaultEditor(Color.class, new BaseSpecialColorEditor(this));
154 specialTableModel.addTableModelListener(new TableModelListener(){
156 public void tableChanged(TableModelEvent e) {
162 // Add the scroll pane to this panel.
169 * Create the GUI and show it. For thread safety, this method should be
170 * invoked from the event-dispatching thread.
172 public void UIvueBases() {
173 // Create and set up the content pane.
174 JComponent newContentPane = this;
175 newContentPane.setOpaque(true); // content panes must be opaque
177 JOptionPane.showMessageDialog(_vp, newContentPane,
178 "Base Colors Edition", JOptionPane.PLAIN_MESSAGE);
182 public int getMode() {
186 public BaseList getDataAt(int i) {
191 public ArrayList<BaseList> getData() {
195 public VARNAPanel get_vp() {
199 public JTable getTable() {
203 public void setTable(JTable table) {
207 public BaseTableModel getSpecialTableModel() {
208 return specialTableModel;
211 public void setSpecialTableModel(BaseTableModel specialTableModel) {
212 this.specialTableModel = specialTableModel;