Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/* ScoreChanger.java
*
* created: Thu Oct 21 1999
*
* This file is part of Artemis
*
* Copyright (C) 1999 Genome Research Limited
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/ScoreChanger.java,v 1.1 2004-06-09 09:47:29 tjc Exp $
*/
package uk.ac.sanger.artemis.components;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* This is a JFrame component that contains ScoreScrollbar components.
*
* @author Kim Rutherford
* @version $Id: ScoreChanger.java,v 1.1 2004-06-09 09:47:29 tjc Exp $
**/
public class ScoreChanger extends JFrame {
/**
* Create a new ScoreChanger.
* @param minimum_value The minimum allowable value for the scroll bars.
* @param maximum_value The maximum allowable value for the scroll bars.
**/
public ScoreChanger (final String name,
final ScoreChangeListener minimum_listener,
final ScoreChangeListener maximum_listener,
final int minimum_value, final int maximum_value)
throws IllegalArgumentException {
super (name);
this.minimum_listener = minimum_listener;
this.maximum_listener = maximum_listener;
this.minimum_value = minimum_value;
this.maximum_value = maximum_value;
getContentPane ().setLayout (new GridLayout (5, 1));
minimum_label = new JLabel ();
getContentPane ().add (minimum_label);
minimum_score_scrollbar =
new ScoreScrollbar (minimum_value, maximum_value);
final ScoreChangeListener this_minimum_listener =
new ScoreChangeListener () {
public void scoreChanged (ScoreChangeEvent event) {
minimum_label.setText ("Minimum Cutoff: " + event.getValue ());
}
};
minimum_score_scrollbar.addScoreChangeListener (this_minimum_listener);
getContentPane ().add (minimum_score_scrollbar);
maximum_label = new JLabel ();
getContentPane ().add (maximum_label);
maximum_score_scrollbar =
new ScoreScrollbar (minimum_value, maximum_value);
final ScoreChangeListener this_maximum_listener =
new ScoreChangeListener () {
public void scoreChanged (ScoreChangeEvent event) {
maximum_label.setText ("Maximum Cutoff: " + event.getValue ());
}
};
maximum_score_scrollbar.addScoreChangeListener (this_maximum_listener);
getContentPane ().add (maximum_score_scrollbar);
final FlowLayout flow_layout =
new FlowLayout (FlowLayout.CENTER, 18, 0);
final JPanel button_panel = new JPanel (flow_layout);
final JButton reset_button = new JButton ("Reset");
reset_button.addActionListener (new ActionListener () {
public void actionPerformed (ActionEvent e) {
reset ();
}
});
button_panel.add (reset_button);
final JButton close_button = new JButton ("Close");
close_button.addActionListener (new ActionListener () {
public void actionPerformed (ActionEvent e) {
dispose ();
}
});
button_panel.add (close_button);
getContentPane ().add (button_panel);
addWindowListener (new WindowAdapter () {
public void windowClosing (WindowEvent event) {
dispose ();
}
});
pack ();
setSize (270, getSize ().height);
final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
setLocation (new Point ((screen.width - getSize ().width) / 2,
(screen.height - getSize ().height) / 2));
reset ();
minimum_score_scrollbar.addScoreChangeListener (minimum_listener);
maximum_score_scrollbar.addScoreChangeListener (maximum_listener);
}
/**
* Call reset (), clean up the listeners then call super.dispose ().
**/
public void dispose () {
reset ();
minimum_score_scrollbar.removeScoreChangeListener (minimum_listener);
maximum_score_scrollbar.removeScoreChangeListener (maximum_listener);
super.dispose ();
}
/**
* Reset the minimum_score_scrollbar to 0 and the maximum_score_scrollbar
* to 100.
**/
private void reset () {
minimum_score_scrollbar.setValue (minimum_value);
maximum_score_scrollbar.setValue (maximum_value);
minimum_label.setText ("Minimum Cutoff: " + minimum_value);
maximum_label.setText ("Maximum Cutoff: " + maximum_value);
final ScoreChangeEvent minimum_event =
new ScoreChangeEvent (this, minimum_value);
minimum_listener.scoreChanged (minimum_event);
final ScoreChangeEvent maximum_event =
new ScoreChangeEvent (this, maximum_value);
maximum_listener.scoreChanged (maximum_event);
}
/**
* The ScoreChangeListener for the minimum score that was passed to the
* constructor.
**/
final ScoreChangeListener minimum_listener;
/**
* The minimum score scrollbar the created by the constructor.
**/
final ScoreScrollbar minimum_score_scrollbar;
/**
* The ScoreChangeListener for the maximum score that was passed to the
* constructor.
**/
final ScoreChangeListener maximum_listener;
/**
* The maximum score scrollbar the created by the constructor.
**/
final ScoreScrollbar maximum_score_scrollbar;
/**
* The minimum allowable value for the scroll bars.
**/
final int minimum_value;
/**
* The maximum allowable value for the scroll bars.
**/
final int maximum_value;
/**
* A Label that shows something like this: "Minimum Cutoff: 0"
**/
final JLabel minimum_label;
/**
* A Label that shows something like this: "Maximum Cutoff: 100"
**/
final JLabel maximum_label;
}