JAL-3026 srcjar files for VARNA and log4j
[jalview.git] / srcjar / fr / orsay / lri / varna / views / VueBorder.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.Dimension;
21 import java.awt.FlowLayout;
22 import java.awt.GridLayout;
23
24 import javax.swing.JLabel;
25 import javax.swing.JPanel;
26 import javax.swing.JSlider;
27
28
29 import fr.orsay.lri.varna.VARNAPanel;
30 import fr.orsay.lri.varna.controlers.ControleurBorder;
31 import fr.orsay.lri.varna.controlers.ControleurSliderLabel;
32
33 public class VueBorder {
34
35         private VARNAPanel _vp;
36         private JSlider borderHeightSlider, borderWidthSlider;
37         private JPanel panel;
38
39         public VueBorder(VARNAPanel vp) {
40                 _vp = vp;
41
42                 JPanel pup = new JPanel();
43                 JPanel pdown = new JPanel();
44                 panel = new JPanel();
45                 panel.setLayout(new GridLayout(2, 1));
46                 pup.setLayout(new FlowLayout(FlowLayout.LEFT));
47                 pdown.setLayout(new FlowLayout(FlowLayout.LEFT));
48
49                 borderHeightSlider = new JSlider(JSlider.HORIZONTAL, 0,
50                                 _vp.getHeight() / 2 - 10, _vp.getBorderSize().height);
51                 // Turn on labels at major tick marks.
52                 borderHeightSlider.setMajorTickSpacing(50);
53                 borderHeightSlider.setMinorTickSpacing(10);
54                 borderHeightSlider.setPaintTicks(true);
55                 borderHeightSlider.setPaintLabels(true);
56                 JLabel borderHeightLabel = new JLabel(String.valueOf(_vp
57                                 .getBorderSize().height));
58                 borderHeightLabel.setPreferredSize(new Dimension(50, borderHeightLabel
59                                 .getPreferredSize().height));
60                 borderHeightSlider.addChangeListener(new ControleurSliderLabel(
61                                 borderHeightLabel, false));
62                 borderHeightSlider.addChangeListener(new ControleurBorder(this));
63
64                 borderWidthSlider = new JSlider(JSlider.HORIZONTAL, 0,
65                                 _vp.getWidth() / 2 - 10, _vp.getBorderSize().width);
66                 // Turn on labels at major tick marks.
67                 borderWidthSlider.setMajorTickSpacing(50);
68                 borderWidthSlider.setMinorTickSpacing(10);
69                 borderWidthSlider.setPaintTicks(true);
70                 borderWidthSlider.setPaintLabels(true);
71                 JLabel borderWidthLabel = new JLabel(String
72                                 .valueOf(_vp.getBorderSize().width));
73                 borderWidthLabel.setPreferredSize(new Dimension(50, borderWidthLabel
74                                 .getPreferredSize().height));
75                 borderWidthSlider.addChangeListener(new ControleurSliderLabel(
76                                 borderWidthLabel, false));
77                 borderWidthSlider.addChangeListener(new ControleurBorder(this));
78
79                 JLabel labelW = new JLabel("Width:");
80                 JLabel labelH = new JLabel("Height:");
81
82                 pup.add(labelW);
83                 pup.add(borderWidthSlider);
84                 pup.add(borderWidthLabel);
85
86                 pdown.add(labelH);
87                 pdown.add(borderHeightSlider);
88                 pdown.add(borderHeightLabel);
89
90                 panel.add(pup);
91                 panel.add(pdown);
92         }
93
94         public JPanel getPanel() {
95                 return panel;
96         }
97
98         public Dimension getDimension() {
99                 return new Dimension(borderWidthSlider.getValue(), borderHeightSlider
100                                 .getValue());
101         }
102
103         public int getHeight() {
104                 return borderHeightSlider.getValue();
105         }
106
107         public int getWidth() {
108                 return borderWidthSlider.getValue();
109         }
110
111         public VARNAPanel get_vp() {
112                 return _vp;
113         }
114 }