JAL-3032 adds Java 8 functionality (2/2)
[jalview.git] / src2 / fr / orsay / lri / varna / views / VueBPType.java
1 /*
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
6
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.
10
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.
14
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.
17  */
18 package fr.orsay.lri.varna.views;
19
20 import java.awt.FlowLayout;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23
24 import javax.swing.JComboBox;
25 import javax.swing.JLabel;
26 import javax.swing.JPanel;
27
28 import fr.orsay.lri.varna.VARNAPanel;
29 import fr.orsay.lri.varna.models.rna.ModeleBP;
30
31
32 public class VueBPType implements ActionListener {
33
34         private VARNAPanel _vp;
35         ModeleBP _msbp;
36         private JComboBox _edge5;
37         private JComboBox _edge3;
38         private JComboBox _stericity;
39         private JPanel panel;
40
41         public VueBPType(VARNAPanel vp, ModeleBP msbp) {
42                 _vp = vp;
43                 _msbp = msbp;
44
45                 ModeleBP.Edge[] edges = ModeleBP.Edge.values();
46                 ModeleBP.Edge bck = msbp.getEdgePartner5();
47                 _edge5 = new JComboBox(edges);
48                 for (int i = 0; i < edges.length; i++) {
49                         if (edges[i] == bck)
50                                 _edge5.setSelectedIndex(i);
51                 }
52
53                 bck = msbp.getEdgePartner3();
54                 _edge3 = new JComboBox(edges);
55                 for (int i = 0; i < edges.length; i++) {
56                         if (edges[i] == bck)
57                                 _edge3.setSelectedIndex(i);
58                 }
59
60                 ModeleBP.Stericity[] sters = ModeleBP.Stericity.values();
61                 ModeleBP.Stericity bcks = msbp.getStericity();
62                 _stericity = new JComboBox(sters);
63                 for (int i = 0; i < sters.length; i++) {
64                         if (sters[i] == bcks)
65                                 _stericity.setSelectedIndex(i);
66                 }
67
68                 _edge5.addActionListener(this);
69                 _edge3.addActionListener(this);
70                 _stericity.addActionListener(this);
71
72                 panel = new JPanel();
73                 panel.setLayout(new FlowLayout(FlowLayout.LEFT));
74
75                 JLabel label5 = new JLabel("5' edge: ");
76                 JLabel label3 = new JLabel("3' edge: ");
77                 JLabel labelS = new JLabel("Stericity: ");
78
79                 panel.add(label5);
80                 panel.add(_edge5);
81                 panel.add(label3);
82                 panel.add(_edge3);
83                 panel.add(labelS);
84                 panel.add(_stericity);
85         }
86
87         public JPanel getPanel() {
88                 return panel;
89         }
90
91         public ModeleBP.Edge getEdge5() {
92                 return (ModeleBP.Edge) _edge5.getSelectedItem();
93         }
94
95         public ModeleBP.Edge getEdge3() {
96                 return (ModeleBP.Edge) _edge3.getSelectedItem();
97         }
98
99         public ModeleBP.Stericity getStericity() {
100                 return (ModeleBP.Stericity) _stericity.getSelectedItem();
101         }
102
103         public VARNAPanel get_vp() {
104                 return _vp;
105         }
106
107         public void actionPerformed(ActionEvent e) {
108                 _msbp.setEdge5(getEdge5());
109                 _msbp.setEdge3(getEdge3());
110                 _msbp.setStericity(getStericity());
111                 _vp.repaint();
112         }
113
114 }