2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2004, 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 |
5 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: OneWayANOVAInitBox.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.8 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2005/03/10 20:32:38 $ |
2 |
26 Feb 07 |
jari |
* $Author: braistedj $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
|
2 |
26 Feb 07 |
jari |
13 |
package org.tigr.microarray.mev.cluster.gui.impl.owa; |
2 |
26 Feb 07 |
jari |
14 |
|
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Font; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.GridBagConstraints; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.Toolkit; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
23 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
24 |
import java.awt.event.WindowAdapter; |
2 |
26 Feb 07 |
jari |
25 |
import java.io.BufferedReader; |
2 |
26 Feb 07 |
jari |
26 |
import java.io.File; |
2 |
26 Feb 07 |
jari |
27 |
import java.io.FileOutputStream; |
2 |
26 Feb 07 |
jari |
28 |
import java.io.FileReader; |
2 |
26 Feb 07 |
jari |
29 |
import java.io.PrintWriter; |
2 |
26 Feb 07 |
jari |
30 |
import java.util.Vector; |
2 |
26 Feb 07 |
jari |
31 |
|
2 |
26 Feb 07 |
jari |
32 |
import javax.swing.BorderFactory; |
2 |
26 Feb 07 |
jari |
33 |
import javax.swing.ButtonGroup; |
2 |
26 Feb 07 |
jari |
34 |
import javax.swing.JButton; |
2 |
26 Feb 07 |
jari |
35 |
import javax.swing.JFileChooser; |
2 |
26 Feb 07 |
jari |
36 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
37 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
38 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
39 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
40 |
import javax.swing.JRadioButton; |
2 |
26 Feb 07 |
jari |
41 |
import javax.swing.JScrollPane; |
2 |
26 Feb 07 |
jari |
42 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
43 |
import javax.swing.ScrollPaneConstants; |
2 |
26 Feb 07 |
jari |
44 |
import javax.swing.UIManager; |
2 |
26 Feb 07 |
jari |
45 |
import javax.swing.border.BevelBorder; |
2 |
26 Feb 07 |
jari |
46 |
import javax.swing.border.EtchedBorder; |
2 |
26 Feb 07 |
jari |
47 |
import javax.swing.border.TitledBorder; |
2 |
26 Feb 07 |
jari |
48 |
|
2 |
26 Feb 07 |
jari |
49 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.AlgorithmDialog; |
2 |
26 Feb 07 |
jari |
50 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.HCLSigOnlyPanel; |
2 |
26 Feb 07 |
jari |
51 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.dialogHelpUtil.HelpWindow; |
2 |
26 Feb 07 |
jari |
52 |
|
2 |
26 Feb 07 |
jari |
53 |
/** |
2 |
26 Feb 07 |
jari |
54 |
* |
2 |
26 Feb 07 |
jari |
* @author nbhagaba |
2 |
26 Feb 07 |
jari |
* @version |
2 |
26 Feb 07 |
jari |
57 |
*/ |
2 |
26 Feb 07 |
jari |
58 |
public class OneWayANOVAInitBox extends AlgorithmDialog { |
2 |
26 Feb 07 |
jari |
59 |
|
2 |
26 Feb 07 |
jari |
60 |
public static final int JUST_ALPHA = 1; |
2 |
26 Feb 07 |
jari |
61 |
public static final int STD_BONFERRONI = 2; |
2 |
26 Feb 07 |
jari |
62 |
public static final int ADJ_BONFERRONI = 3; |
2 |
26 Feb 07 |
jari |
63 |
public static final int MAX_T = 9; |
2 |
26 Feb 07 |
jari |
64 |
public static final int FALSE_NUM = 12; |
2 |
26 Feb 07 |
jari |
65 |
public static final int FALSE_PROP = 13; |
2 |
26 Feb 07 |
jari |
66 |
|
2 |
26 Feb 07 |
jari |
67 |
boolean okPressed = false; |
2 |
26 Feb 07 |
jari |
68 |
Vector exptNames; |
2 |
26 Feb 07 |
jari |
69 |
MultiClassPanel mPanel; |
2 |
26 Feb 07 |
jari |
70 |
PermOrFDistPanel permPanel; |
2 |
26 Feb 07 |
jari |
71 |
PValuePanel pPanel; |
2 |
26 Feb 07 |
jari |
//HCLSelectionPanel hclOpsPanel; |
2 |
26 Feb 07 |
jari |
73 |
HCLSigOnlyPanel hclOpsPanel; |
2 |
26 Feb 07 |
jari |
74 |
|
2 |
26 Feb 07 |
jari |
/** Creates new OneWayANOVAInitBox */ |
2 |
26 Feb 07 |
jari |
76 |
public OneWayANOVAInitBox(JFrame parentFrame, boolean modality, Vector exptNames) { |
2 |
26 Feb 07 |
jari |
77 |
super(parentFrame, "One-way ANOVA Initialization", modality); |
2 |
26 Feb 07 |
jari |
78 |
this.exptNames = exptNames; |
2 |
26 Feb 07 |
jari |
79 |
setBounds(0, 0, 800, 850); |
2 |
26 Feb 07 |
jari |
80 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
81 |
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
2 |
26 Feb 07 |
jari |
82 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
83 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
84 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
85 |
|
2 |
26 Feb 07 |
jari |
86 |
JPanel pane = new JPanel(); |
2 |
26 Feb 07 |
jari |
87 |
pane.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
88 |
|
2 |
26 Feb 07 |
jari |
89 |
mPanel = new MultiClassPanel(); |
2 |
26 Feb 07 |
jari |
90 |
|
2 |
26 Feb 07 |
jari |
91 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 80); |
2 |
26 Feb 07 |
jari |
92 |
gridbag.setConstraints(mPanel, constraints); |
2 |
26 Feb 07 |
jari |
93 |
pane.add(mPanel); |
2 |
26 Feb 07 |
jari |
94 |
|
2 |
26 Feb 07 |
jari |
95 |
permPanel = new PermOrFDistPanel(); |
2 |
26 Feb 07 |
jari |
96 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 5); |
2 |
26 Feb 07 |
jari |
97 |
gridbag.setConstraints(permPanel, constraints); |
2 |
26 Feb 07 |
jari |
98 |
pane.add(permPanel); |
2 |
26 Feb 07 |
jari |
99 |
|
2 |
26 Feb 07 |
jari |
100 |
pPanel = new PValuePanel(); |
2 |
26 Feb 07 |
jari |
101 |
buildConstraints(constraints, 0, 2, 1, 1, 0, 10); |
2 |
26 Feb 07 |
jari |
102 |
gridbag.setConstraints(pPanel, constraints); |
2 |
26 Feb 07 |
jari |
103 |
pane.add(pPanel); |
2 |
26 Feb 07 |
jari |
104 |
|
2 |
26 Feb 07 |
jari |
105 |
hclOpsPanel = new HCLSigOnlyPanel(); |
2 |
26 Feb 07 |
jari |
106 |
buildConstraints(constraints, 0, 3, 1, 1, 0, 5); |
2 |
26 Feb 07 |
jari |
107 |
gridbag.setConstraints(hclOpsPanel, constraints); |
2 |
26 Feb 07 |
jari |
108 |
pane.add(hclOpsPanel); |
2 |
26 Feb 07 |
jari |
109 |
|
2 |
26 Feb 07 |
jari |
110 |
addContent(pane); |
2 |
26 Feb 07 |
jari |
111 |
EventListener listener = new EventListener(); |
2 |
26 Feb 07 |
jari |
112 |
setActionListeners(listener); |
2 |
26 Feb 07 |
jari |
113 |
this.addWindowListener(listener); |
2 |
26 Feb 07 |
jari |
//pack(); |
2 |
26 Feb 07 |
jari |
115 |
} |
2 |
26 Feb 07 |
jari |
116 |
|
2 |
26 Feb 07 |
jari |
117 |
|
2 |
26 Feb 07 |
jari |
118 |
public void setVisible(boolean visible) { |
2 |
26 Feb 07 |
jari |
119 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
120 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
121 |
|
2 |
26 Feb 07 |
jari |
122 |
super.setVisible(visible); |
2 |
26 Feb 07 |
jari |
123 |
|
2 |
26 Feb 07 |
jari |
124 |
if (visible) { |
2 |
26 Feb 07 |
jari |
//bPanel.okButton.requestFocus(); //UNCOMMMENT THIS LATER |
2 |
26 Feb 07 |
jari |
126 |
} |
2 |
26 Feb 07 |
jari |
127 |
} |
2 |
26 Feb 07 |
jari |
128 |
|
2 |
26 Feb 07 |
jari |
129 |
void buildConstraints(GridBagConstraints gbc, int gx, int gy, |
2 |
26 Feb 07 |
jari |
130 |
int gw, int gh, int wx, int wy) { |
2 |
26 Feb 07 |
jari |
131 |
|
2 |
26 Feb 07 |
jari |
132 |
gbc.gridx = gx; |
2 |
26 Feb 07 |
jari |
133 |
gbc.gridy = gy; |
2 |
26 Feb 07 |
jari |
134 |
gbc.gridwidth = gw; |
2 |
26 Feb 07 |
jari |
135 |
gbc.gridheight = gh; |
2 |
26 Feb 07 |
jari |
136 |
gbc.weightx = wx; |
2 |
26 Feb 07 |
jari |
137 |
gbc.weighty = wy; |
2 |
26 Feb 07 |
jari |
138 |
} |
2 |
26 Feb 07 |
jari |
139 |
|
2 |
26 Feb 07 |
jari |
140 |
|
2 |
26 Feb 07 |
jari |
141 |
public boolean isOkPressed() { |
2 |
26 Feb 07 |
jari |
142 |
return okPressed; |
2 |
26 Feb 07 |
jari |
143 |
} |
2 |
26 Feb 07 |
jari |
144 |
|
2 |
26 Feb 07 |
jari |
145 |
public boolean drawTrees() { |
2 |
26 Feb 07 |
jari |
146 |
return this.hclOpsPanel.isHCLSelected(); |
2 |
26 Feb 07 |
jari |
147 |
} |
2 |
26 Feb 07 |
jari |
148 |
|
2 |
26 Feb 07 |
jari |
149 |
public boolean drawSigTreesOnly() { |
2 |
26 Feb 07 |
jari |
150 |
return hclOpsPanel.drawSigTreesOnly(); |
2 |
26 Feb 07 |
jari |
151 |
} |
2 |
26 Feb 07 |
jari |
152 |
|
2 |
26 Feb 07 |
jari |
153 |
class MultiClassPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
154 |
NumGroupsPanel ngPanel; |
2 |
26 Feb 07 |
jari |
155 |
GridBagConstraints constraints; |
2 |
26 Feb 07 |
jari |
156 |
GridBagLayout gridbag; |
2 |
26 Feb 07 |
jari |
157 |
JPanel dummyPanel; |
2 |
26 Feb 07 |
jari |
158 |
MultiGroupExperimentsPanel mulgPanel; |
2 |
26 Feb 07 |
jari |
159 |
int numGroups; |
2 |
26 Feb 07 |
jari |
//Vector exptNames; |
2 |
26 Feb 07 |
jari |
161 |
|
2 |
26 Feb 07 |
jari |
162 |
public MultiClassPanel(/*Vector exptNames*/) { |
2 |
26 Feb 07 |
jari |
163 |
constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
164 |
gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
165 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
//this.exptNames = exptNames; |
2 |
26 Feb 07 |
jari |
167 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
168 |
ngPanel = new NumGroupsPanel(); |
2 |
26 Feb 07 |
jari |
169 |
|
2 |
26 Feb 07 |
jari |
170 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 10); |
2 |
26 Feb 07 |
jari |
171 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
172 |
gridbag.setConstraints(ngPanel, constraints); |
2 |
26 Feb 07 |
jari |
173 |
ngPanel.okButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
174 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
175 |
ngPanel.okPressed = true; |
2 |
26 Feb 07 |
jari |
176 |
try { |
2 |
26 Feb 07 |
jari |
177 |
numGroups = Integer.parseInt(ngPanel.numGroupsField.getText()); |
2 |
26 Feb 07 |
jari |
178 |
if (numGroups <= 2) { |
2 |
26 Feb 07 |
jari |
179 |
JOptionPane.showMessageDialog(null, "Please enter a positive integer > 2!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
180 |
} else { |
2 |
26 Feb 07 |
jari |
181 |
mulgPanel = new MultiGroupExperimentsPanel(exptNames, numGroups); |
2 |
26 Feb 07 |
jari |
//System.out.println("OK Pressed"); |
2 |
26 Feb 07 |
jari |
//JButton dummyButton = new JButton("dummyButton"); |
2 |
26 Feb 07 |
jari |
184 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 90); |
2 |
26 Feb 07 |
jari |
185 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
186 |
gridbag.setConstraints(mulgPanel, constraints); |
2 |
26 Feb 07 |
jari |
//dummyButton.setVisible(true); |
2 |
26 Feb 07 |
jari |
188 |
MultiClassPanel.this.remove(dummyPanel); |
2 |
26 Feb 07 |
jari |
189 |
MultiClassPanel.this.add(mulgPanel); |
2 |
26 Feb 07 |
jari |
//MultiClassPanel.this.add(dummyButton); |
2 |
26 Feb 07 |
jari |
191 |
MultiClassPanel.this.validate(); |
2 |
26 Feb 07 |
jari |
192 |
ngPanel.okButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
193 |
ngPanel.numGroupsField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
194 |
} |
2 |
26 Feb 07 |
jari |
//MultiClassPanel.this.repaint(); |
2 |
26 Feb 07 |
jari |
//dispose(); |
2 |
26 Feb 07 |
jari |
197 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
198 |
JOptionPane.showMessageDialog(null, "Please enter a positive integer > 2!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
199 |
} |
2 |
26 Feb 07 |
jari |
200 |
} |
2 |
26 Feb 07 |
jari |
201 |
}); |
2 |
26 Feb 07 |
jari |
202 |
this.add(ngPanel); |
2 |
26 Feb 07 |
jari |
203 |
|
2 |
26 Feb 07 |
jari |
204 |
|
2 |
26 Feb 07 |
jari |
205 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 90); |
2 |
26 Feb 07 |
jari |
206 |
dummyPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
207 |
dummyPanel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
208 |
gridbag.setConstraints(dummyPanel, constraints); |
2 |
26 Feb 07 |
jari |
209 |
this.add(dummyPanel); |
2 |
26 Feb 07 |
jari |
210 |
} |
2 |
26 Feb 07 |
jari |
211 |
|
2 |
26 Feb 07 |
jari |
212 |
|
2 |
26 Feb 07 |
jari |
213 |
class NumGroupsPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
214 |
JTextField numGroupsField; |
2 |
26 Feb 07 |
jari |
215 |
JButton okButton; |
2 |
26 Feb 07 |
jari |
216 |
boolean okPressed = false; |
2 |
26 Feb 07 |
jari |
217 |
|
2 |
26 Feb 07 |
jari |
218 |
public NumGroupsPanel() { |
2 |
26 Feb 07 |
jari |
219 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
220 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
221 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
222 |
|
2 |
26 Feb 07 |
jari |
//JPanel pane = new JPanel(); |
2 |
26 Feb 07 |
jari |
224 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
225 |
|
2 |
26 Feb 07 |
jari |
226 |
JLabel numGroupsLabel = new JLabel("Number of groups "); |
2 |
26 Feb 07 |
jari |
227 |
buildConstraints(constraints, 0, 0, 1, 1, 30, 100); |
2 |
26 Feb 07 |
jari |
228 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
229 |
gridbag.setConstraints(numGroupsLabel, constraints); |
2 |
26 Feb 07 |
jari |
230 |
this.add(numGroupsLabel); |
2 |
26 Feb 07 |
jari |
231 |
|
2 |
26 Feb 07 |
jari |
232 |
numGroupsField = new JTextField("", 7); |
2 |
26 Feb 07 |
jari |
233 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
234 |
buildConstraints(constraints, 1, 0, 1, 1, 30, 0); |
2 |
26 Feb 07 |
jari |
235 |
gridbag.setConstraints(numGroupsField, constraints); |
2 |
26 Feb 07 |
jari |
236 |
this.add(numGroupsField); |
2 |
26 Feb 07 |
jari |
237 |
|
2 |
26 Feb 07 |
jari |
238 |
okButton = new JButton("OK"); |
2 |
26 Feb 07 |
jari |
239 |
buildConstraints(constraints, 2, 0, 1, 1, 40, 0); |
2 |
26 Feb 07 |
jari |
240 |
gridbag.setConstraints(okButton, constraints); |
2 |
26 Feb 07 |
jari |
241 |
|
2 |
26 Feb 07 |
jari |
242 |
this.add(okButton); |
2 |
26 Feb 07 |
jari |
243 |
|
2 |
26 Feb 07 |
jari |
244 |
} |
2 |
26 Feb 07 |
jari |
245 |
|
2 |
26 Feb 07 |
jari |
246 |
|
2 |
26 Feb 07 |
jari |
247 |
|
2 |
26 Feb 07 |
jari |
248 |
public void setVisible(boolean visible) { |
2 |
26 Feb 07 |
jari |
//Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
250 |
setLocation((MultiClassPanel.this.getWidth() - getSize().width)/2, (MultiClassPanel.this.getHeight() - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
251 |
|
2 |
26 Feb 07 |
jari |
252 |
super.setVisible(visible); |
2 |
26 Feb 07 |
jari |
253 |
|
2 |
26 Feb 07 |
jari |
254 |
if (visible) { |
2 |
26 Feb 07 |
jari |
//bPanel.okButton.requestFocus(); //UNCOMMMENT THIS LATER |
2 |
26 Feb 07 |
jari |
256 |
} |
2 |
26 Feb 07 |
jari |
257 |
} |
2 |
26 Feb 07 |
jari |
258 |
|
2 |
26 Feb 07 |
jari |
259 |
public boolean isOkPressed() { |
2 |
26 Feb 07 |
jari |
260 |
return okPressed; |
2 |
26 Feb 07 |
jari |
261 |
} |
2 |
26 Feb 07 |
jari |
262 |
|
2 |
26 Feb 07 |
jari |
263 |
} |
2 |
26 Feb 07 |
jari |
264 |
|
2 |
26 Feb 07 |
jari |
265 |
class MultiGroupExperimentsPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
266 |
int numPanels = 0; |
2 |
26 Feb 07 |
jari |
267 |
JLabel[] expLabels; |
2 |
26 Feb 07 |
jari |
268 |
JRadioButton[][] exptGroupRadioButtons; |
2 |
26 Feb 07 |
jari |
269 |
JRadioButton[] notInGroupRadioButtons; |
2 |
26 Feb 07 |
jari |
270 |
MultiGroupExperimentsPanel(Vector exptNames, int numGroups) { |
2 |
26 Feb 07 |
jari |
271 |
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 |
272 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
273 |
|
2 |
26 Feb 07 |
jari |
// JPanel panel1 = new JPanel(); |
2 |
26 Feb 07 |
jari |
275 |
expLabels = new JLabel[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
276 |
exptGroupRadioButtons = new JRadioButton[numGroups][exptNames.size()]; |
2 |
26 Feb 07 |
jari |
277 |
numPanels = exptNames.size()/512 + 1; |
2 |
26 Feb 07 |
jari |
278 |
|
2 |
26 Feb 07 |
jari |
//groupARadioButtons = new JRadioButton[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
//groupBRadioButtons = new JRadioButton[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
281 |
notInGroupRadioButtons = new JRadioButton[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
282 |
ButtonGroup chooseGroup[] = new ButtonGroup[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
283 |
|
2 |
26 Feb 07 |
jari |
284 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
285 |
GridBagLayout gridbag2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
286 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
287 |
this.setLayout(gridbag2); |
2 |
26 Feb 07 |
jari |
// panel1.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
289 |
|
2 |
26 Feb 07 |
jari |
290 |
|
2 |
26 Feb 07 |
jari |
291 |
JPanel [] panels = new JPanel[numPanels]; |
2 |
26 Feb 07 |
jari |
292 |
|
2 |
26 Feb 07 |
jari |
293 |
int currPanel = 0; |
2 |
26 Feb 07 |
jari |
294 |
for(int i = 0; i < panels.length; i++) { |
2 |
26 Feb 07 |
jari |
295 |
panels[i] = new JPanel(gridbag); |
2 |
26 Feb 07 |
jari |
296 |
} |
2 |
26 Feb 07 |
jari |
297 |
|
2 |
26 Feb 07 |
jari |
298 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
299 |
String s1 = (String)(exptNames.get(i)); |
2 |
26 Feb 07 |
jari |
300 |
expLabels[i] = new JLabel(s1); |
2 |
26 Feb 07 |
jari |
301 |
chooseGroup[i] = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
302 |
for (int j = 0; j < numGroups; j++) { |
2 |
26 Feb 07 |
jari |
303 |
exptGroupRadioButtons[j][i] = new JRadioButton("Group " + (j + 1) + " ", j == 0? true: false); |
2 |
26 Feb 07 |
jari |
304 |
chooseGroup[i].add(exptGroupRadioButtons[j][i]); |
2 |
26 Feb 07 |
jari |
305 |
} |
2 |
26 Feb 07 |
jari |
306 |
|
2 |
26 Feb 07 |
jari |
//set current panel |
2 |
26 Feb 07 |
jari |
308 |
currPanel = i / 512; |
2 |
26 Feb 07 |
jari |
309 |
|
2 |
26 Feb 07 |
jari |
310 |
notInGroupRadioButtons[i] = new JRadioButton("Not in groups", false); |
2 |
26 Feb 07 |
jari |
311 |
chooseGroup[i].add(notInGroupRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
312 |
|
2 |
26 Feb 07 |
jari |
313 |
|
2 |
26 Feb 07 |
jari |
314 |
for (int j = 0; j < numGroups; j++) { |
2 |
26 Feb 07 |
jari |
315 |
buildConstraints(constraints, j, i%512, 1, 1, 100, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
317 |
gridbag.setConstraints(exptGroupRadioButtons[j][i], constraints); |
2 |
26 Feb 07 |
jari |
318 |
panels[currPanel].add(exptGroupRadioButtons[j][i]); |
2 |
26 Feb 07 |
jari |
// panel1.add(exptGroupRadioButtons[j][i]); |
2 |
26 Feb 07 |
jari |
320 |
} |
2 |
26 Feb 07 |
jari |
321 |
|
2 |
26 Feb 07 |
jari |
322 |
buildConstraints(constraints, (numGroups + 1), i%512, 1, 1, 100, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
324 |
gridbag.setConstraints(notInGroupRadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
325 |
|
2 |
26 Feb 07 |
jari |
326 |
|
2 |
26 Feb 07 |
jari |
//panel1.add(notInGroupRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
328 |
panels[currPanel].add(notInGroupRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
329 |
|
2 |
26 Feb 07 |
jari |
330 |
|
2 |
26 Feb 07 |
jari |
331 |
} |
2 |
26 Feb 07 |
jari |
332 |
|
2 |
26 Feb 07 |
jari |
333 |
int maxLabelWidth = 0; |
2 |
26 Feb 07 |
jari |
334 |
|
2 |
26 Feb 07 |
jari |
335 |
for (int i = 0; i < expLabels.length; i++) { |
2 |
26 Feb 07 |
jari |
336 |
if (expLabels[i].getPreferredSize().getWidth() > maxLabelWidth) { |
2 |
26 Feb 07 |
jari |
337 |
maxLabelWidth = (int)Math.ceil(expLabels[i].getPreferredSize().getWidth()); |
2 |
26 Feb 07 |
jari |
338 |
} |
2 |
26 Feb 07 |
jari |
339 |
} |
2 |
26 Feb 07 |
jari |
340 |
|
2 |
26 Feb 07 |
jari |
341 |
JPanel bigPanel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
342 |
|
2 |
26 Feb 07 |
jari |
343 |
for(int i = 0; i < numPanels; i++) { |
2 |
26 Feb 07 |
jari |
344 |
bigPanel.add(panels[i] ,new GridBagConstraints(0,i,1,1,1,1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
345 |
} |
2 |
26 Feb 07 |
jari |
346 |
|
2 |
26 Feb 07 |
jari |
347 |
JScrollPane scroll = new JScrollPane(bigPanel); |
2 |
26 Feb 07 |
jari |
348 |
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
349 |
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
350 |
|
2 |
26 Feb 07 |
jari |
351 |
|
2 |
26 Feb 07 |
jari |
352 |
|
2 |
26 Feb 07 |
jari |
353 |
JPanel [] exptNameHeaderPanels = new JPanel[this.numPanels]; |
2 |
26 Feb 07 |
jari |
354 |
GridBagLayout exptHeaderGridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
//exptNameHeaderPanel.HEIGHT = panel1.getHeight(); |
2 |
26 Feb 07 |
jari |
//System.out.println("panel1.preferredSise().height = " + panel1.getPreferredSize().height); |
2 |
26 Feb 07 |
jari |
357 |
for(int i = 0; i < exptNameHeaderPanels.length; i++) { |
2 |
26 Feb 07 |
jari |
358 |
exptNameHeaderPanels[i] = new JPanel(); |
2 |
26 Feb 07 |
jari |
359 |
exptNameHeaderPanels[i].setSize(50, panels[i].getPreferredSize().height); |
2 |
26 Feb 07 |
jari |
360 |
exptNameHeaderPanels[i].setPreferredSize(new Dimension(maxLabelWidth + 10, panels[i].getPreferredSize().height)); |
2 |
26 Feb 07 |
jari |
361 |
exptNameHeaderPanels[i].setLayout(exptHeaderGridbag); |
2 |
26 Feb 07 |
jari |
362 |
} |
2 |
26 Feb 07 |
jari |
//scroll.getRowHeader().setLayout(exptHeaderGridbag); |
2 |
26 Feb 07 |
jari |
364 |
|
2 |
26 Feb 07 |
jari |
//need to possibly add to additional panels if number of exp. excedes 512 |
2 |
26 Feb 07 |
jari |
366 |
for (int i = 0; i < expLabels.length; i++) { |
2 |
26 Feb 07 |
jari |
367 |
currPanel = i / 512; |
2 |
26 Feb 07 |
jari |
368 |
buildConstraints(constraints, 0, i%512, 1, 1, 100, 100); |
2 |
26 Feb 07 |
jari |
369 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
370 |
exptHeaderGridbag.setConstraints(expLabels[i], constraints); |
2 |
26 Feb 07 |
jari |
371 |
exptNameHeaderPanels[currPanel].add(expLabels[i]); |
2 |
26 Feb 07 |
jari |
372 |
} |
2 |
26 Feb 07 |
jari |
373 |
|
2 |
26 Feb 07 |
jari |
374 |
JPanel headerPanel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
375 |
for(int i = 0; i < exptNameHeaderPanels.length; i++) { |
2 |
26 Feb 07 |
jari |
376 |
headerPanel.add(exptNameHeaderPanels[i], new GridBagConstraints(0,i,1,1,1,1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
377 |
} |
2 |
26 Feb 07 |
jari |
378 |
|
2 |
26 Feb 07 |
jari |
379 |
scroll.setRowHeaderView(headerPanel); |
2 |
26 Feb 07 |
jari |
380 |
|
2 |
26 Feb 07 |
jari |
381 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 90); |
2 |
26 Feb 07 |
jari |
382 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
383 |
gridbag2.setConstraints(scroll, constraints); |
2 |
26 Feb 07 |
jari |
384 |
this.add(scroll); |
2 |
26 Feb 07 |
jari |
385 |
|
2 |
26 Feb 07 |
jari |
386 |
JLabel label1 = new JLabel("Note: Each group MUST each contain more than one sample."); |
2 |
26 Feb 07 |
jari |
387 |
label1.setHorizontalAlignment(JLabel.CENTER); |
2 |
26 Feb 07 |
jari |
388 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 5); |
2 |
26 Feb 07 |
jari |
389 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
391 |
gridbag2.setConstraints(label1, constraints); |
2 |
26 Feb 07 |
jari |
392 |
this.add(label1); |
2 |
26 Feb 07 |
jari |
393 |
|
2 |
26 Feb 07 |
jari |
394 |
JPanel panel2 = new JPanel(); |
2 |
26 Feb 07 |
jari |
395 |
GridBagLayout gridbag3 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
396 |
panel2.setLayout(gridbag3); |
2 |
26 Feb 07 |
jari |
397 |
panel2.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
398 |
JButton saveButton = new JButton(" Save settings "); |
2 |
26 Feb 07 |
jari |
399 |
saveButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
400 |
saveButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.lightGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
401 |
JButton loadButton = new JButton(" Load settings "); |
2 |
26 Feb 07 |
jari |
402 |
loadButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
403 |
loadButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.lightGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
404 |
JButton resetButton = new JButton(" Reset "); |
2 |
26 Feb 07 |
jari |
405 |
resetButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
406 |
resetButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.lightGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
407 |
|
2 |
26 Feb 07 |
jari |
408 |
|
2 |
26 Feb 07 |
jari |
409 |
final int finNum = exptNames.size(); |
2 |
26 Feb 07 |
jari |
410 |
|
2 |
26 Feb 07 |
jari |
411 |
resetButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
412 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
413 |
for (int i = 0; i < finNum; i++) { |
2 |
26 Feb 07 |
jari |
414 |
exptGroupRadioButtons[0][i].setSelected(true); |
2 |
26 Feb 07 |
jari |
415 |
} |
2 |
26 Feb 07 |
jari |
416 |
} |
2 |
26 Feb 07 |
jari |
417 |
}); |
2 |
26 Feb 07 |
jari |
418 |
|
2 |
26 Feb 07 |
jari |
419 |
final JFileChooser fc = new JFileChooser(); |
2 |
26 Feb 07 |
jari |
420 |
fc.setCurrentDirectory(new File("Data")); |
2 |
26 Feb 07 |
jari |
421 |
|
2 |
26 Feb 07 |
jari |
422 |
saveButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
423 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
424 |
int returnVal = fc.showSaveDialog(MultiGroupExperimentsPanel.this); |
2 |
26 Feb 07 |
jari |
425 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
426 |
File file = fc.getSelectedFile(); |
2 |
26 Feb 07 |
jari |
427 |
try { |
2 |
26 Feb 07 |
jari |
428 |
PrintWriter out = new PrintWriter(new FileOutputStream(file)); |
2 |
26 Feb 07 |
jari |
429 |
int[] groupAssgn = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
430 |
for (int i = 0; i < groupAssgn.length; i++) { |
2 |
26 Feb 07 |
jari |
431 |
out.print(groupAssgn[i]); |
2 |
26 Feb 07 |
jari |
432 |
if (i < groupAssgn.length - 1) { |
2 |
26 Feb 07 |
jari |
433 |
out.print("\n"); |
2 |
26 Feb 07 |
jari |
434 |
} |
2 |
26 Feb 07 |
jari |
435 |
} |
2 |
26 Feb 07 |
jari |
436 |
out.println(); |
2 |
26 Feb 07 |
jari |
437 |
out.flush(); |
2 |
26 Feb 07 |
jari |
438 |
out.close(); |
2 |
26 Feb 07 |
jari |
439 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
//e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
441 |
} |
2 |
26 Feb 07 |
jari |
//this is where a real application would save the file. |
2 |
26 Feb 07 |
jari |
//log.append("Saving: " + file.getName() + "." + newline); |
2 |
26 Feb 07 |
jari |
444 |
} else { |
2 |
26 Feb 07 |
jari |
//log.append("Save command cancelled by user." + newline); |
2 |
26 Feb 07 |
jari |
446 |
} |
2 |
26 Feb 07 |
jari |
447 |
} |
2 |
26 Feb 07 |
jari |
448 |
}); |
2 |
26 Feb 07 |
jari |
449 |
|
2 |
26 Feb 07 |
jari |
450 |
|
2 |
26 Feb 07 |
jari |
//NEED TO REWORK THIS FOR MULTICLASS |
2 |
26 Feb 07 |
jari |
452 |
|
2 |
26 Feb 07 |
jari |
453 |
loadButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
454 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
455 |
int returnVal = fc.showOpenDialog(MultiGroupExperimentsPanel.this); |
2 |
26 Feb 07 |
jari |
456 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
457 |
try { |
2 |
26 Feb 07 |
jari |
458 |
FileReader file = new FileReader(fc.getSelectedFile()); |
2 |
26 Feb 07 |
jari |
459 |
BufferedReader buff = new BufferedReader(file); |
2 |
26 Feb 07 |
jari |
// String line = buff.readLine(); |
2 |
26 Feb 07 |
jari |
//System.out.println(line); |
2 |
26 Feb 07 |
jari |
// StringSplitter st = new StringSplitter('\t'); |
2 |
26 Feb 07 |
jari |
//st.init(line); |
2 |
26 Feb 07 |
jari |
464 |
Vector groupsVector = new Vector(); |
2 |
26 Feb 07 |
jari |
465 |
String current; |
2 |
26 Feb 07 |
jari |
466 |
while ((current = buff.readLine()) != null) { |
2 |
26 Feb 07 |
jari |
//current = st.nextToken(); |
2 |
26 Feb 07 |
jari |
468 |
groupsVector.add(new Integer(current)); |
2 |
26 Feb 07 |
jari |
//System.out.print(current); |
2 |
26 Feb 07 |
jari |
470 |
} |
2 |
26 Feb 07 |
jari |
471 |
buff.close(); |
2 |
26 Feb 07 |
jari |
472 |
int[] groupAssgn = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
473 |
if (groupsVector.size() != groupAssgn.length) { |
2 |
26 Feb 07 |
jari |
474 |
JOptionPane.showMessageDialog(mPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
475 |
} else { |
2 |
26 Feb 07 |
jari |
476 |
for (int i = 0; i < groupsVector.size(); i++) { |
2 |
26 Feb 07 |
jari |
477 |
int currentGroup = ((Integer)groupsVector.get(i)).intValue(); |
2 |
26 Feb 07 |
jari |
478 |
if (currentGroup != 0) { |
2 |
26 Feb 07 |
jari |
479 |
exptGroupRadioButtons[currentGroup - 1][i].setSelected(true); |
2 |
26 Feb 07 |
jari |
480 |
} else { |
2 |
26 Feb 07 |
jari |
481 |
notInGroupRadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
482 |
} |
2 |
26 Feb 07 |
jari |
483 |
|
2 |
26 Feb 07 |
jari |
484 |
} |
2 |
26 Feb 07 |
jari |
485 |
} |
2 |
26 Feb 07 |
jari |
486 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
487 |
JOptionPane.showMessageDialog(mPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
488 |
for (int i = 0; i < finNum; i++) { |
2 |
26 Feb 07 |
jari |
489 |
exptGroupRadioButtons[0][i].setSelected(true); |
2 |
26 Feb 07 |
jari |
490 |
} |
2 |
26 Feb 07 |
jari |
//e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
492 |
} |
2 |
26 Feb 07 |
jari |
493 |
|
2 |
26 Feb 07 |
jari |
//this is where a real application would save the file. |
2 |
26 Feb 07 |
jari |
//log.append("Saving: " + file.getName() + "." + newline); |
2 |
26 Feb 07 |
jari |
496 |
} else { |
2 |
26 Feb 07 |
jari |
//log.append("Save command cancelled by user." + newline); |
2 |
26 Feb 07 |
jari |
498 |
} |
2 |
26 Feb 07 |
jari |
499 |
} |
2 |
26 Feb 07 |
jari |
500 |
}); |
2 |
26 Feb 07 |
jari |
501 |
// |
2 |
26 Feb 07 |
jari |
502 |
|
2 |
26 Feb 07 |
jari |
503 |
|
2 |
26 Feb 07 |
jari |
504 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
505 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
506 |
constraints.insets = new Insets(5,5,5,5); |
2 |
26 Feb 07 |
jari |
507 |
buildConstraints(constraints, 0, 0, 1, 1, 33, 100); |
2 |
26 Feb 07 |
jari |
508 |
gridbag3.setConstraints(saveButton, constraints); |
2 |
26 Feb 07 |
jari |
509 |
panel2.add(saveButton); |
2 |
26 Feb 07 |
jari |
510 |
|
2 |
26 Feb 07 |
jari |
511 |
buildConstraints(constraints, 1, 0, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
512 |
gridbag3.setConstraints(loadButton, constraints); |
2 |
26 Feb 07 |
jari |
513 |
panel2.add(loadButton); |
2 |
26 Feb 07 |
jari |
514 |
|
2 |
26 Feb 07 |
jari |
515 |
buildConstraints(constraints, 2, 0, 1, 1, 34, 0); |
2 |
26 Feb 07 |
jari |
516 |
gridbag3.setConstraints(resetButton, constraints); |
2 |
26 Feb 07 |
jari |
517 |
panel2.add(resetButton); |
2 |
26 Feb 07 |
jari |
518 |
constraints.insets = new Insets(0,0,0,0); |
2 |
26 Feb 07 |
jari |
519 |
buildConstraints(constraints, 0, 2, 1, 1, 0, 5); |
2 |
26 Feb 07 |
jari |
520 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
522 |
gridbag2.setConstraints(panel2, constraints); |
2 |
26 Feb 07 |
jari |
523 |
this.add(panel2); |
2 |
26 Feb 07 |
jari |
524 |
|
2 |
26 Feb 07 |
jari |
525 |
/* |
2 |
26 Feb 07 |
jari |
JButton gButton = new JButton("groupExpts"); |
2 |
26 Feb 07 |
jari |
buildConstraints(constraints, 0, 0, 1, 1, 100, 100); |
2 |
26 Feb 07 |
jari |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
gridbag.setConstraints(gButton, constraints); |
2 |
26 Feb 07 |
jari |
this.add(gButton); |
2 |
26 Feb 07 |
jari |
531 |
*/ |
2 |
26 Feb 07 |
jari |
532 |
|
2 |
26 Feb 07 |
jari |
533 |
} |
2 |
26 Feb 07 |
jari |
534 |
|
2 |
26 Feb 07 |
jari |
535 |
/** |
2 |
26 Feb 07 |
jari |
* resets group assignments |
2 |
26 Feb 07 |
jari |
537 |
*/ |
2 |
26 Feb 07 |
jari |
538 |
private void reset(){ |
2 |
26 Feb 07 |
jari |
539 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
540 |
exptGroupRadioButtons[0][i].setSelected(true); |
2 |
26 Feb 07 |
jari |
541 |
} |
2 |
26 Feb 07 |
jari |
542 |
} |
2 |
26 Feb 07 |
jari |
543 |
} |
2 |
26 Feb 07 |
jari |
544 |
private void reset(){ |
2 |
26 Feb 07 |
jari |
545 |
mulgPanel.reset(); |
2 |
26 Feb 07 |
jari |
546 |
} |
2 |
26 Feb 07 |
jari |
547 |
} |
2 |
26 Feb 07 |
jari |
548 |
|
2 |
26 Feb 07 |
jari |
549 |
class PermOrFDistPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
550 |
JRadioButton tDistButton, permutButton; // randomGroupsButton, allCombsButton; |
2 |
26 Feb 07 |
jari |
551 |
JLabel numPermsLabel; |
2 |
26 Feb 07 |
jari |
552 |
JTextField timesField;//, alphaInputField; |
2 |
26 Feb 07 |
jari |
//JButton permParamButton; |
2 |
26 Feb 07 |
jari |
554 |
|
2 |
26 Feb 07 |
jari |
555 |
PermOrFDistPanel() { |
2 |
26 Feb 07 |
jari |
// this.setBorder(new TitledBorder(new EtchedBorder(), "P-Value parameters")); |
2 |
26 Feb 07 |
jari |
557 |
this.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Permutations or F-distribution", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
558 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
559 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
560 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
//constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
563 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
564 |
|
2 |
26 Feb 07 |
jari |
//permParamButton = new JButton("Permutation parameters"); |
2 |
26 Feb 07 |
jari |
//permParamButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
567 |
|
2 |
26 Feb 07 |
jari |
568 |
ButtonGroup chooseP = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
569 |
|
2 |
26 Feb 07 |
jari |
570 |
tDistButton = new JRadioButton("p-values based on F-distribution", true); |
2 |
26 Feb 07 |
jari |
571 |
tDistButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
572 |
tDistButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
573 |
tDistButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
574 |
|
2 |
26 Feb 07 |
jari |
575 |
numPermsLabel = new JLabel("Enter number of permutations"); |
2 |
26 Feb 07 |
jari |
576 |
numPermsLabel.setEnabled(false); |
2 |
26 Feb 07 |
jari |
577 |
|
2 |
26 Feb 07 |
jari |
578 |
timesField = new JTextField("1000", 7); |
2 |
26 Feb 07 |
jari |
579 |
timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
580 |
timesField.setBackground(Color.darkGray); |
2 |
26 Feb 07 |
jari |
581 |
|
2 |
26 Feb 07 |
jari |
582 |
tDistButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
583 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
584 |
numPermsLabel.setEnabled(false); |
2 |
26 Feb 07 |
jari |
585 |
timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
586 |
timesField.setBackground(Color.darkGray); |
2 |
26 Feb 07 |
jari |
587 |
if (pPanel.maxTButton.isSelected() || pPanel.falseNumButton.isSelected() || pPanel.falsePropButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
588 |
pPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
589 |
} |
2 |
26 Feb 07 |
jari |
590 |
pPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
591 |
pPanel.falseNumButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
592 |
pPanel.falsePropButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
593 |
pPanel.falseNumField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
594 |
pPanel.falsePropField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
//pAdjPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
596 |
} |
2 |
26 Feb 07 |
jari |
597 |
}); |
2 |
26 Feb 07 |
jari |
598 |
|
2 |
26 Feb 07 |
jari |
599 |
chooseP.add(tDistButton); |
2 |
26 Feb 07 |
jari |
600 |
|
2 |
26 Feb 07 |
jari |
601 |
permutButton = new JRadioButton("p-values based on permutation: ", false); |
2 |
26 Feb 07 |
jari |
602 |
permutButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
603 |
permutButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
604 |
permutButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
605 |
|
2 |
26 Feb 07 |
jari |
606 |
permutButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
607 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
608 |
numPermsLabel.setEnabled(true); |
2 |
26 Feb 07 |
jari |
609 |
timesField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
610 |
timesField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
611 |
pPanel.maxTButton.setEnabled(true); //UNCOMMENT THIS WHEN MAXT METHOD HAS BEEN IMPLEMEMTED |
2 |
26 Feb 07 |
jari |
//pAdjPanel.minPButton.setEnabled(true); //UNCOMMENT THIS WHEN MINP METHOD HAS BEEN DEBUGGED |
2 |
26 Feb 07 |
jari |
613 |
pPanel.falseNumButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
614 |
pPanel.falsePropButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
615 |
pPanel.falseNumField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
616 |
pPanel.falsePropField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
617 |
} |
2 |
26 Feb 07 |
jari |
618 |
}); |
2 |
26 Feb 07 |
jari |
619 |
|
2 |
26 Feb 07 |
jari |
620 |
chooseP.add(permutButton); |
2 |
26 Feb 07 |
jari |
621 |
|
2 |
26 Feb 07 |
jari |
622 |
|
2 |
26 Feb 07 |
jari |
//constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
624 |
|
2 |
26 Feb 07 |
jari |
//numCombsLabel = new JLabel(" "); |
2 |
26 Feb 07 |
jari |
//numCombsLabel.setOpaque(false); |
2 |
26 Feb 07 |
jari |
627 |
/* |
2 |
26 Feb 07 |
jari |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
buildConstraints(constraints, 1, 2, 1, 1, 0, 0); |
2 |
26 Feb 07 |
jari |
gridbag.setConstraints(numCombsLabel, constraints); |
2 |
26 Feb 07 |
jari |
this.add(numCombsLabel); |
2 |
26 Feb 07 |
jari |
632 |
*/ |
2 |
26 Feb 07 |
jari |
633 |
|
2 |
26 Feb 07 |
jari |
634 |
|
2 |
26 Feb 07 |
jari |
635 |
buildConstraints(constraints, 0, 0, 3, 1, 100, 50); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
637 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
638 |
gridbag.setConstraints(tDistButton, constraints); |
2 |
26 Feb 07 |
jari |
639 |
this.add(tDistButton); |
2 |
26 Feb 07 |
jari |
640 |
|
2 |
26 Feb 07 |
jari |
641 |
buildConstraints(constraints, 0, 1, 1, 1, 30, 50); |
2 |
26 Feb 07 |
jari |
642 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
643 |
gridbag.setConstraints(permutButton, constraints); |
2 |
26 Feb 07 |
jari |
644 |
this.add(permutButton); |
2 |
26 Feb 07 |
jari |
645 |
|
2 |
26 Feb 07 |
jari |
//JLabel numPermsLabel = new JLabel("Enter number of permutations"); |
2 |
26 Feb 07 |
jari |
//numPermsLabel.setEnabled(false); |
2 |
26 Feb 07 |
jari |
648 |
buildConstraints(constraints, 1, 1, 1, 1, 30, 0); |
2 |
26 Feb 07 |
jari |
649 |
gridbag.setConstraints(numPermsLabel, constraints); |
2 |
26 Feb 07 |
jari |
650 |
this.add(numPermsLabel); |
2 |
26 Feb 07 |
jari |
651 |
|
2 |
26 Feb 07 |
jari |
652 |
buildConstraints(constraints, 2, 1, 1, 1, 40, 0); |
2 |
26 Feb 07 |
jari |
653 |
gridbag.setConstraints(timesField, constraints); |
2 |
26 Feb 07 |
jari |
654 |
this.add(timesField); |
2 |
26 Feb 07 |
jari |
655 |
/* |
2 |
26 Feb 07 |
jari |
JLabel alphaLabel = new JLabel("Enter critical p-value"); |
2 |
26 Feb 07 |
jari |
buildConstraints(constraints, 0, 2, 2, 1, 60, 40); |
2 |
26 Feb 07 |
jari |
//constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
gridbag.setConstraints(alphaLabel, constraints); |
2 |
26 Feb 07 |
jari |
this.add(alphaLabel); |
2 |
26 Feb 07 |
jari |
661 |
|
2 |
26 Feb 07 |
jari |
alphaInputField = new JTextField("0.01", 7); |
2 |
26 Feb 07 |
jari |
buildConstraints(constraints, 1, 2, 1, 1, 40, 0); |
2 |
26 Feb 07 |
jari |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
gridbag.setConstraints(alphaInputField, constraints); |
2 |
26 Feb 07 |
jari |
this.add(alphaInputField); |
2 |
26 Feb 07 |
jari |
667 |
*/ |
2 |
26 Feb 07 |
jari |
668 |
} |
2 |
26 Feb 07 |
jari |
669 |
} |
2 |
26 Feb 07 |
jari |
670 |
|
2 |
26 Feb 07 |
jari |
671 |
|
2 |
26 Feb 07 |
jari |
672 |
class PValuePanel extends JPanel { |
2 |
26 Feb 07 |
jari |
673 |
JTextField pValueInputField, falseNumField, falsePropField; |
2 |
26 Feb 07 |
jari |
674 |
JRadioButton justAlphaButton, stdBonfButton, adjBonfButton, maxTButton, falseNumButton, falsePropButton; |
2 |
26 Feb 07 |
jari |
675 |
|
2 |
26 Feb 07 |
jari |
676 |
public PValuePanel() { |
2 |
26 Feb 07 |
jari |
677 |
this.setBorder(new TitledBorder(new EtchedBorder(), "P-value / false discovery parameters", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
678 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
679 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
681 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
//JPanel pane = new JPanel(); |
2 |
26 Feb 07 |
jari |
683 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
684 |
|
2 |
26 Feb 07 |
jari |
685 |
JLabel pValueLabel = new JLabel("Enter alpha (critical p-value): "); |
2 |
26 Feb 07 |
jari |
686 |
buildConstraints(constraints, 0, 0, 1, 1, 33, 25); |
2 |
26 Feb 07 |
jari |
687 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
688 |
gridbag.setConstraints(pValueLabel, constraints); |
2 |
26 Feb 07 |
jari |
689 |
this.add(pValueLabel); |
2 |
26 Feb 07 |
jari |
690 |
|
2 |
26 Feb 07 |
jari |
691 |
pValueInputField = new JTextField("0.01", 7); |
2 |
26 Feb 07 |
jari |
692 |
buildConstraints(constraints, 1, 0, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
693 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
694 |
gridbag.setConstraints(pValueInputField, constraints); |
2 |
26 Feb 07 |
jari |
695 |
this.add(pValueInputField); |
2 |
26 Feb 07 |
jari |
696 |
|
2 |
26 Feb 07 |
jari |
697 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
698 |
|
2 |
26 Feb 07 |
jari |
699 |
justAlphaButton = new JRadioButton("Just alpha (no correction)", true); |
2 |
26 Feb 07 |
jari |
700 |
justAlphaButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
//justAlphaButton.setVisible(false); |
2 |
26 Feb 07 |
jari |
702 |
stdBonfButton = new JRadioButton("Standard Bonferroni", false); |
2 |
26 Feb 07 |
jari |
703 |
stdBonfButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
//stdBonfButton.setVisible(false); // WILL BE MADE VISIBLE WHEN THESE OPTIONS ARE IMPLEMENTED |
2 |
26 Feb 07 |
jari |
705 |
adjBonfButton = new JRadioButton("Adjusted Bonferroni", false); |
2 |
26 Feb 07 |
jari |
706 |
adjBonfButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
//adjBonfButton.setVisible(false);// WILL BE MADE VISIBLE WHEN THESE OPTIONS ARE IMPLEMENTED |
2 |
26 Feb 07 |
jari |
708 |
maxTButton = new JRadioButton("Westfall-Young step-down maxT", false); |
2 |
26 Feb 07 |
jari |
709 |
maxTButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
710 |
maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
711 |
|
2 |
26 Feb 07 |
jari |
712 |
falseNumButton = new JRadioButton("EITHER, The number of false significant genes should not exceed", false); |
2 |
26 Feb 07 |
jari |
713 |
falseNumButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
//falseNumButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
715 |
falseNumButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
716 |
falseNumButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
717 |
falseNumButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
//sigGroup.add(falseNumButton); |
2 |
26 Feb 07 |
jari |
719 |
|
2 |
26 Feb 07 |
jari |
720 |
falsePropButton = new JRadioButton("OR, The proportion of false significant genes should not exceed", false); |
2 |
26 Feb 07 |
jari |
721 |
falsePropButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
//falsePropButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
723 |
falsePropButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
724 |
falsePropButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
725 |
falsePropButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
//sigGroup.add(falsePropButton); |
2 |
26 Feb 07 |
jari |
727 |
|
2 |
26 Feb 07 |
jari |
728 |
falseNumField = new JTextField(10); |
2 |
26 Feb 07 |
jari |
729 |
falseNumField.setText("10"); |
2 |
26 Feb 07 |
jari |
730 |
falseNumField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
731 |
falsePropField = new JTextField(10); |
2 |
26 Feb 07 |
jari |
732 |
falsePropField.setText("0.05"); |
2 |
26 Feb 07 |
jari |
733 |
falsePropField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
734 |
|
2 |
26 Feb 07 |
jari |
735 |
ButtonGroup chooseCorrection = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
736 |
chooseCorrection.add(justAlphaButton); |
2 |
26 Feb 07 |
jari |
737 |
chooseCorrection.add(stdBonfButton); |
2 |
26 Feb 07 |
jari |
738 |
chooseCorrection.add(adjBonfButton); |
2 |
26 Feb 07 |
jari |
739 |
chooseCorrection.add(maxTButton); |
2 |
26 Feb 07 |
jari |
740 |
chooseCorrection.add(falseNumButton); |
2 |
26 Feb 07 |
jari |
741 |
chooseCorrection.add(falsePropButton); |
2 |
26 Feb 07 |
jari |
//stdBonfButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
//adjBonfButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
744 |
|
2 |
26 Feb 07 |
jari |
745 |
JPanel FDRPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
746 |
FDRPanel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
747 |
FDRPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "False discovery control (permutations only)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
748 |
GridBagLayout grid3 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
749 |
FDRPanel.setLayout(grid3); |
2 |
26 Feb 07 |
jari |
750 |
|
2 |
26 Feb 07 |
jari |
751 |
JLabel FDRLabel = new JLabel("With confidence of [1 - alpha] : "); |
2 |
26 Feb 07 |
jari |
752 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
753 |
buildConstraints(constraints, 0, 0, 2, 1, 100, 34); |
2 |
26 Feb 07 |
jari |
754 |
grid3.setConstraints(FDRLabel, constraints); |
2 |
26 Feb 07 |
jari |
755 |
FDRPanel.add(FDRLabel); |
2 |
26 Feb 07 |
jari |
756 |
|
2 |
26 Feb 07 |
jari |
757 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
758 |
|
2 |
26 Feb 07 |
jari |
759 |
buildConstraints(constraints, 0, 1, 1, 1, 50, 33); |
2 |
26 Feb 07 |
jari |
760 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
761 |
grid3.setConstraints(falseNumButton, constraints); |
2 |
26 Feb 07 |
jari |
762 |
FDRPanel.add(falseNumButton); |
2 |
26 Feb 07 |
jari |
763 |
|
2 |
26 Feb 07 |
jari |
764 |
buildConstraints(constraints, 1, 1, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
765 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
766 |
grid3.setConstraints(falseNumField, constraints); |
2 |
26 Feb 07 |
jari |
767 |
FDRPanel.add(falseNumField); |
2 |
26 Feb 07 |
jari |
768 |
|
2 |
26 Feb 07 |
jari |
769 |
buildConstraints(constraints, 0, 2, 1, 1, 50, 33); |
2 |
26 Feb 07 |
jari |
770 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
771 |
grid3.setConstraints(falsePropButton, constraints); |
2 |
26 Feb 07 |
jari |
772 |
FDRPanel.add(falsePropButton); |
2 |
26 Feb 07 |
jari |
773 |
|
2 |
26 Feb 07 |
jari |
774 |
buildConstraints(constraints, 1, 2, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
775 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
776 |
grid3.setConstraints(falsePropField, constraints); |
2 |
26 Feb 07 |
jari |
777 |
FDRPanel.add(falsePropField); |
2 |
26 Feb 07 |
jari |
778 |
|
2 |
26 Feb 07 |
jari |
779 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
780 |
|
2 |
26 Feb 07 |
jari |
781 |
|
2 |
26 Feb 07 |
jari |
782 |
|
2 |
26 Feb 07 |
jari |
783 |
buildConstraints(constraints, 0, 1, 1, 1, 25, 25); |
2 |
26 Feb 07 |
jari |
784 |
gridbag.setConstraints(justAlphaButton, constraints); |
2 |
26 Feb 07 |
jari |
785 |
this.add(justAlphaButton); |
2 |
26 Feb 07 |
jari |
786 |
|
2 |
26 Feb 07 |
jari |
787 |
buildConstraints(constraints, 1, 1, 1, 1, 25, 0); |
2 |
26 Feb 07 |
jari |
788 |
gridbag.setConstraints(stdBonfButton, constraints); |
2 |
26 Feb 07 |
jari |
789 |
this.add(stdBonfButton); |
2 |
26 Feb 07 |
jari |
790 |
|
2 |
26 Feb 07 |
jari |
791 |
buildConstraints(constraints, 2, 1, 1, 1, 25, 0); |
2 |
26 Feb 07 |
jari |
792 |
gridbag.setConstraints(adjBonfButton, constraints); |
2 |
26 Feb 07 |
jari |
793 |
this.add(adjBonfButton); |
2 |
26 Feb 07 |
jari |
794 |
|
2 |
26 Feb 07 |
jari |
795 |
buildConstraints(constraints, 3, 1, 1, 1, 25, 0); |
2 |
26 Feb 07 |
jari |
796 |
gridbag.setConstraints(maxTButton, constraints); |
2 |
26 Feb 07 |
jari |
797 |
this.add(maxTButton); |
2 |
26 Feb 07 |
jari |
798 |
|
2 |
26 Feb 07 |
jari |
799 |
buildConstraints(constraints, 0, 2, 4, 1, 100, 50); |
2 |
26 Feb 07 |
jari |
800 |
gridbag.setConstraints(FDRPanel, constraints); |
2 |
26 Feb 07 |
jari |
801 |
this.add(FDRPanel); |
2 |
26 Feb 07 |
jari |
802 |
} |
2 |
26 Feb 07 |
jari |
803 |
|
2 |
26 Feb 07 |
jari |
804 |
private void reset() { |
2 |
26 Feb 07 |
jari |
805 |
pValueInputField.setText("0.01"); |
2 |
26 Feb 07 |
jari |
806 |
justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
807 |
} |
2 |
26 Feb 07 |
jari |
808 |
|
2 |
26 Feb 07 |
jari |
809 |
} |
2 |
26 Feb 07 |
jari |
810 |
|
2 |
26 Feb 07 |
jari |
811 |
public class EventListener extends WindowAdapter implements ActionListener{ |
2 |
26 Feb 07 |
jari |
812 |
|
2 |
26 Feb 07 |
jari |
813 |
public void actionPerformed(ActionEvent ae) { |
2 |
26 Feb 07 |
jari |
814 |
String command = ae.getActionCommand(); |
2 |
26 Feb 07 |
jari |
815 |
if(command.equals("ok-command")){ |
2 |
26 Feb 07 |
jari |
816 |
boolean tooFew = false; |
2 |
26 Feb 07 |
jari |
817 |
int[] grpAssignments = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
818 |
int numGroups = getNumGroups(); |
2 |
26 Feb 07 |
jari |
819 |
int[] groupSize = new int[numGroups]; |
2 |
26 Feb 07 |
jari |
820 |
|
2 |
26 Feb 07 |
jari |
821 |
for (int i = 0; i < groupSize.length; i++) { |
2 |
26 Feb 07 |
jari |
822 |
groupSize[i] = 0; |
2 |
26 Feb 07 |
jari |
823 |
} |
2 |
26 Feb 07 |
jari |
824 |
|
2 |
26 Feb 07 |
jari |
825 |
for (int i = 0; i < grpAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
826 |
int currentGroup = grpAssignments[i]; |
2 |
26 Feb 07 |
jari |
827 |
if (currentGroup != 0) { |
2 |
26 Feb 07 |
jari |
828 |
groupSize[currentGroup - 1]++; |
2 |
26 Feb 07 |
jari |
829 |
} |
2 |
26 Feb 07 |
jari |
830 |
} |
2 |
26 Feb 07 |
jari |
831 |
|
2 |
26 Feb 07 |
jari |
832 |
/* |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < grpAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
System.out.println("grpAssignments[" + i + "] = " + grpAssignments[i]); |
2 |
26 Feb 07 |
jari |
835 |
} |
2 |
26 Feb 07 |
jari |
836 |
|
2 |
26 Feb 07 |
jari |
for (int i = 0; i < groupSize.length; i++) { |
2 |
26 Feb 07 |
jari |
System.out.println("groupSize[" + i + "] = " + groupSize[i] + " (group " + (i +1) + ")"); |
2 |
26 Feb 07 |
jari |
839 |
} |
2 |
26 Feb 07 |
jari |
840 |
*/ |
2 |
26 Feb 07 |
jari |
841 |
|
2 |
26 Feb 07 |
jari |
842 |
for (int i = 0; i < groupSize.length; i++) { |
2 |
26 Feb 07 |
jari |
843 |
if (groupSize[i] <= 1) { |
2 |
26 Feb 07 |
jari |
844 |
JOptionPane.showMessageDialog(null, "Each group must contain more than one sample.", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
845 |
tooFew = true; |
2 |
26 Feb 07 |
jari |
846 |
break; |
2 |
26 Feb 07 |
jari |
847 |
} |
2 |
26 Feb 07 |
jari |
848 |
} |
2 |
26 Feb 07 |
jari |
849 |
|
2 |
26 Feb 07 |
jari |
850 |
if (!tooFew) { |
2 |
26 Feb 07 |
jari |
851 |
try { |
2 |
26 Feb 07 |
jari |
852 |
if (pPanel.falseNumButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
853 |
if (!validateFalseNum()) { |
2 |
26 Feb 07 |
jari |
854 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
855 |
return; |
2 |
26 Feb 07 |
jari |
856 |
} |
2 |
26 Feb 07 |
jari |
857 |
} |
2 |
26 Feb 07 |
jari |
858 |
if (pPanel.falsePropButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
859 |
if (!validateFalseProp()) { |
2 |
26 Feb 07 |
jari |
860 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
861 |
return; |
2 |
26 Feb 07 |
jari |
862 |
} |
2 |
26 Feb 07 |
jari |
863 |
} |
2 |
26 Feb 07 |
jari |
//HERE, CHECK OTHER INPUTS: P-VALUE VALIDITY - 4/25/03 |
2 |
26 Feb 07 |
jari |
865 |
double d = Double.parseDouble(pPanel.pValueInputField.getText()); |
2 |
26 Feb 07 |
jari |
866 |
/* |
2 |
26 Feb 07 |
jari |
if (usePerms()) { |
2 |
26 Feb 07 |
jari |
int p = getNumPerms(); |
2 |
26 Feb 07 |
jari |
869 |
} |
2 |
26 Feb 07 |
jari |
870 |
*/ |
2 |
26 Feb 07 |
jari |
871 |
if ((d <= 0d)||(d > 1d) || (usePerms() && (getNumPerms() <= 1))) { |
2 |
26 Feb 07 |
jari |
872 |
JOptionPane.showMessageDialog(null, "Valid inputs: 0 < alpha < 1, and # of permutations (integer only) > 1", "Error!", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
873 |
} else { |
2 |
26 Feb 07 |
jari |
874 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
875 |
dispose(); |
2 |
26 Feb 07 |
jari |
876 |
} |
2 |
26 Feb 07 |
jari |
877 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
878 |
JOptionPane.showMessageDialog(null, "Valid inputs: 0 < alpha < 1, and # of permutations (integer only) > 1", "Error!", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
879 |
} |
2 |
26 Feb 07 |
jari |
880 |
|
2 |
26 Feb 07 |
jari |
881 |
} |
2 |
26 Feb 07 |
jari |
882 |
} else if (command.equals("reset-command")) { |
2 |
26 Feb 07 |
jari |
883 |
mPanel.reset(); |
2 |
26 Feb 07 |
jari |
884 |
pPanel.reset(); |
2 |
26 Feb 07 |
jari |
885 |
} else if (command.equals("cancel-command")) { |
2 |
26 Feb 07 |
jari |
886 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
887 |
dispose(); |
2 |
26 Feb 07 |
jari |
888 |
} else if (command.equals("info-command")){ |
2 |
26 Feb 07 |
jari |
889 |
HelpWindow hw = new HelpWindow(OneWayANOVAInitBox.this, "One Way ANOVA Initialization Dialog"); |
2 |
26 Feb 07 |
jari |
890 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
891 |
if(hw.getWindowContent()){ |
2 |
26 Feb 07 |
jari |
892 |
hw.setSize(450,600); |
2 |
26 Feb 07 |
jari |
893 |
hw.setLocation(); |
2 |
26 Feb 07 |
jari |
894 |
hw.show(); |
2 |
26 Feb 07 |
jari |
895 |
return; |
2 |
26 Feb 07 |
jari |
896 |
} |
2 |
26 Feb 07 |
jari |
897 |
else { |
2 |
26 Feb 07 |
jari |
898 |
hw.setVisible(false); |
2 |
26 Feb 07 |
jari |
899 |
hw.dispose(); |
2 |
26 Feb 07 |
jari |
900 |
return; |
2 |
26 Feb 07 |
jari |
901 |
} |
2 |
26 Feb 07 |
jari |
902 |
} |
2 |
26 Feb 07 |
jari |
903 |
} |
2 |
26 Feb 07 |
jari |
904 |
|
2 |
26 Feb 07 |
jari |
905 |
} |
2 |
26 Feb 07 |
jari |
906 |
|
2 |
26 Feb 07 |
jari |
907 |
public int[] getGroupAssignments() { |
2 |
26 Feb 07 |
jari |
908 |
int[] groupAssignments = new int[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
909 |
|
2 |
26 Feb 07 |
jari |
910 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
911 |
if (mPanel.mulgPanel.notInGroupRadioButtons[i].isSelected()) {// "NOT IN GROUP" IS STORED AS ZERO, AND GROUP J IS STORED AS THE INTEGER J (I.E., THERE IS NO GROUP 0) |
2 |
26 Feb 07 |
jari |
912 |
groupAssignments[i] = 0; |
2 |
26 Feb 07 |
jari |
913 |
} else { |
2 |
26 Feb 07 |
jari |
914 |
for (int j = 0; j < mPanel.mulgPanel.exptGroupRadioButtons.length; j++) { |
2 |
26 Feb 07 |
jari |
915 |
if (mPanel.mulgPanel.exptGroupRadioButtons[j][i].isSelected()) { |
2 |
26 Feb 07 |
jari |
916 |
groupAssignments[i] = j + 1; |
2 |
26 Feb 07 |
jari |
917 |
break; |
2 |
26 Feb 07 |
jari |
918 |
} |
2 |
26 Feb 07 |
jari |
919 |
} |
2 |
26 Feb 07 |
jari |
920 |
} |
2 |
26 Feb 07 |
jari |
921 |
} |
2 |
26 Feb 07 |
jari |
922 |
|
2 |
26 Feb 07 |
jari |
923 |
|
2 |
26 Feb 07 |
jari |
924 |
return groupAssignments; |
2 |
26 Feb 07 |
jari |
925 |
} |
2 |
26 Feb 07 |
jari |
926 |
|
2 |
26 Feb 07 |
jari |
927 |
public int getNumGroups() { |
2 |
26 Feb 07 |
jari |
928 |
return mPanel.numGroups; |
2 |
26 Feb 07 |
jari |
929 |
} |
2 |
26 Feb 07 |
jari |
930 |
|
2 |
26 Feb 07 |
jari |
931 |
public boolean usePerms() { |
2 |
26 Feb 07 |
jari |
932 |
return this.permPanel.permutButton.isSelected(); |
2 |
26 Feb 07 |
jari |
933 |
} |
2 |
26 Feb 07 |
jari |
934 |
|
2 |
26 Feb 07 |
jari |
935 |
public int getNumPerms() { |
2 |
26 Feb 07 |
jari |
936 |
return Integer.parseInt(this.permPanel.timesField.getText()); |
2 |
26 Feb 07 |
jari |
937 |
} |
2 |
26 Feb 07 |
jari |
938 |
|
2 |
26 Feb 07 |
jari |
939 |
public double getPValue() { |
2 |
26 Feb 07 |
jari |
940 |
return Double.parseDouble(pPanel.pValueInputField.getText()); |
2 |
26 Feb 07 |
jari |
941 |
} |
2 |
26 Feb 07 |
jari |
942 |
|
2 |
26 Feb 07 |
jari |
943 |
public int getFalseNum() { |
2 |
26 Feb 07 |
jari |
944 |
return Integer.parseInt(pPanel.falseNumField.getText()); |
2 |
26 Feb 07 |
jari |
945 |
} |
2 |
26 Feb 07 |
jari |
946 |
|
2 |
26 Feb 07 |
jari |
947 |
public double getFalseProp() { |
2 |
26 Feb 07 |
jari |
948 |
return Double.parseDouble(pPanel.falsePropField.getText()); |
2 |
26 Feb 07 |
jari |
949 |
} |
2 |
26 Feb 07 |
jari |
950 |
|
2 |
26 Feb 07 |
jari |
951 |
public boolean validateFalseNum() { |
2 |
26 Feb 07 |
jari |
952 |
int a; |
2 |
26 Feb 07 |
jari |
953 |
try { |
2 |
26 Feb 07 |
jari |
954 |
String falseNum = pPanel.falseNumField.getText(); |
2 |
26 Feb 07 |
jari |
955 |
a = Integer.parseInt(falseNum); |
2 |
26 Feb 07 |
jari |
956 |
} catch (NumberFormatException e) { |
2 |
26 Feb 07 |
jari |
957 |
JOptionPane.showMessageDialog(OneWayANOVAInitBox.this, "False number must be an integer >= 0", "Input Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
958 |
pPanel.falseNumField.requestFocus(); |
2 |
26 Feb 07 |
jari |
959 |
pPanel.falseNumField.selectAll(); |
2 |
26 Feb 07 |
jari |
960 |
return false; |
2 |
26 Feb 07 |
jari |
961 |
} |
2 |
26 Feb 07 |
jari |
962 |
if (a < 0) { |
2 |
26 Feb 07 |
jari |
963 |
JOptionPane.showMessageDialog(OneWayANOVAInitBox.this, "False number must be an integer >= 0", "Input Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
964 |
pPanel.falseNumField.requestFocus(); |
2 |
26 Feb 07 |
jari |
965 |
pPanel.falseNumField.selectAll(); |
2 |
26 Feb 07 |
jari |
966 |
return false; |
2 |
26 Feb 07 |
jari |
967 |
} |
2 |
26 Feb 07 |
jari |
968 |
return true; |
2 |
26 Feb 07 |
jari |
969 |
} |
2 |
26 Feb 07 |
jari |
970 |
|
2 |
26 Feb 07 |
jari |
971 |
public boolean validateFalseProp() { |
2 |
26 Feb 07 |
jari |
972 |
float a; |
2 |
26 Feb 07 |
jari |
973 |
try { |
2 |
26 Feb 07 |
jari |
974 |
String falseProp = pPanel.falsePropField.getText(); |
2 |
26 Feb 07 |
jari |
975 |
a = Float.parseFloat(falseProp); |
2 |
26 Feb 07 |
jari |
976 |
} catch (NumberFormatException e) { |
2 |
26 Feb 07 |
jari |
977 |
JOptionPane.showMessageDialog(OneWayANOVAInitBox.this, "False proportion must be between 0 and 1", "Input Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
978 |
pPanel.falsePropField.requestFocus(); |
2 |
26 Feb 07 |
jari |
979 |
pPanel.falsePropField.selectAll(); |
2 |
26 Feb 07 |
jari |
980 |
return false; |
2 |
26 Feb 07 |
jari |
981 |
} |
2 |
26 Feb 07 |
jari |
982 |
if ((a <= 0) || (a > 1)) { |
2 |
26 Feb 07 |
jari |
983 |
JOptionPane.showMessageDialog(OneWayANOVAInitBox.this, "False proportion must be between 0 and 1", "Input Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
984 |
pPanel.falsePropField.requestFocus(); |
2 |
26 Feb 07 |
jari |
985 |
pPanel.falsePropField.selectAll(); |
2 |
26 Feb 07 |
jari |
986 |
return false; |
2 |
26 Feb 07 |
jari |
987 |
} |
2 |
26 Feb 07 |
jari |
988 |
return true; |
2 |
26 Feb 07 |
jari |
989 |
} |
2 |
26 Feb 07 |
jari |
990 |
|
2 |
26 Feb 07 |
jari |
991 |
public int getCorrectionMethod() { |
2 |
26 Feb 07 |
jari |
992 |
int method = JUST_ALPHA; |
2 |
26 Feb 07 |
jari |
993 |
if (pPanel.justAlphaButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
994 |
method = JUST_ALPHA; |
2 |
26 Feb 07 |
jari |
995 |
} else if (pPanel.stdBonfButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
996 |
method = STD_BONFERRONI; |
2 |
26 Feb 07 |
jari |
997 |
} else if (pPanel.adjBonfButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
998 |
method = ADJ_BONFERRONI; |
2 |
26 Feb 07 |
jari |
999 |
} else if (pPanel.maxTButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
1000 |
method = MAX_T; |
2 |
26 Feb 07 |
jari |
1001 |
} else if (pPanel.falseNumButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
1002 |
method = FALSE_NUM; |
2 |
26 Feb 07 |
jari |
1003 |
} else if (pPanel.falsePropButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
1004 |
method = FALSE_PROP; |
2 |
26 Feb 07 |
jari |
1005 |
} |
2 |
26 Feb 07 |
jari |
1006 |
|
2 |
26 Feb 07 |
jari |
1007 |
return method; |
2 |
26 Feb 07 |
jari |
1008 |
} |
2 |
26 Feb 07 |
jari |
1009 |
|
2 |
26 Feb 07 |
jari |
1010 |
|
2 |
26 Feb 07 |
jari |
1011 |
public static void main(String[] args) { |
2 |
26 Feb 07 |
jari |
1012 |
JFrame dummyFrame = new JFrame(); |
2 |
26 Feb 07 |
jari |
1013 |
Vector dummyVect = new Vector(); |
2 |
26 Feb 07 |
jari |
1014 |
for (int i = 0; i < 100; i++) { |
2 |
26 Feb 07 |
jari |
1015 |
dummyVect.add("Expt " + i); |
2 |
26 Feb 07 |
jari |
1016 |
} |
2 |
26 Feb 07 |
jari |
1017 |
|
2 |
26 Feb 07 |
jari |
1018 |
OneWayANOVAInitBox oBox = new OneWayANOVAInitBox(dummyFrame, true, dummyVect); |
2 |
26 Feb 07 |
jari |
1019 |
oBox.setVisible(true); |
2 |
26 Feb 07 |
jari |
1020 |
|
2 |
26 Feb 07 |
jari |
1021 |
} |
2 |
26 Feb 07 |
jari |
1022 |
} |