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.Dimension;
21 import java.awt.FlowLayout;
22 import java.util.ArrayList;
24 import javax.swing.JLabel;
25 import javax.swing.JPanel;
26 import javax.swing.JSlider;
27 import javax.swing.event.ChangeEvent;
28 import javax.swing.event.ChangeListener;
30 import fr.orsay.lri.varna.VARNAPanel;
31 import fr.orsay.lri.varna.controlers.ControleurSliderLabel;
32 import fr.orsay.lri.varna.models.VARNAConfig;
33 import fr.orsay.lri.varna.models.rna.ModeleBP;
35 public class VueBPThickness implements ChangeListener {
37 private VARNAPanel _vp;
38 ArrayList<ModeleBP> _msbp;
39 private JSlider _thicknessSlider;
42 private ArrayList<Double> _backupThicknesses = new ArrayList<Double>();
44 private double FACTOR = 10.0;
46 public VueBPThickness(VARNAPanel vp, ArrayList<ModeleBP> msbp) {
51 _thicknessSlider = new JSlider(JSlider.HORIZONTAL, 1, 100,
52 (int) (msbp.get(0).getStyle().getThickness(
53 VARNAConfig.DEFAULT_BP_THICKNESS) * FACTOR));
54 _thicknessSlider.setMajorTickSpacing(10);
55 _thicknessSlider.setPaintTicks(true);
56 _thicknessSlider.setPaintLabels(false);
57 _thicknessSlider.setPreferredSize(new Dimension(500, 50));
59 JLabel thicknessLabel = new JLabel(String.valueOf(msbp.get(0).getStyle()
60 .getThickness(VARNAConfig.DEFAULT_BP_THICKNESS)));
61 thicknessLabel.setPreferredSize(new Dimension(50, thicknessLabel
62 .getPreferredSize().height));
63 _thicknessSlider.addChangeListener(new ControleurSliderLabel(
64 thicknessLabel, 1.0 / FACTOR));
65 _thicknessSlider.addChangeListener(this);
68 panel.setLayout(new FlowLayout(FlowLayout.LEFT));
70 JLabel labelZ = new JLabel("Thickness:");
73 panel.add(_thicknessSlider);
74 panel.add(thicknessLabel);
77 private void backupThicknesses() {
78 for (int i = 0; i < _msbp.size(); i++) {
79 this._backupThicknesses.add(_msbp.get(i).getStyle().getThickness(
80 VARNAConfig.DEFAULT_BP_THICKNESS));
84 public void restoreThicknesses() {
85 for (int i = 0; i < _msbp.size(); i++) {
86 _msbp.get(i).getStyle().setThickness(_backupThicknesses.get(i));
90 public JPanel getPanel() {
94 public double getThickness() {
95 return (double) _thicknessSlider.getValue() / FACTOR;
98 public VARNAPanel get_vp() {
102 public void stateChanged(ChangeEvent e) {
103 for (int i = 0; i < _msbp.size(); i++) {
104 _msbp.get(i).getStyle().setThickness(
105 ((double) _thicknessSlider.getValue()) / FACTOR);