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: SetDetectionFilterDialog.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 |
//import javax.swing.SpinnerNumberModel; |
2 |
26 Feb 07 |
jari |
71 |
|
2 |
26 Feb 07 |
jari |
72 |
public class SetDetectionFilterDialog extends AlgorithmDialog { |
2 |
26 Feb 07 |
jari |
73 |
|
2 |
26 Feb 07 |
jari |
74 |
private GroupExperimentsPanel gPanel; |
2 |
26 Feb 07 |
jari |
75 |
private JButton filter, cancel; |
2 |
26 Feb 07 |
jari |
76 |
private JLabel msg1Label, msg2Label, msg3Label, tail1Label, tail2Label; |
2 |
26 Feb 07 |
jari |
//private JTextField grp_1_field, grp_2_field; |
2 |
26 Feb 07 |
jari |
78 |
private int result; |
2 |
26 Feb 07 |
jari |
79 |
private DetectionFilter df; |
2 |
26 Feb 07 |
jari |
80 |
protected boolean use_filter; |
2 |
26 Feb 07 |
jari |
81 |
|
2 |
26 Feb 07 |
jari |
82 |
|
2 |
26 Feb 07 |
jari |
83 |
|
2 |
26 Feb 07 |
jari |
84 |
public SetDetectionFilterDialog(JFrame parent, String[] sample_names) { |
2 |
26 Feb 07 |
jari |
85 |
super(parent, "Set Detection Filter", true); |
2 |
26 Feb 07 |
jari |
86 |
|
2 |
26 Feb 07 |
jari |
87 |
setBounds(0, 0, 800, 500); |
2 |
26 Feb 07 |
jari |
88 |
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
2 |
26 Feb 07 |
jari |
89 |
|
2 |
26 Feb 07 |
jari |
90 |
JPanel pane = new JPanel(); |
2 |
26 Feb 07 |
jari |
91 |
pane.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
92 |
pane.setBorder(BorderFactory.createLineBorder(Color.black)); |
2 |
26 Feb 07 |
jari |
93 |
pane.setLayout(new BorderLayout(2,2)); |
2 |
26 Feb 07 |
jari |
94 |
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 |
101 |
|
2 |
26 Feb 07 |
jari |
102 |
|
2 |
26 Feb 07 |
jari |
103 |
String msg1 = "Group A: Gene must be called (P)resent in:"; |
2 |
26 Feb 07 |
jari |
104 |
String msg2 = "Group B: Gene must be called (P)resent in:"; |
2 |
26 Feb 07 |
jari |
105 |
String msg3 = "Select one of the following: "; |
2 |
26 Feb 07 |
jari |
106 |
|
2 |
26 Feb 07 |
jari |
107 |
String tail1 = "out of the total in Group A"; |
2 |
26 Feb 07 |
jari |
108 |
String tail2 = "out of the total in Group B"; |
2 |
26 Feb 07 |
jari |
109 |
String[] selection_options = {"OR", "AND"}; |
2 |
26 Feb 07 |
jari |
110 |
|
2 |
26 Feb 07 |
jari |
111 |
msg1Label = new JLabel(msg1); |
2 |
26 Feb 07 |
jari |
112 |
msg2Label = new JLabel(msg2); |
2 |
26 Feb 07 |
jari |
113 |
msg3Label = new JLabel(msg3); |
2 |
26 Feb 07 |
jari |
114 |
tail1Label = new JLabel(tail1); |
2 |
26 Feb 07 |
jari |
115 |
tail2Label = new JLabel(tail2); |
2 |
26 Feb 07 |
jari |
116 |
|
2 |
26 Feb 07 |
jari |
117 |
/* |
2 |
26 Feb 07 |
jari |
SpinnerNumberModel model1 = new SpinnerNumberModel(1, 0, 100, 1); |
2 |
26 Feb 07 |
jari |
SpinnerNumberModel model2 = new SpinnerNumberModel(1, 0, 100, 1); |
2 |
26 Feb 07 |
jari |
120 |
|
2 |
26 Feb 07 |
jari |
model1.addChangeListener(new VoteListener(0, 1)); |
2 |
26 Feb 07 |
jari |
model2.addChangeListener(new VoteListener(1, 0)); |
2 |
26 Feb 07 |
jari |
123 |
|
2 |
26 Feb 07 |
jari |
JSpinner spinner1 = new JSpinner(model1); |
2 |
26 Feb 07 |
jari |
JSpinner spinner2 = new JSpinner(model2); |
2 |
26 Feb 07 |
jari |
126 |
*/ |
2 |
26 Feb 07 |
jari |
127 |
|
2 |
26 Feb 07 |
jari |
128 |
JTextField vote1 = new JTextField("1", 2); |
2 |
26 Feb 07 |
jari |
129 |
JTextField vote2 = new JTextField("1", 2); |
2 |
26 Feb 07 |
jari |
130 |
|
2 |
26 Feb 07 |
jari |
131 |
vote1.addKeyListener( new VoteKeyListener() ); |
2 |
26 Feb 07 |
jari |
132 |
vote2.addKeyListener( new VoteKeyListener() ); |
2 |
26 Feb 07 |
jari |
133 |
vote1.addFocusListener( new VoteFocusListener(0,1) ); |
2 |
26 Feb 07 |
jari |
134 |
vote2.addFocusListener( new VoteFocusListener(1,1) ); |
2 |
26 Feb 07 |
jari |
135 |
|
2 |
26 Feb 07 |
jari |
136 |
|
2 |
26 Feb 07 |
jari |
137 |
JList use_both = new JList(selection_options); |
2 |
26 Feb 07 |
jari |
138 |
use_both.setBorder(BorderFactory.createLineBorder(Color.black)); |
2 |
26 Feb 07 |
jari |
139 |
use_both.setBackground(Color.lightGray); |
2 |
26 Feb 07 |
jari |
140 |
use_both.setVisibleRowCount(2); |
2 |
26 Feb 07 |
jari |
141 |
|
2 |
26 Feb 07 |
jari |
142 |
use_both.addListSelectionListener(new SelectionListener()); |
2 |
26 Feb 07 |
jari |
143 |
|
2 |
26 Feb 07 |
jari |
// getContentPane().add(pane); |
2 |
26 Feb 07 |
jari |
145 |
|
2 |
26 Feb 07 |
jari |
146 |
gPanel = new GroupExperimentsPanel(sample_names); |
2 |
26 Feb 07 |
jari |
147 |
gPanel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
148 |
|
2 |
26 Feb 07 |
jari |
149 |
this.df = new DetectionFilter(sample_names); |
2 |
26 Feb 07 |
jari |
150 |
int count; |
2 |
26 Feb 07 |
jari |
151 |
|
2 |
26 Feb 07 |
jari |
152 |
for (count = 0; count < gPanel.groupARadioButtons.length; count++) { |
2 |
26 Feb 07 |
jari |
153 |
gPanel.groupARadioButtons[count].addActionListener(new GroupListener(0, count)); |
2 |
26 Feb 07 |
jari |
154 |
} |
2 |
26 Feb 07 |
jari |
155 |
|
2 |
26 Feb 07 |
jari |
156 |
for (count = 0; count < gPanel.groupBRadioButtons.length; count++) { |
2 |
26 Feb 07 |
jari |
157 |
gPanel.groupBRadioButtons[count].addActionListener(new GroupListener(1, count)); |
2 |
26 Feb 07 |
jari |
158 |
} |
2 |
26 Feb 07 |
jari |
159 |
|
2 |
26 Feb 07 |
jari |
160 |
pane.add(gPanel, BorderLayout.CENTER); |
2 |
26 Feb 07 |
jari |
161 |
|
2 |
26 Feb 07 |
jari |
162 |
JPanel bottom_panel = new JPanel(); |
2 |
26 Feb 07 |
jari |
163 |
bottom_panel.setLayout(new GridLayout(3,1)); |
2 |
26 Feb 07 |
jari |
164 |
|
2 |
26 Feb 07 |
jari |
165 |
JPanel sub1 = new JPanel(); |
2 |
26 Feb 07 |
jari |
166 |
sub1.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
167 |
JPanel sub2 = new JPanel(); |
2 |
26 Feb 07 |
jari |
168 |
sub2.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
169 |
JPanel sub3 = new JPanel(); |
2 |
26 Feb 07 |
jari |
170 |
sub3.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
// JPanel sub4 = new JPanel(); |
2 |
26 Feb 07 |
jari |
172 |
|
2 |
26 Feb 07 |
jari |
173 |
sub1.setLayout(new FlowLayout(FlowLayout.LEFT)); |
2 |
26 Feb 07 |
jari |
174 |
sub2.setLayout(new FlowLayout(FlowLayout.LEFT)); |
2 |
26 Feb 07 |
jari |
175 |
sub3.setLayout(new FlowLayout(FlowLayout.LEFT)); |
2 |
26 Feb 07 |
jari |
// sub4.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
2 |
26 Feb 07 |
jari |
177 |
|
2 |
26 Feb 07 |
jari |
178 |
sub1.add(msg1Label); |
2 |
26 Feb 07 |
jari |
//sub1.add(spinner1); |
2 |
26 Feb 07 |
jari |
180 |
sub1.add(vote1); |
2 |
26 Feb 07 |
jari |
181 |
sub1.add(tail1Label); |
2 |
26 Feb 07 |
jari |
182 |
|
2 |
26 Feb 07 |
jari |
// And Or selectionsub2.add() |
2 |
26 Feb 07 |
jari |
184 |
sub2.add(msg3Label); |
2 |
26 Feb 07 |
jari |
185 |
sub2.add(use_both); |
2 |
26 Feb 07 |
jari |
186 |
|
2 |
26 Feb 07 |
jari |
187 |
sub3.add(msg2Label); |
2 |
26 Feb 07 |
jari |
//sub3.add(spinner2); |
2 |
26 Feb 07 |
jari |
189 |
sub3.add(vote2); |
2 |
26 Feb 07 |
jari |
190 |
sub3.add(tail2Label); |
2 |
26 Feb 07 |
jari |
191 |
|
2 |
26 Feb 07 |
jari |
// sub4.add(filter); |
2 |
26 Feb 07 |
jari |
// sub4.add(cancel); |
2 |
26 Feb 07 |
jari |
194 |
|
2 |
26 Feb 07 |
jari |
195 |
bottom_panel.add(sub1); |
2 |
26 Feb 07 |
jari |
196 |
bottom_panel.add(sub2); |
2 |
26 Feb 07 |
jari |
197 |
bottom_panel.add(sub3); |
2 |
26 Feb 07 |
jari |
// bottom_panel.add(sub4); |
2 |
26 Feb 07 |
jari |
199 |
|
2 |
26 Feb 07 |
jari |
200 |
pane.add(bottom_panel, BorderLayout.SOUTH); |
2 |
26 Feb 07 |
jari |
201 |
this.addContent(pane); |
2 |
26 Feb 07 |
jari |
202 |
this.setActionListeners(listener); |
2 |
26 Feb 07 |
jari |
203 |
|
2 |
26 Feb 07 |
jari |
204 |
addWindowListener(listener); |
2 |
26 Feb 07 |
jari |
205 |
pack(); |
2 |
26 Feb 07 |
jari |
206 |
} |
2 |
26 Feb 07 |
jari |
207 |
|
2 |
26 Feb 07 |
jari |
208 |
public static void main(String [] args){ |
2 |
26 Feb 07 |
jari |
209 |
String [] names = new String[40]; |
2 |
26 Feb 07 |
jari |
210 |
for(int i = 0; i < names.length; i++) |
2 |
26 Feb 07 |
jari |
211 |
names[i] = "name"+Integer.toString(i); |
2 |
26 Feb 07 |
jari |
212 |
SetDetectionFilterDialog d = new SetDetectionFilterDialog(new JFrame(), names); |
2 |
26 Feb 07 |
jari |
213 |
d.showModal(); |
2 |
26 Feb 07 |
jari |
214 |
} |
2 |
26 Feb 07 |
jari |
215 |
|
2 |
26 Feb 07 |
jari |
216 |
public SetDetectionFilterDialog(JFrame parent, String[] sample_names, DetectionFilter df){ |
2 |
26 Feb 07 |
jari |
217 |
this(parent, sample_names); |
2 |
26 Feb 07 |
jari |
218 |
this.df = df; |
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 int showModal() { |
2 |
26 Feb 07 |
jari |
223 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
224 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
225 |
show(); |
2 |
26 Feb 07 |
jari |
226 |
return result; |
2 |
26 Feb 07 |
jari |
227 |
} |
2 |
26 Feb 07 |
jari |
228 |
|
2 |
26 Feb 07 |
jari |
229 |
public DetectionFilter getDetectionFilter() { |
2 |
26 Feb 07 |
jari |
//System.out.println(df.toString()); |
2 |
26 Feb 07 |
jari |
231 |
return this.df; |
2 |
26 Feb 07 |
jari |
232 |
} |
2 |
26 Feb 07 |
jari |
233 |
|
2 |
26 Feb 07 |
jari |
234 |
private class Listener extends WindowAdapter implements ActionListener, KeyListener, ItemListener { |
2 |
26 Feb 07 |
jari |
235 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
236 |
String command = event.getActionCommand(); |
2 |
26 Feb 07 |
jari |
237 |
if (command.equals("ok-command")) { |
2 |
26 Feb 07 |
jari |
238 |
onOk(); |
2 |
26 Feb 07 |
jari |
239 |
} else if (command.equals("cancel-command")) { |
2 |
26 Feb 07 |
jari |
240 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
241 |
dispose(); |
2 |
26 Feb 07 |
jari |
242 |
} |
2 |
26 Feb 07 |
jari |
243 |
} |
2 |
26 Feb 07 |
jari |
244 |
|
2 |
26 Feb 07 |
jari |
245 |
public void keyPressed(KeyEvent event) { |
2 |
26 Feb 07 |
jari |
246 |
if (event.getKeyCode() == KeyEvent.VK_ENTER) { |
2 |
26 Feb 07 |
jari |
247 |
onOk(); |
2 |
26 Feb 07 |
jari |
248 |
} |
2 |
26 Feb 07 |
jari |
249 |
} |
2 |
26 Feb 07 |
jari |
250 |
|
2 |
26 Feb 07 |
jari |
251 |
public void windowClosing(WindowEvent e) { |
2 |
26 Feb 07 |
jari |
252 |
result = JOptionPane.CLOSED_OPTION; |
2 |
26 Feb 07 |
jari |
253 |
dispose(); |
2 |
26 Feb 07 |
jari |
254 |
} |
2 |
26 Feb 07 |
jari |
255 |
|
2 |
26 Feb 07 |
jari |
256 |
public void keyReleased(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
257 |
public void keyTyped(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
258 |
|
2 |
26 Feb 07 |
jari |
259 |
public void itemStateChanged(ItemEvent is_checked){ |
2 |
26 Feb 07 |
jari |
260 |
if (is_checked.getStateChange() == ItemEvent.SELECTED) { |
2 |
26 Feb 07 |
jari |
261 |
use_filter = true; |
2 |
26 Feb 07 |
jari |
262 |
} |
2 |
26 Feb 07 |
jari |
263 |
else { |
2 |
26 Feb 07 |
jari |
264 |
use_filter = false; |
2 |
26 Feb 07 |
jari |
265 |
} |
2 |
26 Feb 07 |
jari |
266 |
} |
2 |
26 Feb 07 |
jari |
267 |
|
2 |
26 Feb 07 |
jari |
268 |
private void onOk() { |
2 |
26 Feb 07 |
jari |
269 |
try { |
2 |
26 Feb 07 |
jari |
270 |
getDetectionFilter();//etectionCheckbox.getState(); |
2 |
26 Feb 07 |
jari |
271 |
result = JOptionPane.OK_OPTION; |
2 |
26 Feb 07 |
jari |
272 |
} catch (Exception exception) { |
2 |
26 Feb 07 |
jari |
273 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
274 |
} |
2 |
26 Feb 07 |
jari |
275 |
dispose(); |
2 |
26 Feb 07 |
jari |
276 |
} |
2 |
26 Feb 07 |
jari |
277 |
} |
2 |
26 Feb 07 |
jari |
278 |
|
2 |
26 Feb 07 |
jari |
279 |
/* |
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 |
287 |
} |
2 |
26 Feb 07 |
jari |
288 |
|
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 |
293 |
} |
2 |
26 Feb 07 |
jari |
294 |
|
2 |
26 Feb 07 |
jari |
295 |
} |
2 |
26 Feb 07 |
jari |
296 |
*/ |
2 |
26 Feb 07 |
jari |
297 |
|
2 |
26 Feb 07 |
jari |
// verifies numeric input for vote textfield |
2 |
26 Feb 07 |
jari |
299 |
class VoteKeyListener extends KeyAdapter { |
2 |
26 Feb 07 |
jari |
300 |
|
2 |
26 Feb 07 |
jari |
//keyText.addKeyListener( |
2 |
26 Feb 07 |
jari |
302 |
VoteKeyListener() { |
2 |
26 Feb 07 |
jari |
303 |
super(); |
2 |
26 Feb 07 |
jari |
304 |
} |
2 |
26 Feb 07 |
jari |
305 |
|
2 |
26 Feb 07 |
jari |
306 |
public void keyTyped(KeyEvent e) { |
2 |
26 Feb 07 |
jari |
307 |
char c = e.getKeyChar(); |
2 |
26 Feb 07 |
jari |
308 |
if (! ( (Character.isDigit(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))) ){ |
2 |
26 Feb 07 |
jari |
309 |
getToolkit().beep(); |
2 |
26 Feb 07 |
jari |
310 |
e.consume(); |
2 |
26 Feb 07 |
jari |
311 |
} |
2 |
26 Feb 07 |
jari |
312 |
} |
2 |
26 Feb 07 |
jari |
313 |
} |
2 |
26 Feb 07 |
jari |
314 |
|
2 |
26 Feb 07 |
jari |
315 |
class VoteFocusListener extends FocusAdapter { |
2 |
26 Feb 07 |
jari |
316 |
private int required; |
2 |
26 Feb 07 |
jari |
317 |
private int group_index; |
2 |
26 Feb 07 |
jari |
318 |
VoteFocusListener(int group, int req){ |
2 |
26 Feb 07 |
jari |
319 |
this.required = req; |
2 |
26 Feb 07 |
jari |
320 |
this.group_index = group; |
2 |
26 Feb 07 |
jari |
321 |
} |
2 |
26 Feb 07 |
jari |
322 |
public void focusLost(FocusEvent e) { |
2 |
26 Feb 07 |
jari |
323 |
JTextField textField = (JTextField)e.getSource(); |
2 |
26 Feb 07 |
jari |
324 |
String content = textField.getText(); |
2 |
26 Feb 07 |
jari |
325 |
df.set_num_required(group_index, Integer.parseInt(content)); |
2 |
26 Feb 07 |
jari |
326 |
} |
2 |
26 Feb 07 |
jari |
327 |
} |
2 |
26 Feb 07 |
jari |
328 |
|
2 |
26 Feb 07 |
jari |
329 |
class SelectionListener implements ListSelectionListener { |
2 |
26 Feb 07 |
jari |
330 |
public void valueChanged(ListSelectionEvent event){ |
2 |
26 Feb 07 |
jari |
331 |
if (!event.getValueIsAdjusting()){ |
2 |
26 Feb 07 |
jari |
332 |
JList optionList = (JList) event.getSource(); |
2 |
26 Feb 07 |
jari |
333 |
String selection = (String) optionList.getSelectedValue(); |
2 |
26 Feb 07 |
jari |
334 |
if (selection.equals("AND")){ |
2 |
26 Feb 07 |
jari |
335 |
df.set_both(true); |
2 |
26 Feb 07 |
jari |
//System.out.println("AND"); |
2 |
26 Feb 07 |
jari |
337 |
|
2 |
26 Feb 07 |
jari |
338 |
} |
2 |
26 Feb 07 |
jari |
339 |
else{ |
2 |
26 Feb 07 |
jari |
340 |
df.set_both(false); |
2 |
26 Feb 07 |
jari |
//System.out.println("OR"); |
2 |
26 Feb 07 |
jari |
342 |
} |
2 |
26 Feb 07 |
jari |
343 |
} |
2 |
26 Feb 07 |
jari |
344 |
} |
2 |
26 Feb 07 |
jari |
345 |
} |
2 |
26 Feb 07 |
jari |
346 |
|
2 |
26 Feb 07 |
jari |
347 |
class GroupListener implements ActionListener { |
2 |
26 Feb 07 |
jari |
348 |
int file_index; |
2 |
26 Feb 07 |
jari |
349 |
int group; |
2 |
26 Feb 07 |
jari |
350 |
GroupListener(int group, int file_index){ |
2 |
26 Feb 07 |
jari |
351 |
this.group = group; |
2 |
26 Feb 07 |
jari |
352 |
this.file_index = file_index; |
2 |
26 Feb 07 |
jari |
353 |
} |
2 |
26 Feb 07 |
jari |
354 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
//Change df state |
2 |
26 Feb 07 |
jari |
//System.out.println("file_index: "+file_index); |
2 |
26 Feb 07 |
jari |
//System.out.println("group: " + group); |
2 |
26 Feb 07 |
jari |
//if (evt.getSource() == gPanel.groupBRadioButtons[file_index]) { |
2 |
26 Feb 07 |
jari |
359 |
|
2 |
26 Feb 07 |
jari |
360 |
if (!(df.get_group_membership(file_index) == group) ){ |
2 |
26 Feb 07 |
jari |
361 |
df.set_group_membership(group, file_index); |
2 |
26 Feb 07 |
jari |
// System.out.println("switched to ???"); |
2 |
26 Feb 07 |
jari |
// add code to dynamically change total in message below |
2 |
26 Feb 07 |
jari |
364 |
} |
2 |
26 Feb 07 |
jari |
365 |
//} |
2 |
26 Feb 07 |
jari |
366 |
} |
2 |
26 Feb 07 |
jari |
367 |
} |
2 |
26 Feb 07 |
jari |
368 |
|
2 |
26 Feb 07 |
jari |
369 |
class GroupExperimentsPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
370 |
|
2 |
26 Feb 07 |
jari |
371 |
JRadioButton[] groupARadioButtons, groupBRadioButtons; |
2 |
26 Feb 07 |
jari |
372 |
GroupExperimentsPanel(String[] exptNames) { |
2 |
26 Feb 07 |
jari |
373 |
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 |
374 |
JPanel panel1 = new JPanel(); |
2 |
26 Feb 07 |
jari |
375 |
JLabel[] expLabels = new JLabel[exptNames.length]; |
2 |
26 Feb 07 |
jari |
376 |
groupARadioButtons = new JRadioButton[exptNames.length]; |
2 |
26 Feb 07 |
jari |
377 |
groupBRadioButtons = new JRadioButton[exptNames.length]; |
2 |
26 Feb 07 |
jari |
//neitherGroupRadioButtons = new JRadioButton[exptNames.length]; |
2 |
26 Feb 07 |
jari |
379 |
ButtonGroup chooseGroup[] = new ButtonGroup[exptNames.length]; |
2 |
26 Feb 07 |
jari |
380 |
|
2 |
26 Feb 07 |
jari |
381 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
382 |
GridBagLayout gridbag2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
383 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
384 |
this.setLayout(gridbag2); |
2 |
26 Feb 07 |
jari |
385 |
panel1.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
386 |
|
2 |
26 Feb 07 |
jari |
387 |
for (int i = 0; i < exptNames.length; i++) { |
2 |
26 Feb 07 |
jari |
388 |
String s1 = (String)(exptNames[i]); |
2 |
26 Feb 07 |
jari |
389 |
expLabels[i] = new JLabel(s1); |
2 |
26 Feb 07 |
jari |
390 |
chooseGroup[i] = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
391 |
groupARadioButtons[i] = new JRadioButton("Group A", true); |
2 |
26 Feb 07 |
jari |
392 |
chooseGroup[i].add(groupARadioButtons[i]); |
2 |
26 Feb 07 |
jari |
393 |
groupBRadioButtons[i] = new JRadioButton("Group B", false); |
2 |
26 Feb 07 |
jari |
394 |
chooseGroup[i].add(groupBRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
395 |
|
2 |
26 Feb 07 |
jari |
396 |
buildConstraints(constraints, 0, i, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
398 |
gridbag.setConstraints(expLabels[i], constraints); |
2 |
26 Feb 07 |
jari |
399 |
panel1.add(expLabels[i]); |
2 |
26 Feb 07 |
jari |
400 |
|
2 |
26 Feb 07 |
jari |
401 |
buildConstraints(constraints, 1, i, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
403 |
gridbag.setConstraints(groupARadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
404 |
panel1.add(groupARadioButtons[i]); |
2 |
26 Feb 07 |
jari |
405 |
|
2 |
26 Feb 07 |
jari |
406 |
buildConstraints(constraints, 2, i, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
408 |
gridbag.setConstraints(groupBRadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
409 |
panel1.add(groupBRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
410 |
} |
2 |
26 Feb 07 |
jari |
411 |
|
2 |
26 Feb 07 |
jari |
412 |
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 |
415 |
scroll.setPreferredSize(new Dimension(400, 300)); |
2 |
26 Feb 07 |
jari |
416 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 90); |
2 |
26 Feb 07 |
jari |
417 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
418 |
gridbag2.setConstraints(scroll, constraints); |
2 |
26 Feb 07 |
jari |
419 |
this.add(scroll); |
2 |
26 Feb 07 |
jari |
420 |
|
2 |
26 Feb 07 |
jari |
421 |
} |
2 |
26 Feb 07 |
jari |
422 |
|
2 |
26 Feb 07 |
jari |
423 |
|
2 |
26 Feb 07 |
jari |
424 |
|
2 |
26 Feb 07 |
jari |
425 |
void buildConstraints(GridBagConstraints gbc, int gx, int gy, |
2 |
26 Feb 07 |
jari |
426 |
int gw, int gh, int wx, int wy) { |
2 |
26 Feb 07 |
jari |
427 |
|
2 |
26 Feb 07 |
jari |
428 |
gbc.gridx = gx; |
2 |
26 Feb 07 |
jari |
429 |
gbc.gridy = gy; |
2 |
26 Feb 07 |
jari |
430 |
gbc.gridwidth = gw; |
2 |
26 Feb 07 |
jari |
431 |
gbc.gridheight = gh; |
2 |
26 Feb 07 |
jari |
432 |
gbc.weightx = wx; |
2 |
26 Feb 07 |
jari |
433 |
gbc.weighty = wy; |
2 |
26 Feb 07 |
jari |
434 |
} |
2 |
26 Feb 07 |
jari |
435 |
|
2 |
26 Feb 07 |
jari |
436 |
} |
2 |
26 Feb 07 |
jari |
437 |
} |