2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2003, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
|
2 |
26 Feb 07 |
jari |
This software is provided "AS IS". TIGR makes no warranties, express |
2 |
26 Feb 07 |
jari |
or implied, including no representation or warranty with respect to |
2 |
26 Feb 07 |
jari |
the performance of the software and derivatives or their safety, |
2 |
26 Feb 07 |
jari |
effectiveness, or commercial viability. TIGR does not warrant the |
2 |
26 Feb 07 |
jari |
merchantability or fitness of the software and derivatives for any |
2 |
26 Feb 07 |
jari |
particular purpose, or that they may be exploited without infringing |
2 |
26 Feb 07 |
jari |
the copyrights, patent rights or property rights of others. TIGR shall |
2 |
26 Feb 07 |
jari |
not be liable for any claim, demand or action for any loss, harm, |
2 |
26 Feb 07 |
jari |
illness or other damage or injury arising from access to or use of the |
2 |
26 Feb 07 |
jari |
software or associated information, including without limitation any |
2 |
26 Feb 07 |
jari |
direct, indirect, incidental, exemplary, special or consequential |
2 |
26 Feb 07 |
jari |
damages. |
2 |
26 Feb 07 |
jari |
17 |
|
2 |
26 Feb 07 |
jari |
This software program may not be sold, leased, transferred, exported |
2 |
26 Feb 07 |
jari |
or otherwise disclaimed to anyone, in whole or in part, without the |
2 |
26 Feb 07 |
jari |
prior written consent of TIGR. |
2 |
26 Feb 07 |
jari |
21 |
*/ |
2 |
26 Feb 07 |
jari |
22 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: SetFoldFilterDialog.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.4 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/02/23 20:59:41 $ |
2 |
26 Feb 07 |
jari |
* $Author: caliente $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
28 |
*/ |
2 |
26 Feb 07 |
jari |
29 |
package org.tigr.microarray.mev; |
2 |
26 Feb 07 |
jari |
30 |
|
2 |
26 Feb 07 |
jari |
31 |
|
2 |
26 Feb 07 |
jari |
32 |
import java.awt.BorderLayout; |
2 |
26 Feb 07 |
jari |
33 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
34 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
35 |
import java.awt.FlowLayout; |
2 |
26 Feb 07 |
jari |
36 |
import java.awt.Font; |
2 |
26 Feb 07 |
jari |
37 |
import java.awt.GridBagConstraints; |
2 |
26 Feb 07 |
jari |
38 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
39 |
import java.awt.GridLayout; |
2 |
26 Feb 07 |
jari |
40 |
import java.awt.Toolkit; |
2 |
26 Feb 07 |
jari |
41 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
42 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
43 |
import java.awt.event.FocusAdapter; |
2 |
26 Feb 07 |
jari |
44 |
import java.awt.event.FocusEvent; |
2 |
26 Feb 07 |
jari |
45 |
import java.awt.event.ItemEvent; |
2 |
26 Feb 07 |
jari |
46 |
import java.awt.event.ItemListener; |
2 |
26 Feb 07 |
jari |
47 |
import java.awt.event.KeyAdapter; |
2 |
26 Feb 07 |
jari |
48 |
import java.awt.event.KeyEvent; |
2 |
26 Feb 07 |
jari |
49 |
import java.awt.event.KeyListener; |
2 |
26 Feb 07 |
jari |
50 |
import java.awt.event.WindowAdapter; |
2 |
26 Feb 07 |
jari |
51 |
import java.awt.event.WindowEvent; |
2 |
26 Feb 07 |
jari |
52 |
|
2 |
26 Feb 07 |
jari |
53 |
import javax.swing.BorderFactory; |
2 |
26 Feb 07 |
jari |
54 |
import javax.swing.ButtonGroup; |
2 |
26 Feb 07 |
jari |
55 |
import javax.swing.JButton; |
2 |
26 Feb 07 |
jari |
56 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
57 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
58 |
import javax.swing.JList; |
2 |
26 Feb 07 |
jari |
59 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
60 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
61 |
import javax.swing.JRadioButton; |
2 |
26 Feb 07 |
jari |
62 |
import javax.swing.JScrollPane; |
2 |
26 Feb 07 |
jari |
63 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
64 |
import javax.swing.border.EtchedBorder; |
2 |
26 Feb 07 |
jari |
65 |
import javax.swing.border.TitledBorder; |
2 |
26 Feb 07 |
jari |
66 |
import javax.swing.event.ListSelectionEvent; |
2 |
26 Feb 07 |
jari |
67 |
import javax.swing.event.ListSelectionListener; |
2 |
26 Feb 07 |
jari |
68 |
|
2 |
26 Feb 07 |
jari |
69 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.AlgorithmDialog; |
2 |
26 Feb 07 |
jari |
70 |
|
2 |
26 Feb 07 |
jari |
71 |
public class SetFoldFilterDialog extends AlgorithmDialog { |
2 |
26 Feb 07 |
jari |
72 |
|
2 |
26 Feb 07 |
jari |
73 |
private GroupExperimentsPanel gPanel; |
2 |
26 Feb 07 |
jari |
74 |
private JButton filter, cancel; |
2 |
26 Feb 07 |
jari |
75 |
private JLabel msg1Label, msg2Label, msg3Label, msg4Label; |
2 |
26 Feb 07 |
jari |
76 |
private int result; |
2 |
26 Feb 07 |
jari |
77 |
private FoldFilter ff; |
2 |
26 Feb 07 |
jari |
78 |
private String BOTH = "both"; |
2 |
26 Feb 07 |
jari |
79 |
private String GREATER_THAN = ">"; |
2 |
26 Feb 07 |
jari |
80 |
private String LESS_THAN = "<"; |
2 |
26 Feb 07 |
jari |
81 |
protected boolean use_filter; |
2 |
26 Feb 07 |
jari |
82 |
|
2 |
26 Feb 07 |
jari |
83 |
public SetFoldFilterDialog(JFrame parent, String[] sample_names) { |
2 |
26 Feb 07 |
jari |
84 |
super(parent, "Set Fold Filter", true); |
2 |
26 Feb 07 |
jari |
85 |
|
2 |
26 Feb 07 |
jari |
86 |
setBounds(0, 0, 800, 500); |
2 |
26 Feb 07 |
jari |
87 |
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
2 |
26 Feb 07 |
jari |
88 |
|
2 |
26 Feb 07 |
jari |
89 |
JPanel pane = new JPanel(); |
2 |
26 Feb 07 |
jari |
90 |
pane.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
91 |
pane.setBorder(BorderFactory.createLineBorder(Color.black)); |
2 |
26 Feb 07 |
jari |
92 |
pane.setLayout(new BorderLayout(2,2)); |
2 |
26 Feb 07 |
jari |
93 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
// filter = new JButton("OK"); |
2 |
26 Feb 07 |
jari |
// filter.setActionCommand("ok-command"); |
2 |
26 Feb 07 |
jari |
//filter.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
// cancel = new JButton("Cancel"); |
2 |
26 Feb 07 |
jari |
// cancel.setActionCommand("cancel-command"); |
2 |
26 Feb 07 |
jari |
// cancel.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
100 |
|
2 |
26 Feb 07 |
jari |
101 |
|
2 |
26 Feb 07 |
jari |
102 |
String msg1 = "Genes in Group A must be "; |
2 |
26 Feb 07 |
jari |
103 |
String msg2 = "than in Group B by "; |
2 |
26 Feb 07 |
jari |
104 |
String msg3 = " fold."; |
2 |
26 Feb 07 |
jari |
105 |
String msg4 = "\'both' will keep ALL genes whose fold change is greater than the threshold"; |
2 |
26 Feb 07 |
jari |
106 |
|
2 |
26 Feb 07 |
jari |
107 |
String[] selection_options = {GREATER_THAN, LESS_THAN, BOTH}; |
2 |
26 Feb 07 |
jari |
108 |
|
2 |
26 Feb 07 |
jari |
109 |
msg1Label = new JLabel(msg1); |
2 |
26 Feb 07 |
jari |
110 |
msg2Label = new JLabel(msg2); |
2 |
26 Feb 07 |
jari |
111 |
msg3Label = new JLabel(msg3); |
2 |
26 Feb 07 |
jari |
112 |
msg4Label = new JLabel(msg4); |
2 |
26 Feb 07 |
jari |
113 |
|
2 |
26 Feb 07 |
jari |
114 |
JTextField fold_change = new JTextField("2.0", 3); |
2 |
26 Feb 07 |
jari |
115 |
|
2 |
26 Feb 07 |
jari |
116 |
fold_change.addKeyListener( new VoteKeyListener() ); |
2 |
26 Feb 07 |
jari |
117 |
fold_change.addFocusListener( new VoteFocusListener(0,1) ); |
2 |
26 Feb 07 |
jari |
118 |
|
2 |
26 Feb 07 |
jari |
119 |
|
2 |
26 Feb 07 |
jari |
120 |
JList divider_list = new JList(selection_options); |
2 |
26 Feb 07 |
jari |
121 |
divider_list.setBorder(BorderFactory.createLineBorder(Color.black)); |
2 |
26 Feb 07 |
jari |
122 |
divider_list.setBackground(Color.lightGray); |
2 |
26 Feb 07 |
jari |
123 |
divider_list.setVisibleRowCount(3); |
2 |
26 Feb 07 |
jari |
124 |
|
2 |
26 Feb 07 |
jari |
125 |
divider_list.addListSelectionListener(new SelectionListener()); |
2 |
26 Feb 07 |
jari |
126 |
|
2 |
26 Feb 07 |
jari |
//getContentPane().add(pane); |
2 |
26 Feb 07 |
jari |
128 |
|
2 |
26 Feb 07 |
jari |
129 |
gPanel = new GroupExperimentsPanel(sample_names); |
2 |
26 Feb 07 |
jari |
130 |
|
2 |
26 Feb 07 |
jari |
131 |
this.ff = new FoldFilter(sample_names); |
2 |
26 Feb 07 |
jari |
132 |
int count; |
2 |
26 Feb 07 |
jari |
133 |
|
2 |
26 Feb 07 |
jari |
134 |
for (count = 0; count < gPanel.groupARadioButtons.length; count++) { |
2 |
26 Feb 07 |
jari |
135 |
gPanel.groupARadioButtons[count].addActionListener(new GroupListener(0, count)); |
2 |
26 Feb 07 |
jari |
136 |
} |
2 |
26 Feb 07 |
jari |
137 |
|
2 |
26 Feb 07 |
jari |
138 |
for (count = 0; count < gPanel.groupBRadioButtons.length; count++) { |
2 |
26 Feb 07 |
jari |
139 |
gPanel.groupBRadioButtons[count].addActionListener(new GroupListener(1, count)); |
2 |
26 Feb 07 |
jari |
140 |
} |
2 |
26 Feb 07 |
jari |
141 |
|
2 |
26 Feb 07 |
jari |
// should add another column of buttons for neither group |
2 |
26 Feb 07 |
jari |
143 |
|
2 |
26 Feb 07 |
jari |
144 |
pane.add(gPanel, BorderLayout.CENTER); |
2 |
26 Feb 07 |
jari |
145 |
|
2 |
26 Feb 07 |
jari |
146 |
JPanel bottom_panel = new JPanel(); |
2 |
26 Feb 07 |
jari |
147 |
bottom_panel.setLayout(new GridLayout(2,1)); |
2 |
26 Feb 07 |
jari |
148 |
|
2 |
26 Feb 07 |
jari |
149 |
JPanel sub1 = new JPanel(); |
2 |
26 Feb 07 |
jari |
150 |
sub1.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
151 |
JPanel sub2 = new JPanel(); |
2 |
26 Feb 07 |
jari |
152 |
sub2.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
// JPanel sub3 = new JPanel(); |
2 |
26 Feb 07 |
jari |
// JPanel sub4 = new JPanel(); |
2 |
26 Feb 07 |
jari |
155 |
|
2 |
26 Feb 07 |
jari |
156 |
sub1.setLayout(new FlowLayout(FlowLayout.LEFT)); |
2 |
26 Feb 07 |
jari |
157 |
sub2.setLayout(new FlowLayout(FlowLayout.LEFT)); |
2 |
26 Feb 07 |
jari |
//sub3.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
2 |
26 Feb 07 |
jari |
159 |
|
2 |
26 Feb 07 |
jari |
160 |
sub1.add(msg1Label); |
2 |
26 Feb 07 |
jari |
161 |
sub1.add(divider_list); |
2 |
26 Feb 07 |
jari |
162 |
sub1.add(msg2Label); |
2 |
26 Feb 07 |
jari |
163 |
sub1.add(fold_change); |
2 |
26 Feb 07 |
jari |
164 |
sub1.add(msg3Label); |
2 |
26 Feb 07 |
jari |
165 |
|
2 |
26 Feb 07 |
jari |
166 |
sub2.add(msg4Label); |
2 |
26 Feb 07 |
jari |
167 |
|
2 |
26 Feb 07 |
jari |
//sub3.add(filter); |
2 |
26 Feb 07 |
jari |
//sub3.add(cancel); |
2 |
26 Feb 07 |
jari |
170 |
|
2 |
26 Feb 07 |
jari |
171 |
bottom_panel.add(sub1); |
2 |
26 Feb 07 |
jari |
172 |
bottom_panel.add(sub2); |
2 |
26 Feb 07 |
jari |
// bottom_panel.add(sub3); |
2 |
26 Feb 07 |
jari |
174 |
|
2 |
26 Feb 07 |
jari |
175 |
pane.add(bottom_panel, BorderLayout.SOUTH); |
2 |
26 Feb 07 |
jari |
176 |
|
2 |
26 Feb 07 |
jari |
177 |
addContent(pane); |
2 |
26 Feb 07 |
jari |
178 |
setActionListeners(listener); |
2 |
26 Feb 07 |
jari |
179 |
|
2 |
26 Feb 07 |
jari |
180 |
addWindowListener(listener); |
2 |
26 Feb 07 |
jari |
181 |
} |
2 |
26 Feb 07 |
jari |
182 |
|
2 |
26 Feb 07 |
jari |
183 |
|
2 |
26 Feb 07 |
jari |
184 |
public static void main(String [] args){ |
2 |
26 Feb 07 |
jari |
185 |
String [] names = new String[40]; |
2 |
26 Feb 07 |
jari |
186 |
for(int i = 0; i < names.length; i++) |
2 |
26 Feb 07 |
jari |
187 |
names[i] = "name"+Integer.toString(i); |
2 |
26 Feb 07 |
jari |
188 |
SetFoldFilterDialog d = new SetFoldFilterDialog(new JFrame(), names); |
2 |
26 Feb 07 |
jari |
189 |
d.showModal(); |
2 |
26 Feb 07 |
jari |
190 |
} |
2 |
26 Feb 07 |
jari |
191 |
|
2 |
26 Feb 07 |
jari |
192 |
|
2 |
26 Feb 07 |
jari |
193 |
public SetFoldFilterDialog(JFrame parent, String[] sample_names, FoldFilter ff){ |
2 |
26 Feb 07 |
jari |
194 |
this(parent, sample_names); |
2 |
26 Feb 07 |
jari |
195 |
this.ff = ff; |
2 |
26 Feb 07 |
jari |
196 |
} |
2 |
26 Feb 07 |
jari |
197 |
|
2 |
26 Feb 07 |
jari |
198 |
|
2 |
26 Feb 07 |
jari |
199 |
public int showModal() { |
2 |
26 Feb 07 |
jari |
200 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
201 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
202 |
show(); |
2 |
26 Feb 07 |
jari |
203 |
return result; |
2 |
26 Feb 07 |
jari |
204 |
} |
2 |
26 Feb 07 |
jari |
205 |
|
2 |
26 Feb 07 |
jari |
206 |
public FoldFilter getFoldFilter() { |
2 |
26 Feb 07 |
jari |
//System.out.println(df.toString()); |
2 |
26 Feb 07 |
jari |
208 |
return this.ff; |
2 |
26 Feb 07 |
jari |
209 |
} |
2 |
26 Feb 07 |
jari |
210 |
|
2 |
26 Feb 07 |
jari |
211 |
private class Listener extends WindowAdapter implements ActionListener, KeyListener, ItemListener { |
2 |
26 Feb 07 |
jari |
212 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
213 |
String command = event.getActionCommand(); |
2 |
26 Feb 07 |
jari |
214 |
if (command.equals("ok-command")) { |
2 |
26 Feb 07 |
jari |
215 |
onOk(); |
2 |
26 Feb 07 |
jari |
216 |
} else if (command.equals("cancel-command")) { |
2 |
26 Feb 07 |
jari |
217 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
218 |
dispose(); |
2 |
26 Feb 07 |
jari |
219 |
} |
2 |
26 Feb 07 |
jari |
220 |
} |
2 |
26 Feb 07 |
jari |
221 |
|
2 |
26 Feb 07 |
jari |
222 |
public void keyPressed(KeyEvent event) { |
2 |
26 Feb 07 |
jari |
223 |
if (event.getKeyCode() == KeyEvent.VK_ENTER) { |
2 |
26 Feb 07 |
jari |
224 |
onOk(); |
2 |
26 Feb 07 |
jari |
225 |
} |
2 |
26 Feb 07 |
jari |
226 |
} |
2 |
26 Feb 07 |
jari |
227 |
|
2 |
26 Feb 07 |
jari |
228 |
public void windowClosing(WindowEvent e) { |
2 |
26 Feb 07 |
jari |
229 |
result = JOptionPane.CLOSED_OPTION; |
2 |
26 Feb 07 |
jari |
230 |
dispose(); |
2 |
26 Feb 07 |
jari |
231 |
} |
2 |
26 Feb 07 |
jari |
232 |
|
2 |
26 Feb 07 |
jari |
233 |
public void keyReleased(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
234 |
public void keyTyped(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
235 |
|
2 |
26 Feb 07 |
jari |
236 |
public void itemStateChanged(ItemEvent is_checked){ |
2 |
26 Feb 07 |
jari |
237 |
if (is_checked.getStateChange() == ItemEvent.SELECTED) { |
2 |
26 Feb 07 |
jari |
238 |
use_filter = true; |
2 |
26 Feb 07 |
jari |
239 |
} |
2 |
26 Feb 07 |
jari |
240 |
else { |
2 |
26 Feb 07 |
jari |
241 |
use_filter = false; |
2 |
26 Feb 07 |
jari |
242 |
} |
2 |
26 Feb 07 |
jari |
243 |
} |
2 |
26 Feb 07 |
jari |
244 |
|
2 |
26 Feb 07 |
jari |
245 |
private void onOk() { |
2 |
26 Feb 07 |
jari |
246 |
try { |
2 |
26 Feb 07 |
jari |
247 |
getFoldFilter();//etectionCheckbox.getState(); |
2 |
26 Feb 07 |
jari |
248 |
result = JOptionPane.OK_OPTION; |
2 |
26 Feb 07 |
jari |
249 |
} catch (Exception exception) { |
2 |
26 Feb 07 |
jari |
250 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
251 |
} |
2 |
26 Feb 07 |
jari |
252 |
dispose(); |
2 |
26 Feb 07 |
jari |
253 |
} |
2 |
26 Feb 07 |
jari |
254 |
} |
2 |
26 Feb 07 |
jari |
255 |
|
2 |
26 Feb 07 |
jari |
256 |
/* |
2 |
26 Feb 07 |
jari |
class VoteListener implements ChangeListener { |
2 |
26 Feb 07 |
jari |
// (P) calls required for each group |
2 |
26 Feb 07 |
jari |
private int required; |
2 |
26 Feb 07 |
jari |
private int group_index; |
2 |
26 Feb 07 |
jari |
VoteListener(int group, int req){ |
2 |
26 Feb 07 |
jari |
this.required = req; |
2 |
26 Feb 07 |
jari |
this.group_index = group; |
2 |
26 Feb 07 |
jari |
264 |
} |
2 |
26 Feb 07 |
jari |
265 |
|
2 |
26 Feb 07 |
jari |
public void stateChanged(ChangeEvent e){ |
2 |
26 Feb 07 |
jari |
SpinnerNumberModel m = (SpinnerNumberModel) e.getSource(); |
2 |
26 Feb 07 |
jari |
df.set_num_required(group_index, m.getNumber().intValue() ); |
2 |
26 Feb 07 |
jari |
//System.out.println("Num required: " + m.getNumber().intValue()); |
2 |
26 Feb 07 |
jari |
270 |
} |
2 |
26 Feb 07 |
jari |
271 |
|
2 |
26 Feb 07 |
jari |
272 |
} |
2 |
26 Feb 07 |
jari |
273 |
*/ |
2 |
26 Feb 07 |
jari |
274 |
|
2 |
26 Feb 07 |
jari |
// verifies numeric input for vote textfield |
2 |
26 Feb 07 |
jari |
276 |
class VoteKeyListener extends KeyAdapter { |
2 |
26 Feb 07 |
jari |
277 |
|
2 |
26 Feb 07 |
jari |
//keyText.addKeyListener( |
2 |
26 Feb 07 |
jari |
279 |
VoteKeyListener() { |
2 |
26 Feb 07 |
jari |
280 |
super(); |
2 |
26 Feb 07 |
jari |
281 |
} |
2 |
26 Feb 07 |
jari |
282 |
|
2 |
26 Feb 07 |
jari |
283 |
public void keyTyped(KeyEvent e) { |
2 |
26 Feb 07 |
jari |
284 |
char c = e.getKeyChar(); |
2 |
26 Feb 07 |
jari |
285 |
if (! ( (Character.isDigit(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_PERIOD) || (c == KeyEvent.VK_DELETE))) ){ |
2 |
26 Feb 07 |
jari |
286 |
getToolkit().beep(); |
2 |
26 Feb 07 |
jari |
287 |
e.consume(); |
2 |
26 Feb 07 |
jari |
288 |
} |
2 |
26 Feb 07 |
jari |
289 |
} |
2 |
26 Feb 07 |
jari |
290 |
} |
2 |
26 Feb 07 |
jari |
291 |
|
2 |
26 Feb 07 |
jari |
292 |
class VoteFocusListener extends FocusAdapter { |
2 |
26 Feb 07 |
jari |
293 |
private int required; |
2 |
26 Feb 07 |
jari |
294 |
private int group_index; |
2 |
26 Feb 07 |
jari |
295 |
VoteFocusListener(int group, int req){ |
2 |
26 Feb 07 |
jari |
296 |
this.required = req; |
2 |
26 Feb 07 |
jari |
297 |
this.group_index = group; |
2 |
26 Feb 07 |
jari |
298 |
} |
2 |
26 Feb 07 |
jari |
299 |
public void focusLost(FocusEvent e) { |
2 |
26 Feb 07 |
jari |
300 |
JTextField textField = (JTextField)e.getSource(); |
2 |
26 Feb 07 |
jari |
301 |
String content = textField.getText(); |
2 |
26 Feb 07 |
jari |
302 |
ff.set_fold_change(Float.parseFloat(content)); |
2 |
26 Feb 07 |
jari |
303 |
} |
2 |
26 Feb 07 |
jari |
304 |
} |
2 |
26 Feb 07 |
jari |
305 |
|
2 |
26 Feb 07 |
jari |
306 |
class SelectionListener implements ListSelectionListener { |
2 |
26 Feb 07 |
jari |
307 |
public void valueChanged(ListSelectionEvent event){ |
2 |
26 Feb 07 |
jari |
308 |
if (!event.getValueIsAdjusting()){ |
2 |
26 Feb 07 |
jari |
309 |
JList optionList = (JList) event.getSource(); |
2 |
26 Feb 07 |
jari |
310 |
String selection = (String) optionList.getSelectedValue(); |
2 |
26 Feb 07 |
jari |
311 |
if (selection.equals(GREATER_THAN)){ |
2 |
26 Feb 07 |
jari |
312 |
ff.set_divider(GREATER_THAN); |
2 |
26 Feb 07 |
jari |
313 |
} |
2 |
26 Feb 07 |
jari |
314 |
if (selection.equals(LESS_THAN)){ |
2 |
26 Feb 07 |
jari |
315 |
ff.set_divider(LESS_THAN); |
2 |
26 Feb 07 |
jari |
316 |
} |
2 |
26 Feb 07 |
jari |
317 |
if(selection.equals(BOTH)){ |
2 |
26 Feb 07 |
jari |
318 |
ff.set_divider(BOTH); |
2 |
26 Feb 07 |
jari |
319 |
|
2 |
26 Feb 07 |
jari |
320 |
} |
2 |
26 Feb 07 |
jari |
321 |
} |
2 |
26 Feb 07 |
jari |
322 |
} |
2 |
26 Feb 07 |
jari |
323 |
} |
2 |
26 Feb 07 |
jari |
324 |
|
2 |
26 Feb 07 |
jari |
325 |
class GroupListener implements ActionListener { |
2 |
26 Feb 07 |
jari |
326 |
int file_index; |
2 |
26 Feb 07 |
jari |
327 |
int group; |
2 |
26 Feb 07 |
jari |
328 |
GroupListener(int group, int file_index){ |
2 |
26 Feb 07 |
jari |
329 |
this.group = group; |
2 |
26 Feb 07 |
jari |
330 |
this.file_index = file_index; |
2 |
26 Feb 07 |
jari |
331 |
} |
2 |
26 Feb 07 |
jari |
332 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
333 |
if (!(ff.get_group_membership(file_index) == group) ){ |
2 |
26 Feb 07 |
jari |
334 |
ff.set_group_membership(group, file_index); |
2 |
26 Feb 07 |
jari |
335 |
} |
2 |
26 Feb 07 |
jari |
336 |
} |
2 |
26 Feb 07 |
jari |
337 |
} |
2 |
26 Feb 07 |
jari |
338 |
|
2 |
26 Feb 07 |
jari |
339 |
class GroupExperimentsPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
340 |
|
2 |
26 Feb 07 |
jari |
341 |
JRadioButton[] groupARadioButtons, groupBRadioButtons, neitherGroupRadioButtons; |
2 |
26 Feb 07 |
jari |
342 |
GroupExperimentsPanel(String[] exptNames) { |
2 |
26 Feb 07 |
jari |
343 |
this.setBorder(new TitledBorder(new EtchedBorder(), "Group Assignments", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
344 |
JPanel panel1 = new JPanel(); |
2 |
26 Feb 07 |
jari |
345 |
JLabel[] expLabels = new JLabel[exptNames.length]; |
2 |
26 Feb 07 |
jari |
346 |
groupARadioButtons = new JRadioButton[exptNames.length]; |
2 |
26 Feb 07 |
jari |
347 |
groupBRadioButtons = new JRadioButton[exptNames.length]; |
2 |
26 Feb 07 |
jari |
348 |
neitherGroupRadioButtons = new JRadioButton[exptNames.length]; |
2 |
26 Feb 07 |
jari |
349 |
|
2 |
26 Feb 07 |
jari |
350 |
ButtonGroup chooseGroup[] = new ButtonGroup[exptNames.length]; |
2 |
26 Feb 07 |
jari |
351 |
|
2 |
26 Feb 07 |
jari |
352 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
353 |
GridBagLayout gridbag2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
354 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
355 |
this.setLayout(gridbag2); |
2 |
26 Feb 07 |
jari |
356 |
panel1.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
357 |
|
2 |
26 Feb 07 |
jari |
358 |
for (int i = 0; i < exptNames.length; i++) { |
2 |
26 Feb 07 |
jari |
359 |
String s1 = (String)(exptNames[i]); |
2 |
26 Feb 07 |
jari |
360 |
expLabels[i] = new JLabel(s1); |
2 |
26 Feb 07 |
jari |
361 |
chooseGroup[i] = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
362 |
groupARadioButtons[i] = new JRadioButton("Group A", true); |
2 |
26 Feb 07 |
jari |
363 |
chooseGroup[i].add(groupARadioButtons[i]); |
2 |
26 Feb 07 |
jari |
364 |
groupBRadioButtons[i] = new JRadioButton("Group B", false); |
2 |
26 Feb 07 |
jari |
365 |
chooseGroup[i].add(groupBRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
366 |
|
2 |
26 Feb 07 |
jari |
367 |
neitherGroupRadioButtons[i] = new JRadioButton("Neither", false); |
2 |
26 Feb 07 |
jari |
368 |
chooseGroup[i].add(neitherGroupRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
369 |
|
2 |
26 Feb 07 |
jari |
370 |
buildConstraints(constraints, 0, i, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
372 |
gridbag.setConstraints(expLabels[i], constraints); |
2 |
26 Feb 07 |
jari |
373 |
panel1.add(expLabels[i]); |
2 |
26 Feb 07 |
jari |
374 |
|
2 |
26 Feb 07 |
jari |
375 |
buildConstraints(constraints, 1, i, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
377 |
gridbag.setConstraints(groupARadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
378 |
panel1.add(groupARadioButtons[i]); |
2 |
26 Feb 07 |
jari |
379 |
|
2 |
26 Feb 07 |
jari |
380 |
buildConstraints(constraints, 2, i, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
382 |
gridbag.setConstraints(groupBRadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
383 |
panel1.add(groupBRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
384 |
|
2 |
26 Feb 07 |
jari |
385 |
buildConstraints(constraints, 3, i, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
387 |
gridbag.setConstraints(neitherGroupRadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
388 |
panel1.add(neitherGroupRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
389 |
|
2 |
26 Feb 07 |
jari |
390 |
} |
2 |
26 Feb 07 |
jari |
391 |
|
2 |
26 Feb 07 |
jari |
392 |
JScrollPane scroll = new JScrollPane(panel1); |
2 |
26 Feb 07 |
jari |
// scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
//scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
395 |
scroll.setPreferredSize(new Dimension(400, 450)); |
2 |
26 Feb 07 |
jari |
396 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 90); |
2 |
26 Feb 07 |
jari |
397 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
398 |
gridbag2.setConstraints(scroll, constraints); |
2 |
26 Feb 07 |
jari |
399 |
this.add(scroll); |
2 |
26 Feb 07 |
jari |
400 |
|
2 |
26 Feb 07 |
jari |
401 |
} |
2 |
26 Feb 07 |
jari |
402 |
|
2 |
26 Feb 07 |
jari |
403 |
|
2 |
26 Feb 07 |
jari |
404 |
|
2 |
26 Feb 07 |
jari |
405 |
void buildConstraints(GridBagConstraints gbc, int gx, int gy, |
2 |
26 Feb 07 |
jari |
406 |
int gw, int gh, int wx, int wy) { |
2 |
26 Feb 07 |
jari |
407 |
|
2 |
26 Feb 07 |
jari |
408 |
gbc.gridx = gx; |
2 |
26 Feb 07 |
jari |
409 |
gbc.gridy = gy; |
2 |
26 Feb 07 |
jari |
410 |
gbc.gridwidth = gw; |
2 |
26 Feb 07 |
jari |
411 |
gbc.gridheight = gh; |
2 |
26 Feb 07 |
jari |
412 |
gbc.weightx = wx; |
2 |
26 Feb 07 |
jari |
413 |
gbc.weighty = wy; |
2 |
26 Feb 07 |
jari |
414 |
} |
2 |
26 Feb 07 |
jari |
415 |
|
2 |
26 Feb 07 |
jari |
416 |
} |
2 |
26 Feb 07 |
jari |
417 |
} |