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.controlers;
20 import java.awt.event.MouseEvent;
21 import java.awt.event.MouseListener;
22 import java.awt.event.MouseMotionListener;
24 import javax.swing.JTable;
26 import fr.orsay.lri.varna.VARNAPanel;
27 import fr.orsay.lri.varna.models.annotations.ChemProbAnnotation;
28 import fr.orsay.lri.varna.models.annotations.HighlightRegionAnnotation;
29 import fr.orsay.lri.varna.models.annotations.TextAnnotation;
30 import fr.orsay.lri.varna.views.VueAnnotation;
31 import fr.orsay.lri.varna.views.VueChemProbAnnotation;
32 import fr.orsay.lri.varna.views.VueHighlightRegionEdit;
36 * Mouse action and motion listener for AnnotationTableModel
38 * @author Darty@lri.fr
41 public class ControleurTableAnnotations implements MouseListener,
43 public static final int REMOVE = 0, EDIT = 1;
44 private JTable _table;
45 private VARNAPanel _vp;
53 * : REMOVE = 0, EDIT = 1
55 public ControleurTableAnnotations(JTable table, VARNAPanel vp, int type) {
61 public void mouseClicked(MouseEvent arg0) {
77 private void remove() {
78 _vp.set_selectedAnnotation(null);
79 Object o = _table.getValueAt(_table.getSelectedRow(), 0);
80 if (o instanceof TextAnnotation) {
81 if (!_vp.removeAnnotation((TextAnnotation) o))
82 _vp.errorDialog(new Exception("Impossible de supprimer"));
83 _table.setValueAt("Deleted!", _table.getSelectedRow(), 0);
85 else if (o instanceof ChemProbAnnotation) {
86 _vp.getRNA().removeChemProbAnnotation((ChemProbAnnotation) o);
87 _table.setValueAt("Deleted!", _table.getSelectedRow(), 0);
89 else if (o instanceof HighlightRegionAnnotation) {
90 _vp.getRNA().removeHighlightRegion((HighlightRegionAnnotation) o);
91 _table.setValueAt("Deleted!", _table.getSelectedRow(), 0);
100 Object o = _table.getValueAt(_table
101 .getSelectedRow(), 0);
102 if (o instanceof TextAnnotation)
104 TextAnnotation textAnnot = (TextAnnotation) o;
105 VueAnnotation vueAnnotation;
106 vueAnnotation = new VueAnnotation(_vp, textAnnot, false);
107 vueAnnotation.show();
108 }else if (o instanceof HighlightRegionAnnotation)
110 HighlightRegionAnnotation annot = (HighlightRegionAnnotation) o;
111 HighlightRegionAnnotation an = annot.clone();
112 VueHighlightRegionEdit vueAnnotation = new VueHighlightRegionEdit(_vp,annot);
113 if (!vueAnnotation.show())
115 annot.setBases(an.getBases());
116 annot.setFillColor(an.getFillColor());
117 annot.setOutlineColor(an.getOutlineColor());
118 annot.setRadius(an.getRadius());
120 }else if (o instanceof ChemProbAnnotation)
122 ChemProbAnnotation annot = (ChemProbAnnotation) o;
123 ChemProbAnnotation an = annot.clone();
124 VueChemProbAnnotation vueAnnotation = new VueChemProbAnnotation(_vp,annot);
125 if (!vueAnnotation.show())
127 annot.setColor(an.getColor());
128 annot.setIntensity(an.getIntensity());
129 annot.setType(an.getType());
130 annot.setOut(an.isOut());
136 public void mouseEntered(MouseEvent arg0) {
139 public void mouseExited(MouseEvent arg0) {
140 _vp.set_selectedAnnotation(null);
144 public void mousePressed(MouseEvent arg0) {
147 public void mouseReleased(MouseEvent arg0) {
150 public void mouseDragged(MouseEvent arg0) {
154 * update selected annotation
156 public void mouseMoved(MouseEvent arg0) {
157 if (_table.rowAtPoint(arg0.getPoint()) < 0)
159 Object o = _table.getValueAt(_table.rowAtPoint(arg0.getPoint()), 0);
160 if (o.getClass().equals(TextAnnotation.class)
161 && o != _vp.get_selectedAnnotation()) {
162 _vp.set_selectedAnnotation((TextAnnotation) o);