2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2005, 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: TtestInitDialog.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.11 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/08/11 18:20:48 $ |
2 |
26 Feb 07 |
jari |
* $Author: eleanorahowe $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.microarray.mev.cluster.gui.impl.ttest; |
2 |
26 Feb 07 |
jari |
13 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Component; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Font; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Graphics; |
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.io.BufferedReader; |
2 |
26 Feb 07 |
jari |
25 |
import java.io.File; |
2 |
26 Feb 07 |
jari |
26 |
import java.io.FileOutputStream; |
2 |
26 Feb 07 |
jari |
27 |
import java.io.FileReader; |
2 |
26 Feb 07 |
jari |
28 |
import java.io.PrintWriter; |
2 |
26 Feb 07 |
jari |
29 |
import java.util.Vector; |
2 |
26 Feb 07 |
jari |
30 |
import javax.swing.BorderFactory; |
2 |
26 Feb 07 |
jari |
31 |
import javax.swing.ButtonGroup; |
2 |
26 Feb 07 |
jari |
32 |
import javax.swing.DefaultListModel; |
2 |
26 Feb 07 |
jari |
33 |
import javax.swing.JButton; |
2 |
26 Feb 07 |
jari |
34 |
import javax.swing.JCheckBox; |
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.JList; |
2 |
26 Feb 07 |
jari |
39 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
40 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
41 |
import javax.swing.JRadioButton; |
2 |
26 Feb 07 |
jari |
42 |
import javax.swing.JScrollPane; |
2 |
26 Feb 07 |
jari |
43 |
import javax.swing.JSplitPane; |
2 |
26 Feb 07 |
jari |
44 |
import javax.swing.JTabbedPane; |
2 |
26 Feb 07 |
jari |
45 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
46 |
import javax.swing.ScrollPaneConstants; |
2 |
26 Feb 07 |
jari |
47 |
import javax.swing.UIManager; |
2 |
26 Feb 07 |
jari |
48 |
import javax.swing.border.BevelBorder; |
2 |
26 Feb 07 |
jari |
49 |
import javax.swing.border.Border; |
2 |
26 Feb 07 |
jari |
50 |
import javax.swing.border.EtchedBorder; |
2 |
26 Feb 07 |
jari |
51 |
import javax.swing.border.TitledBorder; |
2 |
26 Feb 07 |
jari |
52 |
import javax.swing.event.ChangeEvent; |
2 |
26 Feb 07 |
jari |
53 |
import javax.swing.event.ChangeListener; |
2 |
26 Feb 07 |
jari |
54 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.AlgorithmDialog; |
2 |
26 Feb 07 |
jari |
55 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.HCLSigOnlyPanel; |
2 |
26 Feb 07 |
jari |
56 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.dialogHelpUtil.HelpWindow; |
2 |
26 Feb 07 |
jari |
57 |
import org.tigr.util.StringSplitter; |
2 |
26 Feb 07 |
jari |
58 |
/** |
2 |
26 Feb 07 |
jari |
59 |
* |
2 |
26 Feb 07 |
jari |
* @author nbhagaba |
2 |
26 Feb 07 |
jari |
* @version |
2 |
26 Feb 07 |
jari |
62 |
*/ |
2 |
26 Feb 07 |
jari |
63 |
public class TtestInitDialog extends AlgorithmDialog { |
2 |
26 Feb 07 |
jari |
64 |
|
2 |
26 Feb 07 |
jari |
65 |
GroupExperimentsPanel gPanel; |
2 |
26 Feb 07 |
jari |
66 |
OneClassPanel oPanel; |
2 |
26 Feb 07 |
jari |
67 |
TwoClassPairedMainPanel tcpmPanel; |
2 |
26 Feb 07 |
jari |
68 |
PValuePanel pPanel; |
2 |
26 Feb 07 |
jari |
69 |
SignificancePanel sPanel; |
2 |
26 Feb 07 |
jari |
//HCLSelectionPanel hclOpsPanel; |
2 |
26 Feb 07 |
jari |
71 |
HCLSigOnlyPanel hclOpsPanel; |
2 |
26 Feb 07 |
jari |
72 |
Vector exptNames; |
2 |
26 Feb 07 |
jari |
73 |
JTabbedPane chooseDesignPane; |
2 |
26 Feb 07 |
jari |
74 |
DfCalcPanel dPanel; |
2 |
26 Feb 07 |
jari |
75 |
|
2 |
26 Feb 07 |
jari |
76 |
boolean lotsOfSamples = false; |
2 |
26 Feb 07 |
jari |
77 |
String lotsOfSamplesWarningText = " Note: You can assign large numbers of samples quickly by using a saved text file."; |
2 |
26 Feb 07 |
jari |
78 |
|
2 |
26 Feb 07 |
jari |
79 |
public static final int GROUP_A = 1; |
2 |
26 Feb 07 |
jari |
80 |
public static final int GROUP_B = 2; |
2 |
26 Feb 07 |
jari |
81 |
public static final int NEITHER_GROUP = 3; |
2 |
26 Feb 07 |
jari |
82 |
public static final int JUST_ALPHA = 4; |
2 |
26 Feb 07 |
jari |
83 |
public static final int STD_BONFERRONI = 5; |
2 |
26 Feb 07 |
jari |
84 |
public static final int ADJ_BONFERRONI = 6; |
2 |
26 Feb 07 |
jari |
85 |
public static final int BETWEEN_SUBJECTS = 7; |
2 |
26 Feb 07 |
jari |
86 |
public static final int ONE_CLASS = 8; |
2 |
26 Feb 07 |
jari |
87 |
public static final int MAX_T = 9; |
2 |
26 Feb 07 |
jari |
88 |
public static final int MIN_P = 10; |
2 |
26 Feb 07 |
jari |
89 |
public static final int PAIRED = 11; |
2 |
26 Feb 07 |
jari |
90 |
public static final int FALSE_NUM = 12; |
2 |
26 Feb 07 |
jari |
91 |
public static final int FALSE_PROP = 13; |
2 |
26 Feb 07 |
jari |
92 |
|
2 |
26 Feb 07 |
jari |
93 |
boolean okPressed = false; |
2 |
26 Feb 07 |
jari |
94 |
boolean permParamOkPressed = false; |
2 |
26 Feb 07 |
jari |
95 |
private int userNumCombs = 0; |
2 |
26 Feb 07 |
jari |
96 |
private boolean allCombsUsed = false; |
2 |
26 Feb 07 |
jari |
97 |
private int allPossCombs; |
2 |
26 Feb 07 |
jari |
98 |
private Color LABEL_COLOR = UIManager.getColor("Label.foreground"); |
2 |
26 Feb 07 |
jari |
99 |
|
2 |
26 Feb 07 |
jari |
100 |
|
2 |
26 Feb 07 |
jari |
101 |
boolean tooMany = false; |
2 |
26 Feb 07 |
jari |
102 |
int count; |
2 |
26 Feb 07 |
jari |
103 |
|
2 |
26 Feb 07 |
jari |
104 |
final int fileLoadMin=20; |
2 |
26 Feb 07 |
jari |
/** Creates new TtestInitDialog */ |
2 |
26 Feb 07 |
jari |
106 |
public TtestInitDialog(JFrame parentFrame, boolean modality, Vector exptNames) { |
2 |
26 Feb 07 |
jari |
107 |
super(parentFrame, "TTEST: T-test", modality); |
2 |
26 Feb 07 |
jari |
108 |
this.exptNames = exptNames; |
2 |
26 Feb 07 |
jari |
109 |
setBounds(0, 0, 800, 850); |
2 |
26 Feb 07 |
jari |
110 |
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
2 |
26 Feb 07 |
jari |
111 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
112 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
113 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
114 |
JPanel pane = new JPanel(); |
2 |
26 Feb 07 |
jari |
115 |
pane.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
116 |
|
2 |
26 Feb 07 |
jari |
117 |
if(exptNames.size()>fileLoadMin){ |
2 |
26 Feb 07 |
jari |
118 |
lotsOfSamples = true; |
2 |
26 Feb 07 |
jari |
119 |
} |
2 |
26 Feb 07 |
jari |
120 |
|
2 |
26 Feb 07 |
jari |
121 |
chooseDesignPane = new JTabbedPane(); |
2 |
26 Feb 07 |
jari |
122 |
sPanel = new SignificancePanel(); |
2 |
26 Feb 07 |
jari |
123 |
pPanel = new PValuePanel(); |
2 |
26 Feb 07 |
jari |
124 |
gPanel = new GroupExperimentsPanel(exptNames); |
2 |
26 Feb 07 |
jari |
125 |
for (count = 0; count < gPanel.groupARadioButtons.length; count++) { |
2 |
26 Feb 07 |
jari |
126 |
gPanel.groupARadioButtons[count].addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
127 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
//if (evt.getSource() == gPanel.groupARadioButtons[count]) { |
2 |
26 Feb 07 |
jari |
129 |
pPanel.tDistButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
130 |
sPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
131 |
sPanel.maxTButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
132 |
sPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
133 |
sPanel.minPButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
134 |
sPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
135 |
pPanel.randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
136 |
pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
137 |
pPanel.timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
138 |
pPanel.numCombsLabel.setText(" "); |
2 |
26 Feb 07 |
jari |
139 |
//} |
2 |
26 Feb 07 |
jari |
140 |
} |
2 |
26 Feb 07 |
jari |
141 |
}); |
2 |
26 Feb 07 |
jari |
142 |
} |
2 |
26 Feb 07 |
jari |
143 |
for (count = 0; count < gPanel.groupBRadioButtons.length; count++) { |
2 |
26 Feb 07 |
jari |
144 |
gPanel.groupBRadioButtons[count].addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
145 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
//if (evt.getSource() == gPanel.groupBRadioButtons[count]) { |
2 |
26 Feb 07 |
jari |
147 |
pPanel.tDistButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
148 |
sPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
149 |
sPanel.maxTButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
150 |
sPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
151 |
sPanel.minPButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
152 |
sPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
153 |
pPanel.randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
154 |
pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
155 |
pPanel.timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
156 |
pPanel.numCombsLabel.setText(" "); |
2 |
26 Feb 07 |
jari |
157 |
//} |
2 |
26 Feb 07 |
jari |
158 |
} |
2 |
26 Feb 07 |
jari |
159 |
|
2 |
26 Feb 07 |
jari |
160 |
}); |
2 |
26 Feb 07 |
jari |
161 |
} |
2 |
26 Feb 07 |
jari |
162 |
|
2 |
26 Feb 07 |
jari |
163 |
for (count = 0; count < gPanel.neitherGroupRadioButtons.length; count++) { |
2 |
26 Feb 07 |
jari |
164 |
gPanel.neitherGroupRadioButtons[count].addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
165 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
//if (evt.getSource() == gPanel.neitherGroupRadioButtons[count]) { |
2 |
26 Feb 07 |
jari |
167 |
pPanel.tDistButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
168 |
sPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
169 |
sPanel.maxTButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
170 |
sPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
171 |
sPanel.minPButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
172 |
sPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
173 |
pPanel.randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
174 |
pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
175 |
pPanel.timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
176 |
pPanel.numCombsLabel.setText(" "); |
2 |
26 Feb 07 |
jari |
177 |
//} |
2 |
26 Feb 07 |
jari |
178 |
} |
2 |
26 Feb 07 |
jari |
179 |
|
2 |
26 Feb 07 |
jari |
180 |
}); |
2 |
26 Feb 07 |
jari |
181 |
} |
2 |
26 Feb 07 |
jari |
182 |
count = 0; |
2 |
26 Feb 07 |
jari |
183 |
oPanel = new OneClassPanel(); |
2 |
26 Feb 07 |
jari |
184 |
for (int i = 0; i < oPanel.includeExpts.length; i++) { |
2 |
26 Feb 07 |
jari |
185 |
oPanel.includeExpts[i].addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
186 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
//if (evt.getSource() == gPanel.neitherGroupRadioButtons[count]) { |
2 |
26 Feb 07 |
jari |
188 |
pPanel.tDistButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
189 |
sPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
190 |
sPanel.maxTButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
191 |
sPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
192 |
sPanel.minPButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
193 |
sPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
194 |
pPanel.randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
195 |
pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
196 |
pPanel.timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
197 |
pPanel.numCombsLabel.setText(" "); |
2 |
26 Feb 07 |
jari |
198 |
//} |
2 |
26 Feb 07 |
jari |
199 |
} |
2 |
26 Feb 07 |
jari |
200 |
}); |
2 |
26 Feb 07 |
jari |
201 |
} |
2 |
26 Feb 07 |
jari |
202 |
chooseDesignPane.add("One-class", oPanel); |
2 |
26 Feb 07 |
jari |
203 |
chooseDesignPane.add("Between subjects", gPanel); |
2 |
26 Feb 07 |
jari |
204 |
tcpmPanel = new TwoClassPairedMainPanel(); |
2 |
26 Feb 07 |
jari |
205 |
chooseDesignPane.add("Paired", tcpmPanel); |
2 |
26 Feb 07 |
jari |
206 |
pPanel.tDistButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
207 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
208 |
sPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
209 |
sPanel.maxTButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
210 |
sPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
211 |
sPanel.minPButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
212 |
sPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
213 |
sPanel.falseNumButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
214 |
sPanel.falsePropButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
215 |
sPanel.calcFDRPVals.setEnabled(false); |
2 |
26 Feb 07 |
jari |
216 |
sPanel.fastFDRButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
217 |
sPanel.slowFDRButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
218 |
sPanel.falseNumField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
219 |
sPanel.falsePropField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
220 |
} |
2 |
26 Feb 07 |
jari |
221 |
}); |
2 |
26 Feb 07 |
jari |
222 |
pPanel.permutButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
223 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
224 |
if (evt.getSource() == pPanel.permutButton) { |
2 |
26 Feb 07 |
jari |
225 |
sPanel.maxTButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
//sPanel.minPButton.setEnabled(true); // **** ENABLE THIS WHEN MINP MTHOD HAS BEEN DEBUGGED - 1/12/2004 |
2 |
26 Feb 07 |
jari |
227 |
sPanel.falseNumButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
228 |
sPanel.falsePropButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
//sPanel.calcFDRPVals.setEnabled(true); |
2 |
26 Feb 07 |
jari |
230 |
sPanel.fastFDRButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
//sPanel.slowFDRButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
232 |
sPanel.falseNumField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
233 |
sPanel.falsePropField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
234 |
|
2 |
26 Feb 07 |
jari |
235 |
if (getTestDesign() == TtestInitDialog.BETWEEN_SUBJECTS) { |
2 |
26 Feb 07 |
jari |
236 |
int[] grpAssignments = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
237 |
int grpACounter = 0; |
2 |
26 Feb 07 |
jari |
238 |
int grpBCounter = 0; |
2 |
26 Feb 07 |
jari |
239 |
for (int i = 0; i < grpAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
240 |
if (grpAssignments[i] == GROUP_A) { |
2 |
26 Feb 07 |
jari |
241 |
grpACounter++; |
2 |
26 Feb 07 |
jari |
242 |
} else if (grpAssignments[i] == GROUP_B) { |
2 |
26 Feb 07 |
jari |
243 |
grpBCounter++; |
2 |
26 Feb 07 |
jari |
244 |
} |
2 |
26 Feb 07 |
jari |
245 |
} |
2 |
26 Feb 07 |
jari |
246 |
if ((grpACounter < 2) || (grpBCounter < 2)) { |
2 |
26 Feb 07 |
jari |
247 |
pPanel.numCombsLabel.setForeground(Color.red); |
2 |
26 Feb 07 |
jari |
248 |
pPanel.numCombsLabel.setText("Error! Group A and Group B must each contain more than one sample"); |
2 |
26 Feb 07 |
jari |
//JOptionPane.showMessageDialog(gPanel, "Group A and Group B must each contain more than one experiment", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
250 |
} else { |
2 |
26 Feb 07 |
jari |
251 |
int numCombs = 0; |
2 |
26 Feb 07 |
jari |
252 |
pPanel.numCombsLabel.setForeground(Color.black); |
2 |
26 Feb 07 |
jari |
253 |
pPanel.numCombsLabel.setText("There are too many unique permutations "); |
2 |
26 Feb 07 |
jari |
254 |
pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
255 |
pPanel.randomGroupsButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
256 |
pPanel.randomGroupsButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
257 |
pPanel.timesField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
258 |
pPanel.timesField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
259 |
pPanel.timesField.setText("100"); |
2 |
26 Feb 07 |
jari |
//tooMany = true; |
2 |
26 Feb 07 |
jari |
261 |
if ((grpACounter + grpBCounter) <= 20) { |
2 |
26 Feb 07 |
jari |
262 |
numCombs = getNumCombs((grpACounter + grpBCounter), grpACounter); |
2 |
26 Feb 07 |
jari |
263 |
pPanel.numCombsLabel.setForeground(Color.black); |
2 |
26 Feb 07 |
jari |
264 |
pPanel.numCombsLabel.setText("There are " + numCombs + " unique permutations "); |
2 |
26 Feb 07 |
jari |
265 |
allPossCombs = numCombs; |
2 |
26 Feb 07 |
jari |
266 |
pPanel.allCombsButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
267 |
pPanel.randomGroupsButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
268 |
} |
2 |
26 Feb 07 |
jari |
269 |
} |
2 |
26 Feb 07 |
jari |
270 |
} else if (getTestDesign() == TtestInitDialog.ONE_CLASS) { |
2 |
26 Feb 07 |
jari |
271 |
pPanel.numCombsLabel.setForeground(Color.black); |
2 |
26 Feb 07 |
jari |
272 |
int validNum = getNumValidOneClassExpts(); |
2 |
26 Feb 07 |
jari |
273 |
if (validNum <= 1) { |
2 |
26 Feb 07 |
jari |
274 |
pPanel.numCombsLabel.setForeground(Color.red); |
2 |
26 Feb 07 |
jari |
275 |
pPanel.numCombsLabel.setText("Error! Choose at least two samples"); |
2 |
26 Feb 07 |
jari |
276 |
pPanel.randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
277 |
pPanel.timesField.setBackground(Color.gray); |
2 |
26 Feb 07 |
jari |
278 |
pPanel.timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
279 |
} else if (validNum <= 29) { |
2 |
26 Feb 07 |
jari |
280 |
pPanel.numCombsLabel.setText("There are " + (int)Math.pow(2, validNum) + " possible combinations "); |
2 |
26 Feb 07 |
jari |
281 |
pPanel.randomGroupsButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
282 |
pPanel.allCombsButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
283 |
pPanel.timesField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
284 |
pPanel.timesField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
285 |
} else { |
2 |
26 Feb 07 |
jari |
286 |
pPanel.numCombsLabel.setText("There are too many unique combinations "); |
2 |
26 Feb 07 |
jari |
287 |
pPanel.timesField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
288 |
pPanel.timesField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
289 |
pPanel.randomGroupsButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
290 |
pPanel.randomGroupsButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
291 |
} |
2 |
26 Feb 07 |
jari |
//pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
293 |
/* |
2 |
26 Feb 07 |
jari |
pPanel.randomGroupsButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
pPanel.randomGroupsButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
pPanel.timesField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
pPanel.timesField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
pPanel.timesField.setText("100"); |
2 |
26 Feb 07 |
jari |
299 |
*/ |
2 |
26 Feb 07 |
jari |
300 |
} else if (getTestDesign() == TtestInitDialog.PAIRED) { |
2 |
26 Feb 07 |
jari |
301 |
if (tcpmPanel.tcpPanel.pairedListModel.size() < 2) { |
2 |
26 Feb 07 |
jari |
302 |
JOptionPane.showMessageDialog(null, "Need at least two pairs of samples!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
303 |
} else { |
2 |
26 Feb 07 |
jari |
304 |
if (tcpmPanel.tcpPanel.pairedListModel.size() <= 29) { |
2 |
26 Feb 07 |
jari |
305 |
pPanel.numCombsLabel.setText("There are " + (int)(Math.pow(2, tcpmPanel.tcpPanel.pairedListModel.size())) + " possible combinations "); |
2 |
26 Feb 07 |
jari |
306 |
pPanel.randomGroupsButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
307 |
pPanel.allCombsButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
308 |
pPanel.timesField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
309 |
pPanel.timesField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
310 |
} else { |
2 |
26 Feb 07 |
jari |
311 |
pPanel.numCombsLabel.setText("There are too many unique combinations "); |
2 |
26 Feb 07 |
jari |
312 |
pPanel.timesField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
313 |
pPanel.timesField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
314 |
pPanel.randomGroupsButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
315 |
pPanel.randomGroupsButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
316 |
} |
2 |
26 Feb 07 |
jari |
317 |
} |
2 |
26 Feb 07 |
jari |
318 |
} |
2 |
26 Feb 07 |
jari |
319 |
} |
2 |
26 Feb 07 |
jari |
320 |
} |
2 |
26 Feb 07 |
jari |
321 |
}); |
2 |
26 Feb 07 |
jari |
322 |
chooseDesignPane.addChangeListener(new ChangeListener() { |
2 |
26 Feb 07 |
jari |
323 |
public void stateChanged(ChangeEvent e) { |
2 |
26 Feb 07 |
jari |
324 |
pPanel.tDistButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
325 |
sPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
326 |
sPanel.maxTButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
327 |
sPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
328 |
sPanel.minPButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
329 |
sPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
330 |
pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
331 |
pPanel.randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
332 |
pPanel.numCombsLabel.setForeground(Color.black); |
2 |
26 Feb 07 |
jari |
333 |
pPanel.numCombsLabel.setText(""); |
2 |
26 Feb 07 |
jari |
334 |
pPanel.timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
335 |
if (getTestDesign() == TtestInitDialog.ONE_CLASS) { |
2 |
26 Feb 07 |
jari |
336 |
pPanel.numCombsLabel.setForeground(Color.black); |
2 |
26 Feb 07 |
jari |
337 |
pPanel.numCombsLabel.setText(""); |
2 |
26 Feb 07 |
jari |
338 |
} |
2 |
26 Feb 07 |
jari |
339 |
} |
2 |
26 Feb 07 |
jari |
340 |
}); |
2 |
26 Feb 07 |
jari |
341 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 45); |
2 |
26 Feb 07 |
jari |
342 |
gridbag.setConstraints(chooseDesignPane, constraints); |
2 |
26 Feb 07 |
jari |
343 |
pane.add(chooseDesignPane); |
2 |
26 Feb 07 |
jari |
344 |
|
2 |
26 Feb 07 |
jari |
345 |
dPanel = new DfCalcPanel(); |
2 |
26 Feb 07 |
jari |
346 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 5); |
2 |
26 Feb 07 |
jari |
347 |
gridbag.setConstraints(dPanel, constraints); |
2 |
26 Feb 07 |
jari |
348 |
pane.add(dPanel); |
2 |
26 Feb 07 |
jari |
349 |
|
2 |
26 Feb 07 |
jari |
350 |
buildConstraints(constraints, 0, 2, 1, 1, 0, 20); |
2 |
26 Feb 07 |
jari |
351 |
gridbag.setConstraints(pPanel, constraints); |
2 |
26 Feb 07 |
jari |
352 |
pane.add(pPanel); |
2 |
26 Feb 07 |
jari |
353 |
|
2 |
26 Feb 07 |
jari |
//sPanel = new SignificancePanel(); |
2 |
26 Feb 07 |
jari |
355 |
buildConstraints(constraints, 0, 3, 1, 1, 0, 25); |
2 |
26 Feb 07 |
jari |
356 |
gridbag.setConstraints(sPanel, constraints); |
2 |
26 Feb 07 |
jari |
357 |
pane.add(sPanel); |
2 |
26 Feb 07 |
jari |
358 |
|
2 |
26 Feb 07 |
jari |
359 |
hclOpsPanel = new HCLSigOnlyPanel(); |
2 |
26 Feb 07 |
jari |
360 |
buildConstraints(constraints, 0, 4, 1, 1, 0, 5); |
2 |
26 Feb 07 |
jari |
361 |
gridbag.setConstraints(hclOpsPanel, constraints); |
2 |
26 Feb 07 |
jari |
362 |
|
2 |
26 Feb 07 |
jari |
363 |
pane.add(hclOpsPanel); |
2 |
26 Feb 07 |
jari |
364 |
addContent(pane); |
2 |
26 Feb 07 |
jari |
365 |
|
2 |
26 Feb 07 |
jari |
366 |
EventListener listener = new EventListener(); |
2 |
26 Feb 07 |
jari |
367 |
setActionListeners(listener); |
2 |
26 Feb 07 |
jari |
368 |
} |
2 |
26 Feb 07 |
jari |
369 |
|
2 |
26 Feb 07 |
jari |
370 |
|
2 |
26 Feb 07 |
jari |
371 |
public void setVisible(boolean visible) { |
2 |
26 Feb 07 |
jari |
372 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
373 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
374 |
|
2 |
26 Feb 07 |
jari |
375 |
super.setVisible(visible); |
2 |
26 Feb 07 |
jari |
376 |
} |
2 |
26 Feb 07 |
jari |
377 |
|
2 |
26 Feb 07 |
jari |
378 |
void buildConstraints(GridBagConstraints gbc, int gx, int gy, |
2 |
26 Feb 07 |
jari |
379 |
int gw, int gh, int wx, int wy) { |
2 |
26 Feb 07 |
jari |
380 |
gbc.gridx = gx; |
2 |
26 Feb 07 |
jari |
381 |
gbc.gridy = gy; |
2 |
26 Feb 07 |
jari |
382 |
gbc.gridwidth = gw; |
2 |
26 Feb 07 |
jari |
383 |
gbc.gridheight = gh; |
2 |
26 Feb 07 |
jari |
384 |
gbc.weightx = wx; |
2 |
26 Feb 07 |
jari |
385 |
gbc.weighty = wy; |
2 |
26 Feb 07 |
jari |
386 |
} |
2 |
26 Feb 07 |
jari |
387 |
|
2 |
26 Feb 07 |
jari |
388 |
class TwoClassPairedMainPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
389 |
TwoClassPairedPanel tcpPanel; |
2 |
26 Feb 07 |
jari |
390 |
JButton saveButton, resetButton, loadButton; |
2 |
26 Feb 07 |
jari |
391 |
GridBagConstraints constraints; |
2 |
26 Feb 07 |
jari |
392 |
GridBagLayout gridbag; |
2 |
26 Feb 07 |
jari |
393 |
JLabel lotsOfSamplesWarningLabel; |
2 |
26 Feb 07 |
jari |
394 |
|
2 |
26 Feb 07 |
jari |
395 |
public TwoClassPairedMainPanel() { |
2 |
26 Feb 07 |
jari |
396 |
tcpPanel = new TwoClassPairedPanel(); |
2 |
26 Feb 07 |
jari |
397 |
JPanel bottomPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
398 |
bottomPanel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
399 |
constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
400 |
gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
401 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
402 |
|
2 |
26 Feb 07 |
jari |
403 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 90); |
2 |
26 Feb 07 |
jari |
404 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
405 |
gridbag.setConstraints(tcpPanel, constraints); |
2 |
26 Feb 07 |
jari |
406 |
this.add(tcpPanel); |
2 |
26 Feb 07 |
jari |
407 |
|
2 |
26 Feb 07 |
jari |
408 |
if(lotsOfSamples){ |
2 |
26 Feb 07 |
jari |
409 |
lotsOfSamplesWarningLabel = new JLabel(lotsOfSamplesWarningText); |
2 |
26 Feb 07 |
jari |
410 |
lotsOfSamplesWarningLabel.setBackground(Color.gray); |
2 |
26 Feb 07 |
jari |
411 |
this.add(lotsOfSamplesWarningLabel, new GridBagConstraints(0,1,3,1,0,0,GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
412 |
} |
2 |
26 Feb 07 |
jari |
413 |
|
2 |
26 Feb 07 |
jari |
414 |
GridBagLayout grid1 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
415 |
bottomPanel.setLayout(grid1); |
2 |
26 Feb 07 |
jari |
416 |
|
2 |
26 Feb 07 |
jari |
417 |
saveButton = new JButton("Save pairings"); |
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(TwoClassPairedMainPanel.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 |
for (int i = 0; i < tcpPanel.pairedAExpts.size(); i++) { |
2 |
26 Feb 07 |
jari |
430 |
int currentA = ((Integer)(tcpPanel.pairedAExpts.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
431 |
int currentB = ((Integer)(tcpPanel.pairedBExpts.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
432 |
out.print(currentA); |
2 |
26 Feb 07 |
jari |
433 |
out.print("\t"); |
2 |
26 Feb 07 |
jari |
434 |
out.print(currentB); |
2 |
26 Feb 07 |
jari |
435 |
out.print("\t"); |
2 |
26 Feb 07 |
jari |
436 |
out.println(); |
2 |
26 Feb 07 |
jari |
437 |
} |
2 |
26 Feb 07 |
jari |
438 |
out.flush(); |
2 |
26 Feb 07 |
jari |
439 |
out.close(); |
2 |
26 Feb 07 |
jari |
440 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
441 |
} |
2 |
26 Feb 07 |
jari |
442 |
} else { |
2 |
26 Feb 07 |
jari |
443 |
} |
2 |
26 Feb 07 |
jari |
444 |
} |
2 |
26 Feb 07 |
jari |
445 |
}); |
2 |
26 Feb 07 |
jari |
446 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
447 |
buildConstraints(constraints, 0, 1, 1, 1, 33, 100); |
2 |
26 Feb 07 |
jari |
448 |
grid1.setConstraints(saveButton, constraints); |
2 |
26 Feb 07 |
jari |
449 |
bottomPanel.add(saveButton); |
2 |
26 Feb 07 |
jari |
450 |
|
2 |
26 Feb 07 |
jari |
451 |
loadButton = new JButton("Load pairings"); |
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 |
//tcpPanel.reset(); |
2 |
26 Feb 07 |
jari |
456 |
int returnVal = fc.showOpenDialog(TwoClassPairedMainPanel.this); |
2 |
26 Feb 07 |
jari |
457 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
458 |
tcpPanel.reset(); |
2 |
26 Feb 07 |
jari |
459 |
try { |
2 |
26 Feb 07 |
jari |
460 |
FileReader file = new FileReader(fc.getSelectedFile()); |
2 |
26 Feb 07 |
jari |
461 |
BufferedReader buff = new BufferedReader(file); |
2 |
26 Feb 07 |
jari |
462 |
String currentLine; |
2 |
26 Feb 07 |
jari |
463 |
while((currentLine = buff.readLine()) != null) { |
2 |
26 Feb 07 |
jari |
464 |
StringSplitter st = new StringSplitter('\t'); |
2 |
26 Feb 07 |
jari |
465 |
st.init(currentLine); |
2 |
26 Feb 07 |
jari |
466 |
|
2 |
26 Feb 07 |
jari |
467 |
for (int i = 0; i < 2; i++) { |
2 |
26 Feb 07 |
jari |
468 |
String s = st.nextToken(); |
2 |
26 Feb 07 |
jari |
469 |
if (i == 0) { |
2 |
26 Feb 07 |
jari |
470 |
tcpPanel.pairedAExpts.add(new Integer(s)); |
2 |
26 Feb 07 |
jari |
471 |
} else if (i == 1) { |
2 |
26 Feb 07 |
jari |
472 |
tcpPanel.pairedBExpts.add(new Integer(s)); |
2 |
26 Feb 07 |
jari |
473 |
} |
2 |
26 Feb 07 |
jari |
474 |
} |
2 |
26 Feb 07 |
jari |
475 |
|
2 |
26 Feb 07 |
jari |
476 |
} |
2 |
26 Feb 07 |
jari |
477 |
buff.close(); |
2 |
26 Feb 07 |
jari |
478 |
|
2 |
26 Feb 07 |
jari |
479 |
for (int i = 0; i < tcpPanel.pairedAExpts.size(); i++) { |
2 |
26 Feb 07 |
jari |
480 |
int currA = ((Integer)(tcpPanel.pairedAExpts.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
481 |
int currB = ((Integer)(tcpPanel.pairedBExpts.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
482 |
String currPair = "A: " + (String)(exptNames.get(currA)) + " - B: " + (String)(exptNames.get(currB)); |
2 |
26 Feb 07 |
jari |
483 |
tcpPanel.exptButtons[currA].setEnabled(false); |
2 |
26 Feb 07 |
jari |
484 |
tcpPanel.exptButtons[currB].setEnabled(false); |
2 |
26 Feb 07 |
jari |
485 |
tcpPanel.pairedListModel.addElement(currPair); |
2 |
26 Feb 07 |
jari |
486 |
|
2 |
26 Feb 07 |
jari |
487 |
} |
2 |
26 Feb 07 |
jari |
488 |
if (tcpPanel.pairedAExpts.size() > 0) { |
2 |
26 Feb 07 |
jari |
489 |
tcpPanel.removeABPairButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
490 |
tcpPanel.pairedExptsList.setSelectedIndex(tcpPanel.pairedListModel.size() - 1); |
2 |
26 Feb 07 |
jari |
491 |
} |
2 |
26 Feb 07 |
jari |
492 |
|
2 |
26 Feb 07 |
jari |
493 |
pPanel.tDistButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
494 |
sPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
495 |
sPanel.maxTButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
496 |
sPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
497 |
sPanel.minPButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
498 |
sPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
499 |
pPanel.randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
500 |
pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
501 |
pPanel.timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
502 |
pPanel.numCombsLabel.setText(" "); |
2 |
26 Feb 07 |
jari |
503 |
|
2 |
26 Feb 07 |
jari |
504 |
} catch (Exception exc) { |
2 |
26 Feb 07 |
jari |
505 |
JOptionPane.showMessageDialog(tcpPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
506 |
} |
2 |
26 Feb 07 |
jari |
507 |
} else { |
2 |
26 Feb 07 |
jari |
508 |
} |
2 |
26 Feb 07 |
jari |
509 |
} |
2 |
26 Feb 07 |
jari |
510 |
}); |
2 |
26 Feb 07 |
jari |
511 |
|
2 |
26 Feb 07 |
jari |
512 |
buildConstraints(constraints, 1, 1, 1, 1, 33, 100); |
2 |
26 Feb 07 |
jari |
513 |
grid1.setConstraints(loadButton, constraints); |
2 |
26 Feb 07 |
jari |
514 |
bottomPanel.add(loadButton); |
2 |
26 Feb 07 |
jari |
515 |
|
2 |
26 Feb 07 |
jari |
516 |
resetButton = new JButton("Reset"); |
2 |
26 Feb 07 |
jari |
517 |
|
2 |
26 Feb 07 |
jari |
518 |
resetButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
519 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
520 |
tcpPanel.reset(); |
2 |
26 Feb 07 |
jari |
521 |
|
2 |
26 Feb 07 |
jari |
522 |
pPanel.tDistButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
523 |
sPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
524 |
sPanel.maxTButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
525 |
sPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
526 |
sPanel.minPButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
527 |
sPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
528 |
pPanel.randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
529 |
pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
530 |
pPanel.timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
531 |
pPanel.numCombsLabel.setText(" "); |
2 |
26 Feb 07 |
jari |
532 |
} |
2 |
26 Feb 07 |
jari |
533 |
}); |
2 |
26 Feb 07 |
jari |
534 |
|
2 |
26 Feb 07 |
jari |
535 |
buildConstraints(constraints, 2, 1, 1, 1, 34, 100); |
2 |
26 Feb 07 |
jari |
536 |
grid1.setConstraints(resetButton, constraints); |
2 |
26 Feb 07 |
jari |
537 |
bottomPanel.add(resetButton); |
2 |
26 Feb 07 |
jari |
538 |
|
2 |
26 Feb 07 |
jari |
539 |
|
2 |
26 Feb 07 |
jari |
540 |
buildConstraints(constraints, 0, 2, 1, 1, 0, 10); |
2 |
26 Feb 07 |
jari |
541 |
gridbag.setConstraints(bottomPanel, constraints); |
2 |
26 Feb 07 |
jari |
542 |
this.add(bottomPanel); |
2 |
26 Feb 07 |
jari |
543 |
} |
2 |
26 Feb 07 |
jari |
544 |
} |
2 |
26 Feb 07 |
jari |
545 |
|
2 |
26 Feb 07 |
jari |
546 |
class TwoClassPairedPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
547 |
ExperimentButton[] exptButtons; |
2 |
26 Feb 07 |
jari |
548 |
GridBagConstraints constraints; |
2 |
26 Feb 07 |
jari |
549 |
GridBagLayout gridbag; |
2 |
26 Feb 07 |
jari |
550 |
JTextField currentATextField, currentBTextField; |
2 |
26 Feb 07 |
jari |
551 |
JButton removeCurrentAButton, removeCurrentBButton, loadABPairButton, removeABPairButton; |
2 |
26 Feb 07 |
jari |
552 |
PairedExperimentsPanel pairPanel; |
2 |
26 Feb 07 |
jari |
553 |
JList pairedExptsList; |
2 |
26 Feb 07 |
jari |
554 |
DefaultListModel pairedListModel; |
2 |
26 Feb 07 |
jari |
555 |
boolean currentAFilled, currentBFilled; |
2 |
26 Feb 07 |
jari |
556 |
int currentAExpt, currentBExpt; |
2 |
26 Feb 07 |
jari |
557 |
int numPanels = 0; |
2 |
26 Feb 07 |
jari |
558 |
Vector pairedAExpts, pairedBExpts; |
2 |
26 Feb 07 |
jari |
559 |
|
2 |
26 Feb 07 |
jari |
560 |
public TwoClassPairedPanel() { |
2 |
26 Feb 07 |
jari |
561 |
currentAExpt = -1; |
2 |
26 Feb 07 |
jari |
562 |
currentBExpt = -1; |
2 |
26 Feb 07 |
jari |
563 |
currentAFilled = false; |
2 |
26 Feb 07 |
jari |
564 |
currentBFilled = false; |
2 |
26 Feb 07 |
jari |
565 |
pairedAExpts = new Vector(); |
2 |
26 Feb 07 |
jari |
566 |
pairedBExpts = new Vector(); |
2 |
26 Feb 07 |
jari |
567 |
constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
568 |
gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
569 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
570 |
|
2 |
26 Feb 07 |
jari |
571 |
pairedListModel = new DefaultListModel(); |
2 |
26 Feb 07 |
jari |
572 |
pairedExptsList = new JList(pairedListModel); |
2 |
26 Feb 07 |
jari |
573 |
numPanels = exptNames.size()/512 + 1; |
2 |
26 Feb 07 |
jari |
574 |
JPanel [] panels = new JPanel[numPanels]; |
2 |
26 Feb 07 |
jari |
575 |
|
2 |
26 Feb 07 |
jari |
576 |
int currPanel = 0; |
2 |
26 Feb 07 |
jari |
577 |
for(int i = 0; i < panels.length; i++) { |
2 |
26 Feb 07 |
jari |
578 |
panels[i] = new JPanel(gridbag); |
2 |
26 Feb 07 |
jari |
579 |
} |
2 |
26 Feb 07 |
jari |
580 |
exptButtons = new ExperimentButton[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
581 |
|
2 |
26 Feb 07 |
jari |
582 |
int maxWidth = 0; |
2 |
26 Feb 07 |
jari |
583 |
int maxNameLength = 0; |
2 |
26 Feb 07 |
jari |
584 |
|
2 |
26 Feb 07 |
jari |
585 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
586 |
exptButtons[i] = new ExperimentButton(i); |
2 |
26 Feb 07 |
jari |
//set current panel |
2 |
26 Feb 07 |
jari |
588 |
currPanel = i / 512; |
2 |
26 Feb 07 |
jari |
589 |
|
2 |
26 Feb 07 |
jari |
590 |
if (exptButtons[i].getPreferredSize().getWidth() > maxWidth) { |
2 |
26 Feb 07 |
jari |
591 |
maxWidth = (int)Math.ceil(exptButtons[i].getPreferredSize().getWidth()); |
2 |
26 Feb 07 |
jari |
592 |
} |
2 |
26 Feb 07 |
jari |
593 |
|
2 |
26 Feb 07 |
jari |
594 |
String s = (String)(exptNames.get(i)); |
2 |
26 Feb 07 |
jari |
595 |
int currentNameLength = s.length(); |
2 |
26 Feb 07 |
jari |
596 |
|
2 |
26 Feb 07 |
jari |
597 |
if (currentNameLength > maxNameLength) { |
2 |
26 Feb 07 |
jari |
598 |
maxNameLength = currentNameLength; |
2 |
26 Feb 07 |
jari |
599 |
} |
2 |
26 Feb 07 |
jari |
600 |
buildConstraints(constraints, 0, i%512, 1, 1, 100, 100); |
2 |
26 Feb 07 |
jari |
601 |
gridbag.setConstraints(exptButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
602 |
panels[currPanel].add(exptButtons[i]); |
2 |
26 Feb 07 |
jari |
603 |
} |
2 |
26 Feb 07 |
jari |
604 |
|
2 |
26 Feb 07 |
jari |
605 |
currentATextField = new JTextField("", maxNameLength + 2); |
2 |
26 Feb 07 |
jari |
606 |
currentBTextField = new JTextField("", maxNameLength + 2); |
2 |
26 Feb 07 |
jari |
607 |
|
2 |
26 Feb 07 |
jari |
608 |
currentATextField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
609 |
currentBTextField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
610 |
currentATextField.setEditable(false); |
2 |
26 Feb 07 |
jari |
611 |
currentBTextField.setEditable(false); |
2 |
26 Feb 07 |
jari |
612 |
JPanel bigPanel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
613 |
|
2 |
26 Feb 07 |
jari |
614 |
for(int i = 0; i < numPanels; i++) { |
2 |
26 Feb 07 |
jari |
615 |
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 |
616 |
} |
2 |
26 Feb 07 |
jari |
617 |
|
2 |
26 Feb 07 |
jari |
618 |
JScrollPane scroll = new JScrollPane(bigPanel); |
2 |
26 Feb 07 |
jari |
619 |
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
620 |
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
621 |
|
2 |
26 Feb 07 |
jari |
622 |
buildConstraints(constraints, 0, 0, 1, 1, 40, 100); |
2 |
26 Feb 07 |
jari |
623 |
constraints.fill =GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
624 |
gridbag.setConstraints(scroll, constraints); |
2 |
26 Feb 07 |
jari |
625 |
this.add(scroll); |
2 |
26 Feb 07 |
jari |
626 |
|
2 |
26 Feb 07 |
jari |
627 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
628 |
|
2 |
26 Feb 07 |
jari |
629 |
JPanel currentSelectionPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
630 |
GridBagLayout grid2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
631 |
currentSelectionPanel.setLayout(grid2); |
2 |
26 Feb 07 |
jari |
632 |
removeCurrentAButton = new JButton("< Remove A"); |
2 |
26 Feb 07 |
jari |
633 |
removeCurrentBButton = new JButton("< Remove B"); |
2 |
26 Feb 07 |
jari |
634 |
loadABPairButton = new JButton(" Load Pair >> "); |
2 |
26 Feb 07 |
jari |
635 |
removeABPairButton = new JButton("<< Remove Pair"); |
2 |
26 Feb 07 |
jari |
636 |
removeCurrentAButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
637 |
removeCurrentBButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
638 |
loadABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
639 |
removeABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
640 |
removeCurrentAButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
641 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
642 |
exptButtons[currentAExpt].setEnabled(true); |
2 |
26 Feb 07 |
jari |
643 |
currentAExpt = -1; |
2 |
26 Feb 07 |
jari |
644 |
currentATextField.setText(""); |
2 |
26 Feb 07 |
jari |
645 |
currentAFilled = false; |
2 |
26 Feb 07 |
jari |
646 |
removeCurrentAButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
647 |
loadABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
648 |
} |
2 |
26 Feb 07 |
jari |
649 |
}); |
2 |
26 Feb 07 |
jari |
650 |
|
2 |
26 Feb 07 |
jari |
651 |
removeCurrentBButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
652 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
653 |
exptButtons[currentBExpt].setEnabled(true); |
2 |
26 Feb 07 |
jari |
654 |
currentBExpt = -1; |
2 |
26 Feb 07 |
jari |
655 |
currentBTextField.setText(""); |
2 |
26 Feb 07 |
jari |
656 |
currentBFilled = false; |
2 |
26 Feb 07 |
jari |
657 |
removeCurrentBButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
658 |
loadABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
659 |
} |
2 |
26 Feb 07 |
jari |
660 |
}); |
2 |
26 Feb 07 |
jari |
661 |
|
2 |
26 Feb 07 |
jari |
662 |
loadABPairButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
663 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
664 |
String currentPair = "A: " + (String)(exptNames.get(currentAExpt)) + " - B: " + (String)(exptNames.get(currentBExpt)); |
2 |
26 Feb 07 |
jari |
665 |
pairedListModel.addElement(currentPair); |
2 |
26 Feb 07 |
jari |
666 |
pairedAExpts.add(new Integer(currentAExpt)); |
2 |
26 Feb 07 |
jari |
667 |
pairedBExpts.add(new Integer(currentBExpt)); |
2 |
26 Feb 07 |
jari |
668 |
currentAExpt = -1; |
2 |
26 Feb 07 |
jari |
669 |
currentBExpt = -1; |
2 |
26 Feb 07 |
jari |
670 |
currentATextField.setText(""); |
2 |
26 Feb 07 |
jari |
671 |
currentBTextField.setText(""); |
2 |
26 Feb 07 |
jari |
672 |
currentAFilled = false; |
2 |
26 Feb 07 |
jari |
673 |
currentBFilled = false; |
2 |
26 Feb 07 |
jari |
674 |
removeCurrentAButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
675 |
removeCurrentBButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
676 |
loadABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
677 |
removeABPairButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
678 |
pairedExptsList.setSelectedIndex(pairedListModel.size() - 1); |
2 |
26 Feb 07 |
jari |
679 |
|
2 |
26 Feb 07 |
jari |
680 |
pPanel.tDistButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
681 |
sPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
682 |
sPanel.maxTButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
683 |
sPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
684 |
sPanel.minPButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
685 |
sPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
686 |
pPanel.randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
687 |
pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
688 |
pPanel.timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
689 |
pPanel.numCombsLabel.setText(" "); |
2 |
26 Feb 07 |
jari |
690 |
} |
2 |
26 Feb 07 |
jari |
691 |
}); |
2 |
26 Feb 07 |
jari |
692 |
|
2 |
26 Feb 07 |
jari |
693 |
removeABPairButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
694 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
695 |
int index = pairedExptsList.getSelectedIndex(); |
2 |
26 Feb 07 |
jari |
696 |
pairedListModel.removeElementAt(index); |
2 |
26 Feb 07 |
jari |
697 |
int removedAIndex = ((Integer)(pairedAExpts.remove(index))).intValue(); |
2 |
26 Feb 07 |
jari |
698 |
int removedBIndex = ((Integer)(pairedBExpts.remove(index))).intValue(); |
2 |
26 Feb 07 |
jari |
699 |
exptButtons[removedAIndex].setEnabled(true); |
2 |
26 Feb 07 |
jari |
700 |
exptButtons[removedBIndex].setEnabled(true); |
2 |
26 Feb 07 |
jari |
701 |
if (pairedListModel.isEmpty()) { |
2 |
26 Feb 07 |
jari |
702 |
removeABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
703 |
} else { |
2 |
26 Feb 07 |
jari |
704 |
pairedExptsList.setSelectedIndex(pairedListModel.size() - 1); |
2 |
26 Feb 07 |
jari |
705 |
} |
2 |
26 Feb 07 |
jari |
706 |
|
2 |
26 Feb 07 |
jari |
707 |
pPanel.tDistButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
708 |
sPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
709 |
sPanel.maxTButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
710 |
sPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
711 |
sPanel.minPButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
712 |
sPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
713 |
pPanel.randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
714 |
pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
715 |
pPanel.timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
716 |
pPanel.numCombsLabel.setText(" "); |
2 |
26 Feb 07 |
jari |
717 |
} |
2 |
26 Feb 07 |
jari |
718 |
}); |
2 |
26 Feb 07 |
jari |
719 |
JScrollPane currentAScroll = new JScrollPane(currentATextField); |
2 |
26 Feb 07 |
jari |
720 |
currentAScroll.setMinimumSize(new Dimension(90, 50)); |
2 |
26 Feb 07 |
jari |
721 |
JScrollPane currentBScroll = new JScrollPane(currentBTextField); |
2 |
26 Feb 07 |
jari |
722 |
currentBScroll.setMinimumSize(new Dimension(90, 50)); |
2 |
26 Feb 07 |
jari |
723 |
|
2 |
26 Feb 07 |
jari |
724 |
currentAScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
725 |
currentAScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); |
2 |
26 Feb 07 |
jari |
726 |
|
2 |
26 Feb 07 |
jari |
727 |
currentBScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
728 |
currentBScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); |
2 |
26 Feb 07 |
jari |
729 |
|
2 |
26 Feb 07 |
jari |
730 |
buildConstraints(constraints, 0, 0, 1, 1, 20, 50); |
2 |
26 Feb 07 |
jari |
731 |
grid2.setConstraints(removeCurrentAButton, constraints); |
2 |
26 Feb 07 |
jari |
732 |
currentSelectionPanel.add(removeCurrentAButton); |
2 |
26 Feb 07 |
jari |
733 |
|
2 |
26 Feb 07 |
jari |
734 |
JLabel aLabel = new JLabel(" Current A: "); |
2 |
26 Feb 07 |
jari |
735 |
buildConstraints(constraints, 1, 0, 1, 1, 20, 0); |
2 |
26 Feb 07 |
jari |
736 |
grid2.setConstraints(aLabel, constraints); |
2 |
26 Feb 07 |
jari |
737 |
currentSelectionPanel.add(aLabel); |
2 |
26 Feb 07 |
jari |
738 |
|
2 |
26 Feb 07 |
jari |
739 |
buildConstraints(constraints, 2, 0, 1, 1, 60, 0); |
2 |
26 Feb 07 |
jari |
740 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
//constraints.ipady = 100; |
2 |
26 Feb 07 |
jari |
742 |
grid2.setConstraints(currentAScroll, constraints); |
2 |
26 Feb 07 |
jari |
743 |
currentSelectionPanel.add(currentAScroll); |
2 |
26 Feb 07 |
jari |
744 |
|
2 |
26 Feb 07 |
jari |
//constraints.ipady = 0; |
2 |
26 Feb 07 |
jari |
746 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
747 |
|
2 |
26 Feb 07 |
jari |
748 |
buildConstraints(constraints, 0, 1, 1, 1, 20, 50); |
2 |
26 Feb 07 |
jari |
749 |
grid2.setConstraints(removeCurrentBButton, constraints); |
2 |
26 Feb 07 |
jari |
750 |
currentSelectionPanel.add(removeCurrentBButton); |
2 |
26 Feb 07 |
jari |
751 |
|
2 |
26 Feb 07 |
jari |
752 |
JLabel bLabel = new JLabel("Current B: "); |
2 |
26 Feb 07 |
jari |
753 |
buildConstraints(constraints, 1, 1, 1, 1, 20, 0); |
2 |
26 Feb 07 |
jari |
754 |
grid2.setConstraints(bLabel, constraints); |
2 |
26 Feb 07 |
jari |
755 |
currentSelectionPanel.add(bLabel); |
2 |
26 Feb 07 |
jari |
756 |
|
2 |
26 Feb 07 |
jari |
757 |
buildConstraints(constraints, 2, 1, 1, 1, 60, 0); |
2 |
26 Feb 07 |
jari |
758 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
//constraints.ipady = 100; |
2 |
26 Feb 07 |
jari |
760 |
grid2.setConstraints(currentBScroll, constraints); |
2 |
26 Feb 07 |
jari |
761 |
currentSelectionPanel.add(currentBScroll); |
2 |
26 Feb 07 |
jari |
762 |
|
2 |
26 Feb 07 |
jari |
//constraints.ipady = 0; |
2 |
26 Feb 07 |
jari |
764 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
765 |
|
2 |
26 Feb 07 |
jari |
766 |
buildConstraints(constraints, 1, 0, 1, 1, 10, 0); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.HORIZONTAL; |
2 |
26 Feb 07 |
jari |
//constraints.ipadx = 200; |
2 |
26 Feb 07 |
jari |
769 |
gridbag.setConstraints(currentSelectionPanel, constraints); |
2 |
26 Feb 07 |
jari |
770 |
this.add(currentSelectionPanel); |
2 |
26 Feb 07 |
jari |
771 |
|
2 |
26 Feb 07 |
jari |
772 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
//constraints.ipadx = 0; |
2 |
26 Feb 07 |
jari |
774 |
|
2 |
26 Feb 07 |
jari |
775 |
JPanel pairButtonsPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
776 |
GridBagLayout grid3 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
777 |
pairButtonsPanel.setLayout(grid3); |
2 |
26 Feb 07 |
jari |
778 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 50); |
2 |
26 Feb 07 |
jari |
779 |
grid3.setConstraints(loadABPairButton, constraints); |
2 |
26 Feb 07 |
jari |
780 |
pairButtonsPanel.add(loadABPairButton); |
2 |
26 Feb 07 |
jari |
781 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 50); |
2 |
26 Feb 07 |
jari |
782 |
grid3.setConstraints(removeABPairButton, constraints); |
2 |
26 Feb 07 |
jari |
783 |
pairButtonsPanel.add(removeABPairButton); |
2 |
26 Feb 07 |
jari |
784 |
|
2 |
26 Feb 07 |
jari |
785 |
buildConstraints(constraints, 2, 0, 1, 1, 5, 0); |
2 |
26 Feb 07 |
jari |
786 |
gridbag.setConstraints(pairButtonsPanel, constraints); |
2 |
26 Feb 07 |
jari |
787 |
this.add(pairButtonsPanel); |
2 |
26 Feb 07 |
jari |
788 |
|
2 |
26 Feb 07 |
jari |
789 |
buildConstraints(constraints, 3, 0, 1, 1, 45, 0); |
2 |
26 Feb 07 |
jari |
790 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
791 |
JScrollPane pairScroll = new JScrollPane(pairedExptsList); |
2 |
26 Feb 07 |
jari |
792 |
pairScroll.setBorder(new TitledBorder("Paired Samples")); |
2 |
26 Feb 07 |
jari |
793 |
gridbag.setConstraints(pairScroll, constraints); |
2 |
26 Feb 07 |
jari |
794 |
this.add(pairScroll); |
2 |
26 Feb 07 |
jari |
795 |
} |
2 |
26 Feb 07 |
jari |
796 |
|
2 |
26 Feb 07 |
jari |
797 |
public void reset() { |
2 |
26 Feb 07 |
jari |
798 |
for (int i = 0; i < exptButtons.length; i++) { |
2 |
26 Feb 07 |
jari |
799 |
exptButtons[i].setEnabled(true); |
2 |
26 Feb 07 |
jari |
800 |
currentATextField.setText(""); |
2 |
26 Feb 07 |
jari |
801 |
currentBTextField.setText(""); |
2 |
26 Feb 07 |
jari |
802 |
removeCurrentAButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
803 |
removeCurrentBButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
804 |
loadABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
805 |
removeABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
806 |
pairedListModel.clear(); |
2 |
26 Feb 07 |
jari |
807 |
currentAFilled = false; |
2 |
26 Feb 07 |
jari |
808 |
currentBFilled = false; |
2 |
26 Feb 07 |
jari |
809 |
currentAExpt = -1; |
2 |
26 Feb 07 |
jari |
810 |
currentBExpt = -1; |
2 |
26 Feb 07 |
jari |
811 |
pairedAExpts.clear(); |
2 |
26 Feb 07 |
jari |
812 |
pairedBExpts.clear(); |
2 |
26 Feb 07 |
jari |
813 |
} |
2 |
26 Feb 07 |
jari |
814 |
} |
2 |
26 Feb 07 |
jari |
815 |
|
2 |
26 Feb 07 |
jari |
816 |
class ExperimentButton extends JButton { |
2 |
26 Feb 07 |
jari |
817 |
String s; |
2 |
26 Feb 07 |
jari |
818 |
int index; |
2 |
26 Feb 07 |
jari |
819 |
public ExperimentButton(int i) { |
2 |
26 Feb 07 |
jari |
820 |
this.index = i; |
2 |
26 Feb 07 |
jari |
821 |
s = (String)(exptNames.get(i)); |
2 |
26 Feb 07 |
jari |
822 |
this.setText(s); |
2 |
26 Feb 07 |
jari |
823 |
this.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
824 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
825 |
if ((currentAFilled)&&(currentBFilled)) { |
2 |
26 Feb 07 |
jari |
826 |
JOptionPane.showMessageDialog(null, "Clear at least one current field first!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
827 |
} else if (!currentAFilled) { |
2 |
26 Feb 07 |
jari |
828 |
currentAExpt = index; |
2 |
26 Feb 07 |
jari |
829 |
currentATextField.setText(s); |
2 |
26 Feb 07 |
jari |
830 |
currentAFilled = true; |
2 |
26 Feb 07 |
jari |
831 |
ExperimentButton.this.setEnabled(false); |
2 |
26 Feb 07 |
jari |
832 |
removeCurrentAButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
833 |
} else if (!currentBFilled) { |
2 |
26 Feb 07 |
jari |
834 |
currentBExpt = index; |
2 |
26 Feb 07 |
jari |
835 |
currentBTextField.setText(s); |
2 |
26 Feb 07 |
jari |
836 |
currentBFilled = true; |
2 |
26 Feb 07 |
jari |
837 |
ExperimentButton.this.setEnabled(false); |
2 |
26 Feb 07 |
jari |
838 |
removeCurrentBButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
839 |
} |
2 |
26 Feb 07 |
jari |
840 |
|
2 |
26 Feb 07 |
jari |
841 |
if ((currentAFilled) && (currentBFilled)) { |
2 |
26 Feb 07 |
jari |
842 |
loadABPairButton.setEnabled(true); |
2 |
26 Feb 07 |
jari |
843 |
} else { |
2 |
26 Feb 07 |
jari |
844 |
loadABPairButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
845 |
} |
2 |
26 Feb 07 |
jari |
846 |
} |
2 |
26 Feb 07 |
jari |
847 |
}); |
2 |
26 Feb 07 |
jari |
848 |
} |
2 |
26 Feb 07 |
jari |
849 |
} |
2 |
26 Feb 07 |
jari |
850 |
|
2 |
26 Feb 07 |
jari |
851 |
class PairedExperimentsPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
852 |
public PairedExperimentsPanel() { |
2 |
26 Feb 07 |
jari |
//this.setBorder(new TitledBorder("Paired Experiments")); |
2 |
26 Feb 07 |
jari |
854 |
} |
2 |
26 Feb 07 |
jari |
855 |
} |
2 |
26 Feb 07 |
jari |
856 |
} |
2 |
26 Feb 07 |
jari |
857 |
class OneClassPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
858 |
JTextField meanField; |
2 |
26 Feb 07 |
jari |
859 |
JCheckBox[] includeExpts; |
2 |
26 Feb 07 |
jari |
860 |
int numPanels = 0; |
2 |
26 Feb 07 |
jari |
861 |
JButton saveButton, loadButton, resetButton; |
2 |
26 Feb 07 |
jari |
862 |
JLabel lotsOfSamplesWarningLabel; |
2 |
26 Feb 07 |
jari |
863 |
|
2 |
26 Feb 07 |
jari |
864 |
OneClassPanel() { |
2 |
26 Feb 07 |
jari |
865 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
866 |
JLabel meanLabel = new JLabel("Enter the mean value to be tested against: "); |
2 |
26 Feb 07 |
jari |
867 |
meanField = new JTextField("0", 7); |
2 |
26 Feb 07 |
jari |
868 |
includeExpts = new JCheckBox[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
869 |
|
2 |
26 Feb 07 |
jari |
870 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
871 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
872 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
873 |
numPanels = exptNames.size()/512 + 1; |
2 |
26 Feb 07 |
jari |
874 |
JPanel [] panels = new JPanel[numPanels]; |
2 |
26 Feb 07 |
jari |
875 |
|
2 |
26 Feb 07 |
jari |
876 |
int currPanel = 0; |
2 |
26 Feb 07 |
jari |
877 |
for(int i = 0; i < panels.length; i++) { |
2 |
26 Feb 07 |
jari |
878 |
panels[i] = new JPanel(gridbag); |
2 |
26 Feb 07 |
jari |
879 |
} |
2 |
26 Feb 07 |
jari |
880 |
|
2 |
26 Feb 07 |
jari |
881 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
//set current panel |
2 |
26 Feb 07 |
jari |
883 |
currPanel = i / 512; |
2 |
26 Feb 07 |
jari |
//JLabel expLabel = new JLabel((String)(exptNames.get(i))); |
2 |
26 Feb 07 |
jari |
885 |
includeExpts[i] = new JCheckBox((String)(exptNames.get(i)), true); |
2 |
26 Feb 07 |
jari |
886 |
buildConstraints(constraints, 0, i%512, 1, 1, 100, 100); |
2 |
26 Feb 07 |
jari |
887 |
gridbag.setConstraints(includeExpts[i], constraints); |
2 |
26 Feb 07 |
jari |
888 |
panels[currPanel].add(includeExpts[i]); |
2 |
26 Feb 07 |
jari |
889 |
} |
2 |
26 Feb 07 |
jari |
890 |
JPanel bigPanel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
891 |
|
2 |
26 Feb 07 |
jari |
892 |
for(int i = 0; i < numPanels; i++) { |
2 |
26 Feb 07 |
jari |
893 |
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 |
894 |
} |
2 |
26 Feb 07 |
jari |
895 |
|
2 |
26 Feb 07 |
jari |
896 |
JScrollPane scroll = new JScrollPane(bigPanel); |
2 |
26 Feb 07 |
jari |
897 |
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
898 |
|
2 |
26 Feb 07 |
jari |
899 |
JPanel enterMeanPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
900 |
GridBagLayout grid2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
901 |
enterMeanPanel.setLayout(grid2); |
2 |
26 Feb 07 |
jari |
902 |
|
2 |
26 Feb 07 |
jari |
903 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
904 |
buildConstraints(constraints, 0, 0, 1, 1, 50, 100); |
2 |
26 Feb 07 |
jari |
905 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
906 |
grid2.setConstraints(meanLabel, constraints); |
2 |
26 Feb 07 |
jari |
907 |
enterMeanPanel.add(meanLabel); |
2 |
26 Feb 07 |
jari |
908 |
|
2 |
26 Feb 07 |
jari |
909 |
buildConstraints(constraints, 1, 0, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
910 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
911 |
grid2.setConstraints(meanField, constraints); |
2 |
26 Feb 07 |
jari |
912 |
enterMeanPanel.add(meanField); |
2 |
26 Feb 07 |
jari |
913 |
|
2 |
26 Feb 07 |
jari |
914 |
JScrollPane scroll2 = new JScrollPane(enterMeanPanel); |
2 |
26 Feb 07 |
jari |
915 |
|
2 |
26 Feb 07 |
jari |
916 |
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scroll, scroll2); |
2 |
26 Feb 07 |
jari |
917 |
split.setOneTouchExpandable(true); |
2 |
26 Feb 07 |
jari |
918 |
split.setDividerLocation(150); |
2 |
26 Feb 07 |
jari |
919 |
|
2 |
26 Feb 07 |
jari |
920 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
921 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 80); |
2 |
26 Feb 07 |
jari |
922 |
gridbag.setConstraints(split, constraints); |
2 |
26 Feb 07 |
jari |
923 |
this.add(split); |
2 |
26 Feb 07 |
jari |
924 |
|
2 |
26 Feb 07 |
jari |
925 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
926 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
927 |
|
2 |
26 Feb 07 |
jari |
928 |
if(lotsOfSamples){ |
2 |
26 Feb 07 |
jari |
929 |
lotsOfSamplesWarningLabel = new JLabel(lotsOfSamplesWarningText); |
2 |
26 Feb 07 |
jari |
930 |
this.add(lotsOfSamplesWarningLabel, new GridBagConstraints(0,1,1,1,0,0,GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
931 |
} |
2 |
26 Feb 07 |
jari |
932 |
|
2 |
26 Feb 07 |
jari |
933 |
JPanel lsrPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
934 |
loadButton = new JButton("Load settings"); |
2 |
26 Feb 07 |
jari |
935 |
saveButton = new JButton("Save settings"); |
2 |
26 Feb 07 |
jari |
936 |
resetButton = new JButton("Reset"); |
2 |
26 Feb 07 |
jari |
937 |
|
2 |
26 Feb 07 |
jari |
938 |
resetButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
939 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
940 |
for (int i = 0; i < includeExpts.length; i++) { |
2 |
26 Feb 07 |
jari |
941 |
includeExpts[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
942 |
} |
2 |
26 Feb 07 |
jari |
943 |
pPanel.tDistButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
944 |
sPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
945 |
sPanel.maxTButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
946 |
sPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
947 |
sPanel.minPButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
948 |
sPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
949 |
pPanel.randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
950 |
pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
951 |
pPanel.timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
952 |
pPanel.numCombsLabel.setText(" "); |
2 |
26 Feb 07 |
jari |
953 |
} |
2 |
26 Feb 07 |
jari |
954 |
}); |
2 |
26 Feb 07 |
jari |
955 |
final JFileChooser fc = new JFileChooser(); |
2 |
26 Feb 07 |
jari |
956 |
fc.setCurrentDirectory(new File("Data")); |
2 |
26 Feb 07 |
jari |
957 |
|
2 |
26 Feb 07 |
jari |
958 |
saveButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
959 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
960 |
int returnVal = fc.showSaveDialog(OneClassPanel.this); |
2 |
26 Feb 07 |
jari |
961 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
962 |
File file = fc.getSelectedFile(); |
2 |
26 Feb 07 |
jari |
963 |
try { |
2 |
26 Feb 07 |
jari |
964 |
PrintWriter out = new PrintWriter(new FileOutputStream(file)); |
2 |
26 Feb 07 |
jari |
965 |
for (int i = 0; i < includeExpts.length; i++) { |
2 |
26 Feb 07 |
jari |
966 |
if (includeExpts[i].isSelected()) { |
2 |
26 Feb 07 |
jari |
967 |
out.print(1); |
2 |
26 Feb 07 |
jari |
968 |
} else { |
2 |
26 Feb 07 |
jari |
969 |
out.print(0); |
2 |
26 Feb 07 |
jari |
970 |
} |
2 |
26 Feb 07 |
jari |
971 |
if (i < includeExpts.length - 1) { |
2 |
26 Feb 07 |
jari |
972 |
out.print("\t"); |
2 |
26 Feb 07 |
jari |
973 |
} |
2 |
26 Feb 07 |
jari |
974 |
} |
2 |
26 Feb 07 |
jari |
975 |
out.println(); |
2 |
26 Feb 07 |
jari |
976 |
out.flush(); |
2 |
26 Feb 07 |
jari |
977 |
out.close(); |
2 |
26 Feb 07 |
jari |
978 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
979 |
} |
2 |
26 Feb 07 |
jari |
980 |
} else { |
2 |
26 Feb 07 |
jari |
981 |
} |
2 |
26 Feb 07 |
jari |
982 |
} |
2 |
26 Feb 07 |
jari |
983 |
}); |
2 |
26 Feb 07 |
jari |
984 |
|
2 |
26 Feb 07 |
jari |
985 |
loadButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
986 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
987 |
int returnVal = fc.showOpenDialog(OneClassPanel.this); |
2 |
26 Feb 07 |
jari |
988 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
989 |
pPanel.tDistButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
990 |
sPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
991 |
sPanel.maxTButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
992 |
sPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
993 |
sPanel.minPButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
994 |
sPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
995 |
pPanel.randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
996 |
pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
997 |
pPanel.timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
998 |
pPanel.numCombsLabel.setText(" "); |
2 |
26 Feb 07 |
jari |
999 |
|
2 |
26 Feb 07 |
jari |
1000 |
try { |
2 |
26 Feb 07 |
jari |
1001 |
FileReader file = new FileReader(fc.getSelectedFile()); |
2 |
26 Feb 07 |
jari |
1002 |
BufferedReader buff = new BufferedReader(file); |
2 |
26 Feb 07 |
jari |
1003 |
String line = buff.readLine(); |
2 |
26 Feb 07 |
jari |
//System.out.println(line); |
2 |
26 Feb 07 |
jari |
1005 |
StringSplitter st = new StringSplitter('\t'); |
2 |
26 Feb 07 |
jari |
1006 |
st.init(line); |
2 |
26 Feb 07 |
jari |
1007 |
Vector includeExptsVector = new Vector(); |
2 |
26 Feb 07 |
jari |
1008 |
while (st.hasMoreTokens()) { |
2 |
26 Feb 07 |
jari |
1009 |
String current = st.nextToken(); |
2 |
26 Feb 07 |
jari |
1010 |
includeExptsVector.add(new Integer(current)); |
2 |
26 Feb 07 |
jari |
//System.out.print(current); |
2 |
26 Feb 07 |
jari |
1012 |
} |
2 |
26 Feb 07 |
jari |
1013 |
buff.close(); |
2 |
26 Feb 07 |
jari |
1014 |
if (includeExptsVector.size() != includeExpts.length) { |
2 |
26 Feb 07 |
jari |
1015 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
1016 |
} else { |
2 |
26 Feb 07 |
jari |
1017 |
for (int i = 0; i < includeExpts.length; i++) { |
2 |
26 Feb 07 |
jari |
1018 |
int currentState = ((Integer)(includeExptsVector.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
1019 |
if (currentState == 0) { |
2 |
26 Feb 07 |
jari |
1020 |
includeExpts[i].setSelected(false); |
2 |
26 Feb 07 |
jari |
1021 |
} else if (currentState == 1) { |
2 |
26 Feb 07 |
jari |
1022 |
includeExpts[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
1023 |
}else { |
2 |
26 Feb 07 |
jari |
1024 |
for (int j = 0; j < includeExpts.length; j++) { |
2 |
26 Feb 07 |
jari |
1025 |
includeExpts[j].setSelected(true); |
2 |
26 Feb 07 |
jari |
1026 |
} |
2 |
26 Feb 07 |
jari |
1027 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
1028 |
break; |
2 |
26 Feb 07 |
jari |
1029 |
} |
2 |
26 Feb 07 |
jari |
1030 |
} |
2 |
26 Feb 07 |
jari |
1031 |
} |
2 |
26 Feb 07 |
jari |
1032 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
1033 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
1034 |
|
2 |
26 Feb 07 |
jari |
1035 |
} |
2 |
26 Feb 07 |
jari |
1036 |
} else { |
2 |
26 Feb 07 |
jari |
1037 |
} |
2 |
26 Feb 07 |
jari |
1038 |
} |
2 |
26 Feb 07 |
jari |
1039 |
}); |
2 |
26 Feb 07 |
jari |
1040 |
|
2 |
26 Feb 07 |
jari |
1041 |
|
2 |
26 Feb 07 |
jari |
1042 |
GridBagLayout grid3 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1043 |
lsrPanel.setLayout(grid3); |
2 |
26 Feb 07 |
jari |
1044 |
|
2 |
26 Feb 07 |
jari |
1045 |
buildConstraints(constraints, 0, 1, 1, 1, 33, 100); |
2 |
26 Feb 07 |
jari |
1046 |
grid3.setConstraints(saveButton, constraints); |
2 |
26 Feb 07 |
jari |
1047 |
lsrPanel.add(saveButton); |
2 |
26 Feb 07 |
jari |
1048 |
|
2 |
26 Feb 07 |
jari |
1049 |
buildConstraints(constraints, 1, 1, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
1050 |
grid3.setConstraints(loadButton, constraints); |
2 |
26 Feb 07 |
jari |
1051 |
lsrPanel.add(loadButton); |
2 |
26 Feb 07 |
jari |
1052 |
|
2 |
26 Feb 07 |
jari |
1053 |
buildConstraints(constraints, 2, 1, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
1054 |
grid3.setConstraints(resetButton, constraints); |
2 |
26 Feb 07 |
jari |
1055 |
lsrPanel.add(resetButton); |
2 |
26 Feb 07 |
jari |
1056 |
|
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1058 |
buildConstraints(constraints, 0, 2, 1, 1, 0, 20); |
2 |
26 Feb 07 |
jari |
1059 |
gridbag.setConstraints(lsrPanel, constraints); |
2 |
26 Feb 07 |
jari |
1060 |
this.add(lsrPanel); |
2 |
26 Feb 07 |
jari |
1061 |
} |
2 |
26 Feb 07 |
jari |
1062 |
|
2 |
26 Feb 07 |
jari |
1063 |
|
2 |
26 Feb 07 |
jari |
1064 |
public void reset() { |
2 |
26 Feb 07 |
jari |
1065 |
for (int i = 0; i < includeExpts.length; i++) { |
2 |
26 Feb 07 |
jari |
1066 |
includeExpts[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
1067 |
} |
2 |
26 Feb 07 |
jari |
1068 |
meanField.setText("0"); |
2 |
26 Feb 07 |
jari |
1069 |
} |
2 |
26 Feb 07 |
jari |
1070 |
} |
2 |
26 Feb 07 |
jari |
1071 |
|
2 |
26 Feb 07 |
jari |
1072 |
class GroupExperimentsPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
1073 |
JLabel[] expLabels; |
2 |
26 Feb 07 |
jari |
1074 |
JLabel lotsOfSamplesWarningLabel; |
2 |
26 Feb 07 |
jari |
1075 |
int numPanels = 0; |
2 |
26 Feb 07 |
jari |
1076 |
JRadioButton[] groupARadioButtons, groupBRadioButtons, neitherGroupRadioButtons; |
2 |
26 Feb 07 |
jari |
1077 |
GroupExperimentsPanel(Vector exptNames) { |
2 |
26 Feb 07 |
jari |
1078 |
this.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Group Assignments", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
1079 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1080 |
numPanels = exptNames.size()/512 + 1; |
2 |
26 Feb 07 |
jari |
1081 |
expLabels = new JLabel[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
1082 |
groupARadioButtons = new JRadioButton[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
1083 |
groupBRadioButtons = new JRadioButton[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
1084 |
neitherGroupRadioButtons = new JRadioButton[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
1085 |
ButtonGroup chooseGroup[] = new ButtonGroup[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
1086 |
|
2 |
26 Feb 07 |
jari |
1087 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1088 |
GridBagLayout gridbag2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1089 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
1090 |
this.setLayout(gridbag2); |
2 |
26 Feb 07 |
jari |
1091 |
JPanel [] panels = new JPanel[numPanels]; |
2 |
26 Feb 07 |
jari |
1092 |
|
2 |
26 Feb 07 |
jari |
1093 |
int currPanel = 0; |
2 |
26 Feb 07 |
jari |
1094 |
for(int i = 0; i < panels.length; i++) { |
2 |
26 Feb 07 |
jari |
1095 |
panels[i] = new JPanel(gridbag); |
2 |
26 Feb 07 |
jari |
1096 |
} |
2 |
26 Feb 07 |
jari |
1097 |
|
2 |
26 Feb 07 |
jari |
1098 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
//set current panel |
2 |
26 Feb 07 |
jari |
1100 |
currPanel = i / 512; |
2 |
26 Feb 07 |
jari |
1101 |
String s1 = (String)(exptNames.get(i));//permut |
2 |
26 Feb 07 |
jari |
1102 |
expLabels[i] = new JLabel(s1); |
2 |
26 Feb 07 |
jari |
1103 |
expLabels[i].setForeground(Color.black); |
2 |
26 Feb 07 |
jari |
1104 |
chooseGroup[i] = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
1105 |
groupARadioButtons[i] = new JRadioButton("Group A", true); |
2 |
26 Feb 07 |
jari |
// groupARadioButtons[i].setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
// groupARadioButtons[i].setForeground(LABEL_COLOR); |
2 |
26 Feb 07 |
jari |
1108 |
|
2 |
26 Feb 07 |
jari |
1109 |
chooseGroup[i].add(groupARadioButtons[i]); |
2 |
26 Feb 07 |
jari |
1110 |
groupBRadioButtons[i] = new JRadioButton("Group B", false); |
2 |
26 Feb 07 |
jari |
//groupBRadioButtons[i].setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
//groupBRadioButtons[i].setForeground(LABEL_COLOR); |
2 |
26 Feb 07 |
jari |
1113 |
|
2 |
26 Feb 07 |
jari |
1114 |
chooseGroup[i].add(groupBRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
1115 |
|
2 |
26 Feb 07 |
jari |
1116 |
neitherGroupRadioButtons[i] = new JRadioButton("Neither group", false); |
2 |
26 Feb 07 |
jari |
// neitherGroupRadioButtons[i].setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
//neitherGroupRadioButtons[i].setForeground(LABEL_COLOR); |
2 |
26 Feb 07 |
jari |
1119 |
|
2 |
26 Feb 07 |
jari |
1120 |
chooseGroup[i].add(neitherGroupRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
1121 |
buildConstraints(constraints, 0, i%512, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1123 |
gridbag.setConstraints(expLabels[i], constraints); |
2 |
26 Feb 07 |
jari |
1124 |
|
2 |
26 Feb 07 |
jari |
1125 |
panels[currPanel].add(expLabels[i]); |
2 |
26 Feb 07 |
jari |
1126 |
|
2 |
26 Feb 07 |
jari |
1127 |
buildConstraints(constraints, 1, i%512, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1129 |
gridbag.setConstraints(groupARadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
1130 |
|
2 |
26 Feb 07 |
jari |
1131 |
panels[currPanel].add(groupARadioButtons[i]); |
2 |
26 Feb 07 |
jari |
1132 |
|
2 |
26 Feb 07 |
jari |
1133 |
buildConstraints(constraints, 2, i%512, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1135 |
gridbag.setConstraints(groupBRadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
1136 |
|
2 |
26 Feb 07 |
jari |
1137 |
panels[currPanel].add(groupBRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
1138 |
|
2 |
26 Feb 07 |
jari |
1139 |
buildConstraints(constraints, 3, i%512, 1, 1, 25, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1141 |
gridbag.setConstraints(neitherGroupRadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
1142 |
|
2 |
26 Feb 07 |
jari |
1143 |
panels[currPanel].add(neitherGroupRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
1144 |
|
2 |
26 Feb 07 |
jari |
1145 |
} |
2 |
26 Feb 07 |
jari |
1146 |
JPanel bigPanel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
1147 |
for(int i = 0; i < numPanels; i++) { |
2 |
26 Feb 07 |
jari |
1148 |
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 |
1149 |
} |
2 |
26 Feb 07 |
jari |
1150 |
|
2 |
26 Feb 07 |
jari |
1151 |
JScrollPane scroll = new JScrollPane(bigPanel); |
2 |
26 Feb 07 |
jari |
1152 |
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
1153 |
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
1154 |
scroll.setBorder(BorderFactory.createLineBorder(Color.black,2)); |
2 |
26 Feb 07 |
jari |
1155 |
|
2 |
26 Feb 07 |
jari |
1156 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 90); |
2 |
26 Feb 07 |
jari |
1157 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1158 |
gridbag2.setConstraints(scroll, constraints); |
2 |
26 Feb 07 |
jari |
1159 |
this.add(scroll); |
2 |
26 Feb 07 |
jari |
1160 |
|
2 |
26 Feb 07 |
jari |
1161 |
JLabel label1 = new JLabel(" Note: Group A and Group B MUST each contain more than one sample."); |
2 |
26 Feb 07 |
jari |
1162 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 5); |
2 |
26 Feb 07 |
jari |
1163 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
1164 |
gridbag2.setConstraints(label1, constraints); |
2 |
26 Feb 07 |
jari |
1165 |
this.add(label1); |
2 |
26 Feb 07 |
jari |
1166 |
|
2 |
26 Feb 07 |
jari |
1167 |
if(lotsOfSamples){ |
2 |
26 Feb 07 |
jari |
1168 |
lotsOfSamplesWarningLabel = new JLabel(lotsOfSamplesWarningText); |
2 |
26 Feb 07 |
jari |
1169 |
this.add(lotsOfSamplesWarningLabel, new GridBagConstraints(0,2,1,1,0,0,GridBagConstraints.CENTER,GridBagConstraints.BOTH, new Insets(0,0,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
1170 |
} |
2 |
26 Feb 07 |
jari |
1171 |
|
2 |
26 Feb 07 |
jari |
1172 |
JPanel panel2 = new JPanel(); |
2 |
26 Feb 07 |
jari |
1173 |
panel2.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1174 |
GridBagLayout gridbag3 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1175 |
panel2.setLayout(gridbag3); |
2 |
26 Feb 07 |
jari |
1176 |
|
2 |
26 Feb 07 |
jari |
1177 |
JButton saveButton = new JButton(" Save grouping "); |
2 |
26 Feb 07 |
jari |
1178 |
saveButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.gray, new Color(185,185,185), Color.darkGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
1179 |
saveButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1180 |
saveButton.setPreferredSize(new Dimension(100,30)); |
2 |
26 Feb 07 |
jari |
1181 |
JButton loadButton = new JButton(" Load grouping "); |
2 |
26 Feb 07 |
jari |
1182 |
loadButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.gray, new Color(185,185,185), Color.darkGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
1183 |
loadButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1184 |
loadButton.setPreferredSize(new Dimension(100,30)); |
2 |
26 Feb 07 |
jari |
1185 |
JButton resetButton = new JButton(" Reset "); |
2 |
26 Feb 07 |
jari |
1186 |
resetButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.gray, new Color(185,185,185), Color.darkGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
1187 |
resetButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1188 |
resetButton.setPreferredSize(new Dimension(55,30)); |
2 |
26 Feb 07 |
jari |
1189 |
final int finNum = exptNames.size(); |
2 |
26 Feb 07 |
jari |
1190 |
|
2 |
26 Feb 07 |
jari |
1191 |
resetButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
1192 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1193 |
for (int i = 0; i < finNum; i++) { |
2 |
26 Feb 07 |
jari |
1194 |
groupARadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
1195 |
} |
2 |
26 Feb 07 |
jari |
1196 |
|
2 |
26 Feb 07 |
jari |
1197 |
pPanel.tDistButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
1198 |
sPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
1199 |
sPanel.maxTButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
1200 |
sPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1201 |
sPanel.minPButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
1202 |
sPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1203 |
pPanel.randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1204 |
pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1205 |
pPanel.timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1206 |
pPanel.numCombsLabel.setText(" "); |
2 |
26 Feb 07 |
jari |
1207 |
} |
2 |
26 Feb 07 |
jari |
1208 |
}); |
2 |
26 Feb 07 |
jari |
1209 |
|
2 |
26 Feb 07 |
jari |
1210 |
final JFileChooser fc = new JFileChooser(); |
2 |
26 Feb 07 |
jari |
1211 |
fc.setCurrentDirectory(new File("Data")); |
2 |
26 Feb 07 |
jari |
1212 |
|
2 |
26 Feb 07 |
jari |
1213 |
saveButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
1214 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1215 |
int returnVal = fc.showSaveDialog(GroupExperimentsPanel.this); |
2 |
26 Feb 07 |
jari |
1216 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
1217 |
File file = fc.getSelectedFile(); |
2 |
26 Feb 07 |
jari |
1218 |
try { |
2 |
26 Feb 07 |
jari |
1219 |
PrintWriter out = new PrintWriter(new FileOutputStream(file)); |
2 |
26 Feb 07 |
jari |
1220 |
int[] groupAssgn = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
1221 |
for (int i = 0; i < groupAssgn.length; i++) { |
2 |
26 Feb 07 |
jari |
1222 |
out.print(groupAssgn[i]); |
2 |
26 Feb 07 |
jari |
1223 |
if (i < groupAssgn.length - 1) { |
2 |
26 Feb 07 |
jari |
1224 |
out.print("\t"); |
2 |
26 Feb 07 |
jari |
1225 |
} |
2 |
26 Feb 07 |
jari |
1226 |
} |
2 |
26 Feb 07 |
jari |
1227 |
out.println(); |
2 |
26 Feb 07 |
jari |
1228 |
out.flush(); |
2 |
26 Feb 07 |
jari |
1229 |
out.close(); |
2 |
26 Feb 07 |
jari |
1230 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
//e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
1232 |
} |
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 |
1235 |
} else { |
2 |
26 Feb 07 |
jari |
//log.append("Save command cancelled by user." + newline); |
2 |
26 Feb 07 |
jari |
1237 |
} |
2 |
26 Feb 07 |
jari |
1238 |
} |
2 |
26 Feb 07 |
jari |
1239 |
}); |
2 |
26 Feb 07 |
jari |
1240 |
|
2 |
26 Feb 07 |
jari |
1241 |
loadButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
1242 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1243 |
int returnVal = fc.showOpenDialog(GroupExperimentsPanel.this); |
2 |
26 Feb 07 |
jari |
1244 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
1245 |
try { |
2 |
26 Feb 07 |
jari |
1246 |
FileReader file = new FileReader(fc.getSelectedFile()); |
2 |
26 Feb 07 |
jari |
1247 |
BufferedReader buff = new BufferedReader(file); |
2 |
26 Feb 07 |
jari |
1248 |
String line = buff.readLine(); |
2 |
26 Feb 07 |
jari |
//System.out.println(line); |
2 |
26 Feb 07 |
jari |
1250 |
StringSplitter st = new StringSplitter('\t'); |
2 |
26 Feb 07 |
jari |
1251 |
st.init(line); |
2 |
26 Feb 07 |
jari |
1252 |
Vector groupsVector = new Vector(); |
2 |
26 Feb 07 |
jari |
1253 |
while (st.hasMoreTokens()) { |
2 |
26 Feb 07 |
jari |
1254 |
String current = st.nextToken(); |
2 |
26 Feb 07 |
jari |
1255 |
groupsVector.add(new Integer(current)); |
2 |
26 Feb 07 |
jari |
//System.out.print(current); |
2 |
26 Feb 07 |
jari |
1257 |
} |
2 |
26 Feb 07 |
jari |
1258 |
buff.close(); |
2 |
26 Feb 07 |
jari |
1259 |
int[] groupAssgn = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
1260 |
if (groupsVector.size() != groupAssgn.length) { |
2 |
26 Feb 07 |
jari |
1261 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
1262 |
} else { |
2 |
26 Feb 07 |
jari |
1263 |
for (int i = 0; i < groupsVector.size(); i++) { |
2 |
26 Feb 07 |
jari |
1264 |
int currentExpt = ((Integer)groupsVector.get(i)).intValue(); |
2 |
26 Feb 07 |
jari |
1265 |
if (currentExpt == 1) { |
2 |
26 Feb 07 |
jari |
1266 |
groupARadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
1267 |
} else if (currentExpt == 2) { |
2 |
26 Feb 07 |
jari |
1268 |
groupBRadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
1269 |
} else if (currentExpt == 3) { |
2 |
26 Feb 07 |
jari |
1270 |
neitherGroupRadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
1271 |
} else { |
2 |
26 Feb 07 |
jari |
1272 |
for (int j = 0; j < finNum; j++) { |
2 |
26 Feb 07 |
jari |
1273 |
groupARadioButtons[j].setSelected(true); |
2 |
26 Feb 07 |
jari |
1274 |
} |
2 |
26 Feb 07 |
jari |
1275 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
1276 |
break; |
2 |
26 Feb 07 |
jari |
1277 |
} |
2 |
26 Feb 07 |
jari |
1278 |
} |
2 |
26 Feb 07 |
jari |
1279 |
} |
2 |
26 Feb 07 |
jari |
1280 |
|
2 |
26 Feb 07 |
jari |
1281 |
pPanel.tDistButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
1282 |
sPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
1283 |
sPanel.maxTButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
1284 |
sPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1285 |
sPanel.minPButton.setSelected(false); |
2 |
26 Feb 07 |
jari |
1286 |
sPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1287 |
pPanel.randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1288 |
pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1289 |
pPanel.timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1290 |
pPanel.numCombsLabel.setText(" "); |
2 |
26 Feb 07 |
jari |
1291 |
|
2 |
26 Feb 07 |
jari |
1292 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
1293 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
//e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
1295 |
} |
2 |
26 Feb 07 |
jari |
1296 |
|
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 |
1299 |
} else { |
2 |
26 Feb 07 |
jari |
//log.append("Save command cancelled by user." + newline); |
2 |
26 Feb 07 |
jari |
1301 |
} |
2 |
26 Feb 07 |
jari |
1302 |
} |
2 |
26 Feb 07 |
jari |
1303 |
}); |
2 |
26 Feb 07 |
jari |
1304 |
|
2 |
26 Feb 07 |
jari |
1305 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
1306 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
1307 |
constraints.insets = new Insets(0,5,0,5); |
2 |
26 Feb 07 |
jari |
1308 |
|
2 |
26 Feb 07 |
jari |
1309 |
buildConstraints(constraints, 0, 1, 1, 1, 33, 100); |
2 |
26 Feb 07 |
jari |
1310 |
gridbag3.setConstraints(saveButton, constraints); |
2 |
26 Feb 07 |
jari |
1311 |
panel2.add(saveButton); |
2 |
26 Feb 07 |
jari |
1312 |
|
2 |
26 Feb 07 |
jari |
1313 |
buildConstraints(constraints, 1, 1, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
1314 |
gridbag3.setConstraints(loadButton, constraints); |
2 |
26 Feb 07 |
jari |
1315 |
panel2.add(loadButton); |
2 |
26 Feb 07 |
jari |
1316 |
|
2 |
26 Feb 07 |
jari |
1317 |
buildConstraints(constraints, 2, 1, 1, 1, 34, 0); |
2 |
26 Feb 07 |
jari |
1318 |
gridbag3.setConstraints(resetButton, constraints); |
2 |
26 Feb 07 |
jari |
1319 |
panel2.add(resetButton); |
2 |
26 Feb 07 |
jari |
1320 |
|
2 |
26 Feb 07 |
jari |
1321 |
buildConstraints(constraints, 0, 3, 1, 1, 0, 5); |
2 |
26 Feb 07 |
jari |
1322 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
1323 |
gridbag2.setConstraints(panel2, constraints); |
2 |
26 Feb 07 |
jari |
1324 |
this.add(panel2); |
2 |
26 Feb 07 |
jari |
1325 |
|
2 |
26 Feb 07 |
jari |
1326 |
} |
2 |
26 Feb 07 |
jari |
1327 |
public void reset(){ |
2 |
26 Feb 07 |
jari |
1328 |
final int finNum = exptNames.size(); |
2 |
26 Feb 07 |
jari |
1329 |
for (int i = 0; i < finNum; i++) { |
2 |
26 Feb 07 |
jari |
1330 |
groupARadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
1331 |
} |
2 |
26 Feb 07 |
jari |
1332 |
} |
2 |
26 Feb 07 |
jari |
1333 |
} |
2 |
26 Feb 07 |
jari |
1334 |
|
2 |
26 Feb 07 |
jari |
1335 |
class PValuePanel extends JPanel { |
2 |
26 Feb 07 |
jari |
1336 |
JRadioButton tDistButton, permutButton, randomGroupsButton, allCombsButton; |
2 |
26 Feb 07 |
jari |
1337 |
JLabel numCombsLabel; |
2 |
26 Feb 07 |
jari |
1338 |
JTextField timesField, alphaInputField; |
2 |
26 Feb 07 |
jari |
//JButton permParamButton; |
2 |
26 Feb 07 |
jari |
1340 |
|
2 |
26 Feb 07 |
jari |
1341 |
PValuePanel() { |
2 |
26 Feb 07 |
jari |
// this.setBorder(new TitledBorder(new EtchedBorder(), "P-Value parameters")); |
2 |
26 Feb 07 |
jari |
1343 |
this.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "P-Value Parameters", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
1344 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1345 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1346 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
1347 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1349 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
1350 |
|
2 |
26 Feb 07 |
jari |
//permParamButton = new JButton("Permutation parameters"); |
2 |
26 Feb 07 |
jari |
//permParamButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1353 |
|
2 |
26 Feb 07 |
jari |
1354 |
ButtonGroup chooseP = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
1355 |
|
2 |
26 Feb 07 |
jari |
1356 |
tDistButton = new JRadioButton("p-values based on t-distribution", true); |
2 |
26 Feb 07 |
jari |
1357 |
tDistButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1358 |
tDistButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
1359 |
tDistButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1360 |
/* |
2 |
26 Feb 07 |
jari |
tDistButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
public void actionPerformed (ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
if (evt.getSource() == tDistButton) { |
2 |
26 Feb 07 |
jari |
permParamButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1365 |
} |
2 |
26 Feb 07 |
jari |
1366 |
} |
2 |
26 Feb 07 |
jari |
1367 |
}); |
2 |
26 Feb 07 |
jari |
1368 |
*/ |
2 |
26 Feb 07 |
jari |
1369 |
chooseP.add(tDistButton); |
2 |
26 Feb 07 |
jari |
1370 |
|
2 |
26 Feb 07 |
jari |
1371 |
permutButton = new JRadioButton("p-values based on permutation: ", false); |
2 |
26 Feb 07 |
jari |
1372 |
permutButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1373 |
permutButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
1374 |
permutButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1375 |
/* |
2 |
26 Feb 07 |
jari |
permutButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
public void actionPerformed (ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
if (evt.getSource() == permutButton) { |
2 |
26 Feb 07 |
jari |
int[] grpAssignments = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
int grpACounter = 0; |
2 |
26 Feb 07 |
jari |
int grpBCounter = 0; |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < grpAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
if (grpAssignments[i] == GROUP_A) { |
2 |
26 Feb 07 |
jari |
grpACounter++; |
2 |
26 Feb 07 |
jari |
} else if (grpAssignments[i] == GROUP_B) { |
2 |
26 Feb 07 |
jari |
grpBCounter++; |
2 |
26 Feb 07 |
jari |
1387 |
} |
2 |
26 Feb 07 |
jari |
1388 |
} |
2 |
26 Feb 07 |
jari |
if ((grpACounter < 2) || (grpBCounter < 2)) { |
2 |
26 Feb 07 |
jari |
JOptionPane.showMessageDialog(gPanel, "Group A and Group B must each contain more than one experiment", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
} else { |
2 |
26 Feb 07 |
jari |
1392 |
|
2 |
26 Feb 07 |
jari |
//if (pPanel.permutButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
//System.out.println("grpACounter = " + grpACounter + ", grpBCounter = " + grpBCounter); |
2 |
26 Feb 07 |
jari |
int numCombs = 0; |
2 |
26 Feb 07 |
jari |
tooMany = true; |
2 |
26 Feb 07 |
jari |
if ((grpACounter + grpBCounter) <= 20) { |
2 |
26 Feb 07 |
jari |
numCombs = getNumCombs((grpACounter + grpBCounter), grpACounter); |
2 |
26 Feb 07 |
jari |
tooMany = false; |
2 |
26 Feb 07 |
jari |
1400 |
} |
2 |
26 Feb 07 |
jari |
1401 |
} |
2 |
26 Feb 07 |
jari |
1402 |
} |
2 |
26 Feb 07 |
jari |
1403 |
}); |
2 |
26 Feb 07 |
jari |
1404 |
*/ |
2 |
26 Feb 07 |
jari |
1405 |
|
2 |
26 Feb 07 |
jari |
//permutButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1407 |
chooseP.add(permutButton); |
2 |
26 Feb 07 |
jari |
1408 |
/* |
2 |
26 Feb 07 |
jari |
buildConstraints(constraints, 0, 0, 1, 1, 0, 20); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
gridbag.setConstraints(tDistButton, constraints); |
2 |
26 Feb 07 |
jari |
this.add(tDistButton); |
2 |
26 Feb 07 |
jari |
1413 |
*/ |
2 |
26 Feb 07 |
jari |
1414 |
|
2 |
26 Feb 07 |
jari |
1415 |
/* |
2 |
26 Feb 07 |
jari |
JLabel line1 = new JLabel("___________________________________________________________________________________________________"); |
2 |
26 Feb 07 |
jari |
buildConstraints(constraints, 0, 1, 4, 1, 100, 5); |
2 |
26 Feb 07 |
jari |
gridbag.setConstraints(line1, constraints); |
2 |
26 Feb 07 |
jari |
this.add(line1); |
2 |
26 Feb 07 |
jari |
1420 |
*/ |
2 |
26 Feb 07 |
jari |
1421 |
|
2 |
26 Feb 07 |
jari |
1422 |
|
2 |
26 Feb 07 |
jari |
1423 |
/* |
2 |
26 Feb 07 |
jari |
buildConstraints(constraints, 0, 2, 1, 1, 0, 15); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
//constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
gridbag.setConstraints(permutButton, constraints); |
2 |
26 Feb 07 |
jari |
this.add(permutButton); |
2 |
26 Feb 07 |
jari |
1429 |
*/ |
2 |
26 Feb 07 |
jari |
1430 |
|
2 |
26 Feb 07 |
jari |
1431 |
/* |
2 |
26 Feb 07 |
jari |
buildConstraints(constraints, 1, 1, 1, 1, 0, 0); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
gridbag.setConstraints(permParamButton, constraints); |
2 |
26 Feb 07 |
jari |
this.add(permParamButton); |
2 |
26 Feb 07 |
jari |
1437 |
*/ |
2 |
26 Feb 07 |
jari |
1438 |
|
2 |
26 Feb 07 |
jari |
//constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
1440 |
|
2 |
26 Feb 07 |
jari |
1441 |
numCombsLabel = new JLabel(" "); |
2 |
26 Feb 07 |
jari |
1442 |
numCombsLabel.setOpaque(false); |
2 |
26 Feb 07 |
jari |
1443 |
/* |
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 |
1448 |
*/ |
2 |
26 Feb 07 |
jari |
1449 |
|
2 |
26 Feb 07 |
jari |
1450 |
JPanel panel1 = new JPanel(); |
2 |
26 Feb 07 |
jari |
1451 |
panel1.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1452 |
GridBagLayout grid1 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1453 |
panel1.setLayout(grid1); |
2 |
26 Feb 07 |
jari |
1454 |
|
2 |
26 Feb 07 |
jari |
1455 |
buildConstraints(constraints, 0, 0, 1, 1, 30, 50); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1457 |
grid1.setConstraints(tDistButton, constraints); |
2 |
26 Feb 07 |
jari |
1458 |
panel1.add(tDistButton); |
2 |
26 Feb 07 |
jari |
1459 |
|
2 |
26 Feb 07 |
jari |
1460 |
buildConstraints(constraints, 0, 1, 1, 1, 30, 50); |
2 |
26 Feb 07 |
jari |
1461 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
1462 |
grid1.setConstraints(permutButton, constraints); |
2 |
26 Feb 07 |
jari |
1463 |
panel1.add(permutButton); |
2 |
26 Feb 07 |
jari |
1464 |
|
2 |
26 Feb 07 |
jari |
1465 |
buildConstraints(constraints, 1, 1, 1, 1, 70, 0); |
2 |
26 Feb 07 |
jari |
1466 |
constraints.ipadx = 50; |
2 |
26 Feb 07 |
jari |
1467 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
1468 |
grid1.setConstraints(numCombsLabel, constraints); |
2 |
26 Feb 07 |
jari |
1469 |
panel1.add(numCombsLabel); |
2 |
26 Feb 07 |
jari |
1470 |
|
2 |
26 Feb 07 |
jari |
1471 |
constraints.ipadx = 100; |
2 |
26 Feb 07 |
jari |
//constraints.ipady = 100; |
2 |
26 Feb 07 |
jari |
1473 |
|
2 |
26 Feb 07 |
jari |
1474 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 20); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1476 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
1477 |
gridbag.setConstraints(panel1, constraints); |
2 |
26 Feb 07 |
jari |
1478 |
this.add(panel1); |
2 |
26 Feb 07 |
jari |
1479 |
|
2 |
26 Feb 07 |
jari |
//DONE UPTO HERE -- 9/18/02 |
2 |
26 Feb 07 |
jari |
1481 |
|
2 |
26 Feb 07 |
jari |
1482 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
1483 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
1484 |
constraints.ipadx = 0; |
2 |
26 Feb 07 |
jari |
1485 |
constraints.ipady = 0; |
2 |
26 Feb 07 |
jari |
1486 |
|
2 |
26 Feb 07 |
jari |
1487 |
JPanel panel2 = new JPanel(); |
2 |
26 Feb 07 |
jari |
1488 |
panel2.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1489 |
GridBagLayout grid2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1490 |
panel2.setLayout(grid2); |
2 |
26 Feb 07 |
jari |
1491 |
panel2.setBorder(new EtchedBorder()); |
2 |
26 Feb 07 |
jari |
1492 |
|
2 |
26 Feb 07 |
jari |
1493 |
|
2 |
26 Feb 07 |
jari |
1494 |
randomGroupsButton = new JRadioButton("Randomly group samples ", true); |
2 |
26 Feb 07 |
jari |
1495 |
randomGroupsButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1496 |
randomGroupsButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
1497 |
randomGroupsButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1498 |
randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1499 |
|
2 |
26 Feb 07 |
jari |
1500 |
allCombsButton = new JRadioButton("Use all permutations ", false); |
2 |
26 Feb 07 |
jari |
1501 |
allCombsButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1502 |
allCombsButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
1503 |
allCombsButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1504 |
allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1505 |
|
2 |
26 Feb 07 |
jari |
1506 |
|
2 |
26 Feb 07 |
jari |
1507 |
ButtonGroup chooseAllOrRandom = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
1508 |
|
2 |
26 Feb 07 |
jari |
1509 |
buildConstraints(constraints, 0, 0, 1, 1, 60, 50); |
2 |
26 Feb 07 |
jari |
1510 |
grid2.setConstraints(randomGroupsButton, constraints); |
2 |
26 Feb 07 |
jari |
1511 |
panel2.add(randomGroupsButton); |
2 |
26 Feb 07 |
jari |
1512 |
|
2 |
26 Feb 07 |
jari |
1513 |
timesField = new JTextField("100", 7); |
2 |
26 Feb 07 |
jari |
1514 |
timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1515 |
buildConstraints(constraints, 1, 0, 1, 1, 20, 0); |
2 |
26 Feb 07 |
jari |
1516 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
1517 |
grid2.setConstraints(timesField, constraints); |
2 |
26 Feb 07 |
jari |
1518 |
panel2.add(timesField); |
2 |
26 Feb 07 |
jari |
1519 |
|
2 |
26 Feb 07 |
jari |
1520 |
JLabel timesLabel = new JLabel("times"); |
2 |
26 Feb 07 |
jari |
1521 |
timesLabel.setOpaque(false); |
2 |
26 Feb 07 |
jari |
1522 |
buildConstraints(constraints, 2, 0, 1, 1, 20, 0); |
2 |
26 Feb 07 |
jari |
1523 |
grid2.setConstraints(timesLabel, constraints); |
2 |
26 Feb 07 |
jari |
1524 |
panel2.add(timesLabel); |
2 |
26 Feb 07 |
jari |
1525 |
|
2 |
26 Feb 07 |
jari |
1526 |
buildConstraints(constraints, 0, 1, 1, 1, 60, 0); |
2 |
26 Feb 07 |
jari |
1527 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
1528 |
grid2.setConstraints(allCombsButton, constraints); |
2 |
26 Feb 07 |
jari |
1529 |
panel2.add(allCombsButton); |
2 |
26 Feb 07 |
jari |
1530 |
|
2 |
26 Feb 07 |
jari |
1531 |
chooseAllOrRandom.add(randomGroupsButton); |
2 |
26 Feb 07 |
jari |
1532 |
chooseAllOrRandom.add(allCombsButton); |
2 |
26 Feb 07 |
jari |
1533 |
|
2 |
26 Feb 07 |
jari |
1534 |
allCombsButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
1535 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1536 |
if (evt.getSource() == allCombsButton) { |
2 |
26 Feb 07 |
jari |
1537 |
timesField.setText(""); |
2 |
26 Feb 07 |
jari |
1538 |
timesField.setBackground(Color.gray); |
2 |
26 Feb 07 |
jari |
1539 |
timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1540 |
} |
2 |
26 Feb 07 |
jari |
1541 |
} |
2 |
26 Feb 07 |
jari |
1542 |
}); |
2 |
26 Feb 07 |
jari |
1543 |
|
2 |
26 Feb 07 |
jari |
1544 |
randomGroupsButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
1545 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1546 |
if (evt.getSource() == randomGroupsButton) { |
2 |
26 Feb 07 |
jari |
1547 |
timesField.setText("100"); |
2 |
26 Feb 07 |
jari |
1548 |
timesField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1549 |
timesField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
1550 |
} |
2 |
26 Feb 07 |
jari |
1551 |
} |
2 |
26 Feb 07 |
jari |
1552 |
}); |
2 |
26 Feb 07 |
jari |
1553 |
|
2 |
26 Feb 07 |
jari |
1554 |
tDistButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
1555 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
1556 |
if (evt.getSource() ==tDistButton) { |
2 |
26 Feb 07 |
jari |
1557 |
randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1558 |
allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1559 |
timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1560 |
numCombsLabel.setText(" "); |
2 |
26 Feb 07 |
jari |
1561 |
} |
2 |
26 Feb 07 |
jari |
1562 |
} |
2 |
26 Feb 07 |
jari |
1563 |
}); |
2 |
26 Feb 07 |
jari |
1564 |
|
2 |
26 Feb 07 |
jari |
1565 |
buildConstraints(constraints, 0, 1, 1, 1, 100, 60); |
2 |
26 Feb 07 |
jari |
1566 |
constraints.anchor = GridBagConstraints.NORTH; |
2 |
26 Feb 07 |
jari |
1567 |
constraints.fill = GridBagConstraints.VERTICAL; |
2 |
26 Feb 07 |
jari |
1568 |
gridbag.setConstraints(panel2, constraints); |
2 |
26 Feb 07 |
jari |
1569 |
this.add(panel2); |
2 |
26 Feb 07 |
jari |
1570 |
/* |
2 |
26 Feb 07 |
jari |
JLabel line2 = new JLabel("___________________________________________________________________________________________________"); |
2 |
26 Feb 07 |
jari |
buildConstraints(constraints, 0, 5, 4, 1, 100, 5); |
2 |
26 Feb 07 |
jari |
gridbag.setConstraints(line2, constraints); |
2 |
26 Feb 07 |
jari |
this.add(line2); |
2 |
26 Feb 07 |
jari |
1575 |
*/ |
2 |
26 Feb 07 |
jari |
1576 |
|
2 |
26 Feb 07 |
jari |
1577 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
1578 |
|
2 |
26 Feb 07 |
jari |
1579 |
JPanel panel3 = new JPanel(); |
2 |
26 Feb 07 |
jari |
1580 |
panel3.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1581 |
GridBagLayout grid3 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1582 |
panel3.setLayout(grid3); |
2 |
26 Feb 07 |
jari |
1583 |
|
2 |
26 Feb 07 |
jari |
1584 |
JLabel alphaLabel = new JLabel("Overall alpha (critical p-value): "); |
2 |
26 Feb 07 |
jari |
1585 |
alphaLabel.setOpaque(false); |
2 |
26 Feb 07 |
jari |
1586 |
buildConstraints(constraints, 0, 0, 1, 1, 75, 100); |
2 |
26 Feb 07 |
jari |
1587 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1589 |
grid3.setConstraints(alphaLabel, constraints); |
2 |
26 Feb 07 |
jari |
1590 |
panel3.add(alphaLabel); |
2 |
26 Feb 07 |
jari |
1591 |
|
2 |
26 Feb 07 |
jari |
1592 |
alphaInputField = new JTextField("0.01", 7); |
2 |
26 Feb 07 |
jari |
1593 |
buildConstraints(constraints, 1, 0, 1, 1, 25, 0); |
2 |
26 Feb 07 |
jari |
1594 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
1595 |
grid3.setConstraints(alphaInputField, constraints); |
2 |
26 Feb 07 |
jari |
1596 |
panel3.add(alphaInputField); |
2 |
26 Feb 07 |
jari |
1597 |
|
2 |
26 Feb 07 |
jari |
1598 |
buildConstraints(constraints, 0, 2, 1, 1, 0, 20); |
2 |
26 Feb 07 |
jari |
1599 |
gridbag.setConstraints(panel3, constraints); |
2 |
26 Feb 07 |
jari |
1600 |
this.add(panel3); |
2 |
26 Feb 07 |
jari |
1601 |
|
2 |
26 Feb 07 |
jari |
1602 |
/* |
2 |
26 Feb 07 |
jari |
JButton pButton = new JButton("pValuePanel"); |
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(pButton, constraints); |
2 |
26 Feb 07 |
jari |
this.add(pButton); |
2 |
26 Feb 07 |
jari |
1608 |
*/ |
2 |
26 Feb 07 |
jari |
1609 |
} |
2 |
26 Feb 07 |
jari |
1610 |
} |
2 |
26 Feb 07 |
jari |
1611 |
|
2 |
26 Feb 07 |
jari |
1612 |
class SignificancePanel extends JPanel { |
2 |
26 Feb 07 |
jari |
1613 |
JRadioButton minPButton, maxTButton, justAlphaButton, stdBonfButton, adjBonfButton, falseNumButton, falsePropButton, fastFDRButton, slowFDRButton; |
2 |
26 Feb 07 |
jari |
1614 |
JTextField falseNumField, falsePropField; |
2 |
26 Feb 07 |
jari |
1615 |
JCheckBox calcFDRPVals; |
2 |
26 Feb 07 |
jari |
1616 |
SignificancePanel() { |
2 |
26 Feb 07 |
jari |
// this.setBorder(new TitledBorder(new EtchedBorder(), "Significance based on: ")); |
2 |
26 Feb 07 |
jari |
1618 |
this.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "p-value / false discovery corrections", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
1619 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1620 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1621 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
1622 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
1623 |
|
2 |
26 Feb 07 |
jari |
1624 |
/* |
2 |
26 Feb 07 |
jari |
JLabel sigLabel = new JLabel("Significance based on: "); |
2 |
26 Feb 07 |
jari |
buildConstraints(constraints, 0, 0, 3, 1, 0, 50); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
gridbag.setConstraints(sigLabel, constraints); |
2 |
26 Feb 07 |
jari |
this.add(sigLabel); |
2 |
26 Feb 07 |
jari |
1630 |
*/ |
2 |
26 Feb 07 |
jari |
1631 |
|
2 |
26 Feb 07 |
jari |
1632 |
ButtonGroup sigGroup = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
1633 |
|
2 |
26 Feb 07 |
jari |
1634 |
justAlphaButton = new JRadioButton("just alpha (no correction)", true); |
2 |
26 Feb 07 |
jari |
1635 |
justAlphaButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1636 |
justAlphaButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
1637 |
justAlphaButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1638 |
sigGroup.add(justAlphaButton); |
2 |
26 Feb 07 |
jari |
1639 |
|
2 |
26 Feb 07 |
jari |
1640 |
stdBonfButton = new JRadioButton("standard Bonferroni correction", false); |
2 |
26 Feb 07 |
jari |
1641 |
stdBonfButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1642 |
stdBonfButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
1643 |
stdBonfButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1644 |
sigGroup.add(stdBonfButton); |
2 |
26 Feb 07 |
jari |
1645 |
|
2 |
26 Feb 07 |
jari |
1646 |
adjBonfButton = new JRadioButton("adjusted Bonferroni correction", false); |
2 |
26 Feb 07 |
jari |
1647 |
adjBonfButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1648 |
adjBonfButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
1649 |
adjBonfButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1650 |
sigGroup.add(adjBonfButton); |
2 |
26 Feb 07 |
jari |
1651 |
|
2 |
26 Feb 07 |
jari |
1652 |
minPButton = new JRadioButton("minP", false); |
2 |
26 Feb 07 |
jari |
1653 |
minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1654 |
minPButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1655 |
minPButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
1656 |
minPButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1657 |
sigGroup.add(minPButton); |
2 |
26 Feb 07 |
jari |
1658 |
|
2 |
26 Feb 07 |
jari |
1659 |
maxTButton = new JRadioButton("maxT", false); |
2 |
26 Feb 07 |
jari |
1660 |
maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1661 |
maxTButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1662 |
maxTButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
1663 |
maxTButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1664 |
sigGroup.add(maxTButton); |
2 |
26 Feb 07 |
jari |
1665 |
|
2 |
26 Feb 07 |
jari |
1666 |
falseNumButton = new JRadioButton("EITHER, The number of false significant genes should not exceed", false); |
2 |
26 Feb 07 |
jari |
1667 |
falseNumButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
//falseNumButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1669 |
falseNumButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1670 |
falseNumButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
1671 |
falseNumButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1672 |
sigGroup.add(falseNumButton); |
2 |
26 Feb 07 |
jari |
1673 |
|
2 |
26 Feb 07 |
jari |
1674 |
falsePropButton = new JRadioButton("OR, The proportion of false significant genes should not exceed", false); |
2 |
26 Feb 07 |
jari |
1675 |
falsePropButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
//falsePropButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1677 |
falsePropButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
1678 |
falsePropButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
1679 |
falsePropButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1680 |
sigGroup.add(falsePropButton); |
2 |
26 Feb 07 |
jari |
1681 |
|
2 |
26 Feb 07 |
jari |
1682 |
falseNumField = new JTextField(10); |
2 |
26 Feb 07 |
jari |
1683 |
falseNumField.setText("10"); |
2 |
26 Feb 07 |
jari |
1684 |
falseNumField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1685 |
falsePropField = new JTextField(10); |
2 |
26 Feb 07 |
jari |
1686 |
falsePropField.setText("0.05"); |
2 |
26 Feb 07 |
jari |
1687 |
falsePropField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1688 |
calcFDRPVals = new JCheckBox("Calculate adjusted p values for false discovery control", false); |
2 |
26 Feb 07 |
jari |
1689 |
calcFDRPVals.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1690 |
calcFDRPVals.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1691 |
|
2 |
26 Feb 07 |
jari |
1692 |
buildConstraints(constraints, 0, 0, 1, 1, 33, 33); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1694 |
gridbag.setConstraints(justAlphaButton, constraints); |
2 |
26 Feb 07 |
jari |
1695 |
this.add(justAlphaButton); |
2 |
26 Feb 07 |
jari |
1696 |
|
2 |
26 Feb 07 |
jari |
1697 |
buildConstraints(constraints, 1, 0, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1699 |
gridbag.setConstraints(stdBonfButton, constraints); |
2 |
26 Feb 07 |
jari |
1700 |
this.add(stdBonfButton); |
2 |
26 Feb 07 |
jari |
1701 |
|
2 |
26 Feb 07 |
jari |
1702 |
buildConstraints(constraints, 2, 0, 1, 1, 34, 0); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1704 |
gridbag.setConstraints(adjBonfButton, constraints); |
2 |
26 Feb 07 |
jari |
1705 |
this.add(adjBonfButton); |
2 |
26 Feb 07 |
jari |
1706 |
|
2 |
26 Feb 07 |
jari |
1707 |
JPanel westfallYoungPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
1708 |
westfallYoungPanel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1709 |
westfallYoungPanel.setBorder(new EtchedBorder()); |
2 |
26 Feb 07 |
jari |
1710 |
GridBagLayout grid2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1711 |
westfallYoungPanel.setLayout(grid2); |
2 |
26 Feb 07 |
jari |
1712 |
|
2 |
26 Feb 07 |
jari |
1713 |
JLabel stepDownLabel = new JLabel("Step-down Westfall and Young methods (for permutations only): "); |
2 |
26 Feb 07 |
jari |
1714 |
buildConstraints(constraints, 0, 0, 1, 1, 34, 100); |
2 |
26 Feb 07 |
jari |
//buildConstraints(constraints, 0, 1, 1, 1, 34, 50); |
2 |
26 Feb 07 |
jari |
////constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
//constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
//gridbag.setConstraints(stepDownLabel, constraints); |
2 |
26 Feb 07 |
jari |
1719 |
grid2.setConstraints(stepDownLabel, constraints); |
2 |
26 Feb 07 |
jari |
//this.add(stepDownLabel); |
2 |
26 Feb 07 |
jari |
1721 |
westfallYoungPanel.add(stepDownLabel); |
2 |
26 Feb 07 |
jari |
1722 |
|
2 |
26 Feb 07 |
jari |
//buildConstraints(constraints, 1, 1, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
1724 |
buildConstraints(constraints, 1, 0, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
//constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
//gridbag.setConstraints(minPButton, constraints); |
2 |
26 Feb 07 |
jari |
1728 |
grid2.setConstraints(minPButton, constraints); |
2 |
26 Feb 07 |
jari |
//this.add(minPButton); |
2 |
26 Feb 07 |
jari |
1730 |
westfallYoungPanel.add(minPButton); |
2 |
26 Feb 07 |
jari |
1731 |
|
2 |
26 Feb 07 |
jari |
1732 |
|
2 |
26 Feb 07 |
jari |
//buildConstraints(constraints, 2, 1, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
1734 |
buildConstraints(constraints, 2, 0, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
////constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
//constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
//gridbag.setConstraints(maxTButton, constraints); |
2 |
26 Feb 07 |
jari |
1738 |
grid2.setConstraints(maxTButton, constraints); |
2 |
26 Feb 07 |
jari |
//this.add(maxTButton); |
2 |
26 Feb 07 |
jari |
1740 |
westfallYoungPanel.add(maxTButton); |
2 |
26 Feb 07 |
jari |
1741 |
|
2 |
26 Feb 07 |
jari |
1742 |
buildConstraints(constraints, 0, 1, 3, 1, 100, 33); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1744 |
gridbag.setConstraints(westfallYoungPanel, constraints); |
2 |
26 Feb 07 |
jari |
1745 |
this.add(westfallYoungPanel); |
2 |
26 Feb 07 |
jari |
1746 |
|
2 |
26 Feb 07 |
jari |
1747 |
ButtonGroup fastOrSlow = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
1748 |
fastFDRButton = new JRadioButton("Fast approximation (but possibly conservative)", true); |
2 |
26 Feb 07 |
jari |
1749 |
fastFDRButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
1750 |
fastFDRButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1751 |
fastFDRButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1752 |
fastOrSlow.add(fastFDRButton); |
2 |
26 Feb 07 |
jari |
1753 |
slowFDRButton = new JRadioButton("Complete computation (possibly slow)"); |
2 |
26 Feb 07 |
jari |
1754 |
slowFDRButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
1755 |
slowFDRButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1756 |
fastOrSlow.add(slowFDRButton); |
2 |
26 Feb 07 |
jari |
1757 |
|
2 |
26 Feb 07 |
jari |
1758 |
JPanel FDRPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
1759 |
FDRPanel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1760 |
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 |
1761 |
GridBagLayout grid3 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1762 |
FDRPanel.setLayout(grid3); |
2 |
26 Feb 07 |
jari |
1763 |
|
2 |
26 Feb 07 |
jari |
1764 |
JLabel FDRLabel = new JLabel("With confidence of [1 - alpha] : "); |
2 |
26 Feb 07 |
jari |
1765 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
1766 |
buildConstraints(constraints, 0, 0, 2, 1, 100, 20); |
2 |
26 Feb 07 |
jari |
1767 |
grid3.setConstraints(FDRLabel, constraints); |
2 |
26 Feb 07 |
jari |
1768 |
FDRPanel.add(FDRLabel); |
2 |
26 Feb 07 |
jari |
1769 |
|
2 |
26 Feb 07 |
jari |
1770 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
1771 |
|
2 |
26 Feb 07 |
jari |
1772 |
buildConstraints(constraints, 0, 1, 1, 1, 50, 20); |
2 |
26 Feb 07 |
jari |
1773 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
1774 |
grid3.setConstraints(falseNumButton, constraints); |
2 |
26 Feb 07 |
jari |
1775 |
FDRPanel.add(falseNumButton); |
2 |
26 Feb 07 |
jari |
1776 |
|
2 |
26 Feb 07 |
jari |
1777 |
buildConstraints(constraints, 1, 1, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
1778 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
1779 |
grid3.setConstraints(falseNumField, constraints); |
2 |
26 Feb 07 |
jari |
1780 |
FDRPanel.add(falseNumField); |
2 |
26 Feb 07 |
jari |
1781 |
|
2 |
26 Feb 07 |
jari |
1782 |
buildConstraints(constraints, 0, 2, 1, 1, 50, 20); |
2 |
26 Feb 07 |
jari |
1783 |
constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
1784 |
grid3.setConstraints(falsePropButton, constraints); |
2 |
26 Feb 07 |
jari |
1785 |
FDRPanel.add(falsePropButton); |
2 |
26 Feb 07 |
jari |
1786 |
|
2 |
26 Feb 07 |
jari |
1787 |
buildConstraints(constraints, 1, 2, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
1788 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
1789 |
grid3.setConstraints(falsePropField, constraints); |
2 |
26 Feb 07 |
jari |
1790 |
FDRPanel.add(falsePropField); |
2 |
26 Feb 07 |
jari |
1791 |
|
2 |
26 Feb 07 |
jari |
1792 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
1793 |
|
2 |
26 Feb 07 |
jari |
1794 |
buildConstraints(constraints, 0, 3, 1, 1, 50, 20); |
2 |
26 Feb 07 |
jari |
1795 |
grid3.setConstraints(fastFDRButton, constraints); |
2 |
26 Feb 07 |
jari |
1796 |
FDRPanel.add(fastFDRButton); |
2 |
26 Feb 07 |
jari |
1797 |
|
2 |
26 Feb 07 |
jari |
1798 |
buildConstraints(constraints, 1, 3, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
1799 |
grid3.setConstraints(slowFDRButton, constraints); |
2 |
26 Feb 07 |
jari |
1800 |
FDRPanel.add(slowFDRButton); |
2 |
26 Feb 07 |
jari |
1801 |
|
2 |
26 Feb 07 |
jari |
1802 |
buildConstraints(constraints, 0, 4, 2, 1, 100, 20); |
2 |
26 Feb 07 |
jari |
1803 |
grid3.setConstraints(calcFDRPVals, constraints); |
2 |
26 Feb 07 |
jari |
1804 |
FDRPanel.add(calcFDRPVals); |
2 |
26 Feb 07 |
jari |
1805 |
|
2 |
26 Feb 07 |
jari |
1806 |
buildConstraints(constraints, 0, 2, 3, 1, 100, 34); |
2 |
26 Feb 07 |
jari |
1807 |
constraints.fill = GridBagConstraints.HORIZONTAL; |
2 |
26 Feb 07 |
jari |
1808 |
gridbag.setConstraints(FDRPanel, constraints); |
2 |
26 Feb 07 |
jari |
1809 |
this.add(FDRPanel); |
2 |
26 Feb 07 |
jari |
1810 |
|
2 |
26 Feb 07 |
jari |
1811 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
1812 |
/* |
2 |
26 Feb 07 |
jari |
JButton sButton = new JButton("significancePanel"); |
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(sButton, constraints); |
2 |
26 Feb 07 |
jari |
this.add(sButton); |
2 |
26 Feb 07 |
jari |
1818 |
*/ |
2 |
26 Feb 07 |
jari |
1819 |
|
2 |
26 Feb 07 |
jari |
1820 |
} |
2 |
26 Feb 07 |
jari |
1821 |
} |
2 |
26 Feb 07 |
jari |
1822 |
|
2 |
26 Feb 07 |
jari |
1823 |
class OkCancelPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
1824 |
JButton okButton, cancelButton; |
2 |
26 Feb 07 |
jari |
1825 |
JCheckBox drawTreesBox; |
2 |
26 Feb 07 |
jari |
1826 |
OkCancelPanel() { |
2 |
26 Feb 07 |
jari |
1827 |
this.setBorder(new TitledBorder(new EtchedBorder(), "General")); |
2 |
26 Feb 07 |
jari |
1828 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1829 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
1830 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
1831 |
|
2 |
26 Feb 07 |
jari |
1832 |
drawTreesBox = new JCheckBox("Draw hierarchical trees", false); |
2 |
26 Feb 07 |
jari |
1833 |
buildConstraints(constraints, 0, 0, 2, 1, 100, 50); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1835 |
gridbag.setConstraints(drawTreesBox, constraints); |
2 |
26 Feb 07 |
jari |
1836 |
this.add(drawTreesBox); |
2 |
26 Feb 07 |
jari |
1837 |
|
2 |
26 Feb 07 |
jari |
1838 |
okButton = new JButton("OK"); |
2 |
26 Feb 07 |
jari |
1839 |
buildConstraints(constraints, 0, 1, 1, 1, 50, 50); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1841 |
gridbag.setConstraints(okButton, constraints); |
2 |
26 Feb 07 |
jari |
1842 |
this.add(okButton); |
2 |
26 Feb 07 |
jari |
1843 |
|
2 |
26 Feb 07 |
jari |
1844 |
cancelButton = new JButton("Cancel"); |
2 |
26 Feb 07 |
jari |
1845 |
buildConstraints(constraints, 1, 1, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1847 |
gridbag.setConstraints(cancelButton, constraints); |
2 |
26 Feb 07 |
jari |
1848 |
this.add(cancelButton); |
2 |
26 Feb 07 |
jari |
1849 |
|
2 |
26 Feb 07 |
jari |
1850 |
/* |
2 |
26 Feb 07 |
jari |
JButton oButton = new JButton("OkCancelPanel"); |
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(oButton, constraints); |
2 |
26 Feb 07 |
jari |
this.add(oButton); |
2 |
26 Feb 07 |
jari |
1856 |
*/ |
2 |
26 Feb 07 |
jari |
1857 |
} |
2 |
26 Feb 07 |
jari |
1858 |
} |
2 |
26 Feb 07 |
jari |
1859 |
|
2 |
26 Feb 07 |
jari |
1860 |
class DfCalcPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
1861 |
JRadioButton welchButton, eqVarButton; |
2 |
26 Feb 07 |
jari |
1862 |
DfCalcPanel() { |
2 |
26 Feb 07 |
jari |
1863 |
this.setBorder(new TitledBorder(new EtchedBorder(), "Variance assumption (for between subjects t-test only)")); |
2 |
26 Feb 07 |
jari |
1864 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1865 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
1866 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
1867 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
1868 |
|
2 |
26 Feb 07 |
jari |
1869 |
welchButton = new JRadioButton("Welch approximation (unequal group variances)", true); |
2 |
26 Feb 07 |
jari |
1870 |
welchButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1871 |
eqVarButton = new JRadioButton("Assume equal group variances", false); |
2 |
26 Feb 07 |
jari |
1872 |
eqVarButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
1873 |
|
2 |
26 Feb 07 |
jari |
1874 |
ButtonGroup group = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
1875 |
group.add(welchButton); |
2 |
26 Feb 07 |
jari |
1876 |
group.add(eqVarButton); |
2 |
26 Feb 07 |
jari |
1877 |
|
2 |
26 Feb 07 |
jari |
1878 |
buildConstraints(constraints, 0, 0, 1, 1, 50, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1880 |
gridbag.setConstraints(welchButton, constraints); |
2 |
26 Feb 07 |
jari |
1881 |
this.add(welchButton); |
2 |
26 Feb 07 |
jari |
1882 |
|
2 |
26 Feb 07 |
jari |
1883 |
buildConstraints(constraints, 1, 0, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
1885 |
gridbag.setConstraints(eqVarButton, constraints); |
2 |
26 Feb 07 |
jari |
1886 |
this.add(eqVarButton); |
2 |
26 Feb 07 |
jari |
1887 |
} |
2 |
26 Feb 07 |
jari |
1888 |
|
2 |
26 Feb 07 |
jari |
1889 |
public void reset() { |
2 |
26 Feb 07 |
jari |
1890 |
welchButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
1891 |
} |
2 |
26 Feb 07 |
jari |
1892 |
} |
2 |
26 Feb 07 |
jari |
1893 |
|
2 |
26 Feb 07 |
jari |
1894 |
private long factorial(int n) { |
2 |
26 Feb 07 |
jari |
1895 |
if ((n==1) || (n == 0)) { |
2 |
26 Feb 07 |
jari |
1896 |
return 1; |
2 |
26 Feb 07 |
jari |
1897 |
} |
2 |
26 Feb 07 |
jari |
1898 |
else { |
2 |
26 Feb 07 |
jari |
1899 |
return factorial(n-1) * n; |
2 |
26 Feb 07 |
jari |
1900 |
} |
2 |
26 Feb 07 |
jari |
1901 |
} |
2 |
26 Feb 07 |
jari |
1902 |
|
2 |
26 Feb 07 |
jari |
1903 |
private int getNumCombs(int n, int k) { // nCk |
2 |
26 Feb 07 |
jari |
1904 |
|
2 |
26 Feb 07 |
jari |
1905 |
/* |
2 |
26 Feb 07 |
jari |
System.out.println("n = " + n); |
2 |
26 Feb 07 |
jari |
System.out.println("k = " + k); |
2 |
26 Feb 07 |
jari |
System.out.println("Numerator: factorial(n) = " + factorial(n)); |
2 |
26 Feb 07 |
jari |
System.out.println("factorial(k) = " + factorial(k)); |
2 |
26 Feb 07 |
jari |
System.out.println("factorial(n-k) = " + factorial(n-k)); |
2 |
26 Feb 07 |
jari |
1911 |
*/ |
2 |
26 Feb 07 |
jari |
1912 |
return Math.round(factorial(n)/(factorial(k)*factorial(n-k))); |
2 |
26 Feb 07 |
jari |
1913 |
} |
2 |
26 Feb 07 |
jari |
1914 |
|
2 |
26 Feb 07 |
jari |
1915 |
|
2 |
26 Feb 07 |
jari |
1916 |
public boolean isOkPressed() { |
2 |
26 Feb 07 |
jari |
1917 |
return okPressed; |
2 |
26 Feb 07 |
jari |
1918 |
} |
2 |
26 Feb 07 |
jari |
1919 |
|
2 |
26 Feb 07 |
jari |
1920 |
public boolean isDrawTrees() { |
2 |
26 Feb 07 |
jari |
1921 |
return hclOpsPanel.isHCLSelected(); |
2 |
26 Feb 07 |
jari |
1922 |
} |
2 |
26 Feb 07 |
jari |
1923 |
|
2 |
26 Feb 07 |
jari |
1924 |
public boolean drawSigTreesOnly() { |
2 |
26 Feb 07 |
jari |
1925 |
return hclOpsPanel.drawSigTreesOnly(); |
2 |
26 Feb 07 |
jari |
1926 |
} |
2 |
26 Feb 07 |
jari |
1927 |
|
2 |
26 Feb 07 |
jari |
1928 |
public int getTestDesign() { |
2 |
26 Feb 07 |
jari |
1929 |
int design = -1; |
2 |
26 Feb 07 |
jari |
1930 |
if (chooseDesignPane.getSelectedIndex() == 0) { |
2 |
26 Feb 07 |
jari |
1931 |
design = TtestInitDialog.ONE_CLASS; |
2 |
26 Feb 07 |
jari |
1932 |
} else if (chooseDesignPane.getSelectedIndex() == 1){ |
2 |
26 Feb 07 |
jari |
1933 |
design = TtestInitDialog.BETWEEN_SUBJECTS; |
2 |
26 Feb 07 |
jari |
1934 |
} else if (chooseDesignPane.getSelectedIndex() == 2) { |
2 |
26 Feb 07 |
jari |
1935 |
design = TtestInitDialog.PAIRED; |
2 |
26 Feb 07 |
jari |
1936 |
} |
2 |
26 Feb 07 |
jari |
1937 |
return design; |
2 |
26 Feb 07 |
jari |
1938 |
} |
2 |
26 Feb 07 |
jari |
1939 |
|
2 |
26 Feb 07 |
jari |
1940 |
public int[] getGroupAssignments() { |
2 |
26 Feb 07 |
jari |
1941 |
int[] groupAssignments = new int[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
1942 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
1943 |
if (gPanel.groupARadioButtons[i].isSelected()) { |
2 |
26 Feb 07 |
jari |
1944 |
groupAssignments[i] = GROUP_A; |
2 |
26 Feb 07 |
jari |
1945 |
} else if (gPanel.groupBRadioButtons[i].isSelected()) { |
2 |
26 Feb 07 |
jari |
1946 |
groupAssignments[i] = GROUP_B; |
2 |
26 Feb 07 |
jari |
1947 |
} else { |
2 |
26 Feb 07 |
jari |
1948 |
groupAssignments[i] = NEITHER_GROUP; |
2 |
26 Feb 07 |
jari |
1949 |
} |
2 |
26 Feb 07 |
jari |
1950 |
} |
2 |
26 Feb 07 |
jari |
1951 |
|
2 |
26 Feb 07 |
jari |
1952 |
return groupAssignments; |
2 |
26 Feb 07 |
jari |
1953 |
} |
2 |
26 Feb 07 |
jari |
1954 |
|
2 |
26 Feb 07 |
jari |
1955 |
public boolean isPermut() { |
2 |
26 Feb 07 |
jari |
1956 |
return pPanel.permutButton.isSelected(); |
2 |
26 Feb 07 |
jari |
1957 |
} |
2 |
26 Feb 07 |
jari |
1958 |
|
2 |
26 Feb 07 |
jari |
1959 |
public int getUserNumCombs() { |
2 |
26 Feb 07 |
jari |
1960 |
String s1 = pPanel.timesField.getText(); |
2 |
26 Feb 07 |
jari |
1961 |
int num = 0; |
2 |
26 Feb 07 |
jari |
1962 |
if (!useAllCombs()) { |
2 |
26 Feb 07 |
jari |
1963 |
num = Integer.parseInt(s1); |
2 |
26 Feb 07 |
jari |
1964 |
} else { |
2 |
26 Feb 07 |
jari |
1965 |
if (getTestDesign() == TtestInitDialog.BETWEEN_SUBJECTS) { |
2 |
26 Feb 07 |
jari |
1966 |
num = allPossCombs; |
2 |
26 Feb 07 |
jari |
1967 |
} else if (getTestDesign() == TtestInitDialog.ONE_CLASS) { |
2 |
26 Feb 07 |
jari |
1968 |
num = (int)Math.pow(2, getNumValidOneClassExpts()); |
2 |
26 Feb 07 |
jari |
1969 |
} else if (getTestDesign() == TtestInitDialog.PAIRED) { |
2 |
26 Feb 07 |
jari |
1970 |
num = (int)(Math.pow(2, tcpmPanel.tcpPanel.pairedListModel.size())); |
2 |
26 Feb 07 |
jari |
1971 |
} |
2 |
26 Feb 07 |
jari |
1972 |
} |
2 |
26 Feb 07 |
jari |
1973 |
return num; |
2 |
26 Feb 07 |
jari |
1974 |
} |
2 |
26 Feb 07 |
jari |
1975 |
|
2 |
26 Feb 07 |
jari |
1976 |
public double getAlphaValue() { |
2 |
26 Feb 07 |
jari |
1977 |
String s1 = pPanel.alphaInputField.getText(); |
2 |
26 Feb 07 |
jari |
1978 |
|
2 |
26 Feb 07 |
jari |
1979 |
return Double.parseDouble(s1); |
2 |
26 Feb 07 |
jari |
1980 |
} |
2 |
26 Feb 07 |
jari |
1981 |
|
2 |
26 Feb 07 |
jari |
1982 |
public int[] getOneClassAssignments() { |
2 |
26 Feb 07 |
jari |
1983 |
int[] oneClassAssignments = new int[oPanel.includeExpts.length]; |
2 |
26 Feb 07 |
jari |
1984 |
|
2 |
26 Feb 07 |
jari |
1985 |
for (int i = 0; i < oneClassAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
1986 |
if (oPanel.includeExpts[i].isSelected()) { |
2 |
26 Feb 07 |
jari |
1987 |
oneClassAssignments[i] = 1; |
2 |
26 Feb 07 |
jari |
1988 |
} else { |
2 |
26 Feb 07 |
jari |
1989 |
oneClassAssignments[i] = 0; |
2 |
26 Feb 07 |
jari |
1990 |
} |
2 |
26 Feb 07 |
jari |
1991 |
} |
2 |
26 Feb 07 |
jari |
1992 |
|
2 |
26 Feb 07 |
jari |
1993 |
return oneClassAssignments; |
2 |
26 Feb 07 |
jari |
1994 |
} |
2 |
26 Feb 07 |
jari |
1995 |
|
2 |
26 Feb 07 |
jari |
1996 |
public int getNumValidOneClassExpts() { |
2 |
26 Feb 07 |
jari |
1997 |
int validNum = 0; |
2 |
26 Feb 07 |
jari |
1998 |
int[] oca = getOneClassAssignments(); |
2 |
26 Feb 07 |
jari |
1999 |
|
2 |
26 Feb 07 |
jari |
2000 |
for (int i =0; i < oca.length; i++) { |
2 |
26 Feb 07 |
jari |
2001 |
if (oca[i] == 1) { |
2 |
26 Feb 07 |
jari |
2002 |
validNum++; |
2 |
26 Feb 07 |
jari |
2003 |
} |
2 |
26 Feb 07 |
jari |
2004 |
} |
2 |
26 Feb 07 |
jari |
2005 |
|
2 |
26 Feb 07 |
jari |
2006 |
return validNum; |
2 |
26 Feb 07 |
jari |
2007 |
} |
2 |
26 Feb 07 |
jari |
2008 |
|
2 |
26 Feb 07 |
jari |
2009 |
public double getOneClassMean() { |
2 |
26 Feb 07 |
jari |
2010 |
return Double.parseDouble(oPanel.meanField.getText()); |
2 |
26 Feb 07 |
jari |
2011 |
} |
2 |
26 Feb 07 |
jari |
2012 |
|
2 |
26 Feb 07 |
jari |
2013 |
public int getFalseNum() { |
2 |
26 Feb 07 |
jari |
2014 |
return Integer.parseInt(sPanel.falseNumField.getText()); |
2 |
26 Feb 07 |
jari |
2015 |
} |
2 |
26 Feb 07 |
jari |
2016 |
|
2 |
26 Feb 07 |
jari |
2017 |
public double getFalseProp() { |
2 |
26 Feb 07 |
jari |
2018 |
return Double.parseDouble(sPanel.falsePropField.getText()); |
2 |
26 Feb 07 |
jari |
2019 |
} |
2 |
26 Feb 07 |
jari |
2020 |
|
2 |
26 Feb 07 |
jari |
2021 |
public boolean validateAlpha(String alpha){ |
2 |
26 Feb 07 |
jari |
2022 |
float a; |
2 |
26 Feb 07 |
jari |
2023 |
try{ |
2 |
26 Feb 07 |
jari |
2024 |
a = Float.parseFloat(alpha); |
2 |
26 Feb 07 |
jari |
2025 |
} catch (NumberFormatException e){ |
2 |
26 Feb 07 |
jari |
2026 |
JOptionPane.showMessageDialog(TtestInitDialog.this, "Alpha value is not a valid input value.", "Input Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2027 |
pPanel.alphaInputField.requestFocus(); |
2 |
26 Feb 07 |
jari |
2028 |
pPanel.alphaInputField.selectAll(); |
2 |
26 Feb 07 |
jari |
2029 |
return false; |
2 |
26 Feb 07 |
jari |
2030 |
} |
2 |
26 Feb 07 |
jari |
2031 |
if(a <= 0 || a >= 1){ |
2 |
26 Feb 07 |
jari |
2032 |
JOptionPane.showMessageDialog(TtestInitDialog.this, "Alpha value must be > 0 and < 1.0", "Input Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2033 |
pPanel.alphaInputField.requestFocus(); |
2 |
26 Feb 07 |
jari |
2034 |
pPanel.alphaInputField.selectAll(); |
2 |
26 Feb 07 |
jari |
2035 |
return false; |
2 |
26 Feb 07 |
jari |
2036 |
} |
2 |
26 Feb 07 |
jari |
2037 |
return true; |
2 |
26 Feb 07 |
jari |
2038 |
} |
2 |
26 Feb 07 |
jari |
2039 |
|
2 |
26 Feb 07 |
jari |
2040 |
public boolean validateFalseNum() { |
2 |
26 Feb 07 |
jari |
2041 |
int a; |
2 |
26 Feb 07 |
jari |
2042 |
try { |
2 |
26 Feb 07 |
jari |
2043 |
String falseNum = sPanel.falseNumField.getText(); |
2 |
26 Feb 07 |
jari |
2044 |
a = Integer.parseInt(falseNum); |
2 |
26 Feb 07 |
jari |
2045 |
} catch (NumberFormatException e) { |
2 |
26 Feb 07 |
jari |
2046 |
JOptionPane.showMessageDialog(TtestInitDialog.this, "False number must be an integer >= 0", "Input Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2047 |
sPanel.falseNumField.requestFocus(); |
2 |
26 Feb 07 |
jari |
2048 |
sPanel.falseNumField.selectAll(); |
2 |
26 Feb 07 |
jari |
2049 |
return false; |
2 |
26 Feb 07 |
jari |
2050 |
} |
2 |
26 Feb 07 |
jari |
2051 |
if (a < 0) { |
2 |
26 Feb 07 |
jari |
2052 |
JOptionPane.showMessageDialog(TtestInitDialog.this, "False number must be an integer >= 0", "Input Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2053 |
sPanel.falseNumField.requestFocus(); |
2 |
26 Feb 07 |
jari |
2054 |
sPanel.falseNumField.selectAll(); |
2 |
26 Feb 07 |
jari |
2055 |
return false; |
2 |
26 Feb 07 |
jari |
2056 |
} |
2 |
26 Feb 07 |
jari |
2057 |
return true; |
2 |
26 Feb 07 |
jari |
2058 |
} |
2 |
26 Feb 07 |
jari |
2059 |
|
2 |
26 Feb 07 |
jari |
2060 |
public boolean validateFalseProp() { |
2 |
26 Feb 07 |
jari |
2061 |
float a; |
2 |
26 Feb 07 |
jari |
2062 |
try { |
2 |
26 Feb 07 |
jari |
2063 |
String falseProp = sPanel.falsePropField.getText(); |
2 |
26 Feb 07 |
jari |
2064 |
a = Float.parseFloat(falseProp); |
2 |
26 Feb 07 |
jari |
2065 |
} catch (NumberFormatException e) { |
2 |
26 Feb 07 |
jari |
2066 |
JOptionPane.showMessageDialog(TtestInitDialog.this, "False proportion must be between 0 and 1", "Input Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2067 |
sPanel.falsePropField.requestFocus(); |
2 |
26 Feb 07 |
jari |
2068 |
sPanel.falsePropField.selectAll(); |
2 |
26 Feb 07 |
jari |
2069 |
return false; |
2 |
26 Feb 07 |
jari |
2070 |
} |
2 |
26 Feb 07 |
jari |
2071 |
if ((a <= 0) || (a > 1)) { |
2 |
26 Feb 07 |
jari |
2072 |
JOptionPane.showMessageDialog(TtestInitDialog.this, "False proportion must be between 0 and 1", "Input Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2073 |
sPanel.falsePropField.requestFocus(); |
2 |
26 Feb 07 |
jari |
2074 |
sPanel.falsePropField.selectAll(); |
2 |
26 Feb 07 |
jari |
2075 |
return false; |
2 |
26 Feb 07 |
jari |
2076 |
} |
2 |
26 Feb 07 |
jari |
2077 |
return true; |
2 |
26 Feb 07 |
jari |
2078 |
} |
2 |
26 Feb 07 |
jari |
2079 |
|
2 |
26 Feb 07 |
jari |
2080 |
public boolean validatePermutations(String n){ |
2 |
26 Feb 07 |
jari |
2081 |
int i; |
2 |
26 Feb 07 |
jari |
2082 |
try { |
2 |
26 Feb 07 |
jari |
2083 |
i = Integer.parseInt(n); |
2 |
26 Feb 07 |
jari |
2084 |
} catch (NumberFormatException e){ |
2 |
26 Feb 07 |
jari |
2085 |
JOptionPane.showMessageDialog(TtestInitDialog.this, "Number of Permutations is not a valid input value.", "Input Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2086 |
pPanel.timesField.requestFocus(); |
2 |
26 Feb 07 |
jari |
2087 |
pPanel.timesField.selectAll(); |
2 |
26 Feb 07 |
jari |
2088 |
return false; |
2 |
26 Feb 07 |
jari |
2089 |
} |
2 |
26 Feb 07 |
jari |
2090 |
if(i <= 0){ |
2 |
26 Feb 07 |
jari |
2091 |
JOptionPane.showMessageDialog(TtestInitDialog.this, "Number of Permutations must be > 0", "Input Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2092 |
pPanel.timesField.requestFocus(); |
2 |
26 Feb 07 |
jari |
2093 |
pPanel.timesField.selectAll(); |
2 |
26 Feb 07 |
jari |
2094 |
return false; |
2 |
26 Feb 07 |
jari |
2095 |
} |
2 |
26 Feb 07 |
jari |
2096 |
return true; |
2 |
26 Feb 07 |
jari |
2097 |
} |
2 |
26 Feb 07 |
jari |
2098 |
|
2 |
26 Feb 07 |
jari |
2099 |
|
2 |
26 Feb 07 |
jari |
2100 |
public class EventListener implements ActionListener{ |
2 |
26 Feb 07 |
jari |
2101 |
|
2 |
26 Feb 07 |
jari |
2102 |
public void actionPerformed(ActionEvent ae){ |
2 |
26 Feb 07 |
jari |
2103 |
|
2 |
26 Feb 07 |
jari |
2104 |
String command = ae.getActionCommand(); |
2 |
26 Feb 07 |
jari |
2105 |
|
2 |
26 Feb 07 |
jari |
2106 |
if(command.equals("ok-command")){ |
2 |
26 Feb 07 |
jari |
2107 |
if (getTestDesign() == TtestInitDialog.BETWEEN_SUBJECTS) { |
2 |
26 Feb 07 |
jari |
2108 |
int[] grpAssignments = getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
2109 |
int grpACounter = 0; |
2 |
26 Feb 07 |
jari |
2110 |
int grpBCounter = 0; |
2 |
26 Feb 07 |
jari |
2111 |
for (int i = 0; i < grpAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
2112 |
if (grpAssignments[i] == GROUP_A) { |
2 |
26 Feb 07 |
jari |
2113 |
grpACounter++; |
2 |
26 Feb 07 |
jari |
2114 |
} else if (grpAssignments[i] == GROUP_B) { |
2 |
26 Feb 07 |
jari |
2115 |
grpBCounter++; |
2 |
26 Feb 07 |
jari |
2116 |
} |
2 |
26 Feb 07 |
jari |
2117 |
} |
2 |
26 Feb 07 |
jari |
2118 |
if ((grpACounter < 2) || (grpBCounter < 2)) { |
2 |
26 Feb 07 |
jari |
2119 |
JOptionPane.showMessageDialog(gPanel, "Group A and Group B must each contain more than one sample", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2120 |
} else { |
2 |
26 Feb 07 |
jari |
2121 |
String alpha = pPanel.alphaInputField.getText(); |
2 |
26 Feb 07 |
jari |
2122 |
float a; |
2 |
26 Feb 07 |
jari |
2123 |
if(pPanel.permutButton.isSelected() && pPanel.randomGroupsButton.isSelected()){ |
2 |
26 Feb 07 |
jari |
2124 |
String iter = pPanel.timesField.getText(); |
2 |
26 Feb 07 |
jari |
2125 |
if(!validatePermutations(iter)){ |
2 |
26 Feb 07 |
jari |
2126 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
2127 |
return; |
2 |
26 Feb 07 |
jari |
2128 |
} |
2 |
26 Feb 07 |
jari |
2129 |
} |
2 |
26 Feb 07 |
jari |
2130 |
if(!validateAlpha(alpha)){ |
2 |
26 Feb 07 |
jari |
2131 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
2132 |
return; |
2 |
26 Feb 07 |
jari |
2133 |
} |
2 |
26 Feb 07 |
jari |
2134 |
if (sPanel.falseNumButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
2135 |
if (!validateFalseNum()) { |
2 |
26 Feb 07 |
jari |
2136 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
2137 |
return; |
2 |
26 Feb 07 |
jari |
2138 |
} |
2 |
26 Feb 07 |
jari |
2139 |
} |
2 |
26 Feb 07 |
jari |
2140 |
if (sPanel.falsePropButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
2141 |
if (!validateFalseProp()) { |
2 |
26 Feb 07 |
jari |
2142 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
2143 |
return; |
2 |
26 Feb 07 |
jari |
2144 |
} |
2 |
26 Feb 07 |
jari |
2145 |
} |
2 |
26 Feb 07 |
jari |
2146 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
2147 |
hide(); |
2 |
26 Feb 07 |
jari |
2148 |
dispose(); |
2 |
26 Feb 07 |
jari |
2149 |
} |
2 |
26 Feb 07 |
jari |
2150 |
} else if (getTestDesign() == TtestInitDialog.ONE_CLASS) { |
2 |
26 Feb 07 |
jari |
2151 |
try { |
2 |
26 Feb 07 |
jari |
2152 |
float mean = Float.parseFloat(oPanel.meanField.getText()); |
2 |
26 Feb 07 |
jari |
2153 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
2154 |
JOptionPane.showMessageDialog(oPanel, "Invalid value entered for mean", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2155 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
2156 |
return; |
2 |
26 Feb 07 |
jari |
2157 |
} |
2 |
26 Feb 07 |
jari |
2158 |
|
2 |
26 Feb 07 |
jari |
2159 |
if (getNumValidOneClassExpts() < 2) { |
2 |
26 Feb 07 |
jari |
2160 |
JOptionPane.showMessageDialog(oPanel, "Select at least two samples", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
2161 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
2162 |
return; |
2 |
26 Feb 07 |
jari |
2163 |
} |
2 |
26 Feb 07 |
jari |
2164 |
|
2 |
26 Feb 07 |
jari |
2165 |
String alpha = pPanel.alphaInputField.getText(); |
2 |
26 Feb 07 |
jari |
2166 |
|
2 |
26 Feb 07 |
jari |
2167 |
float a; |
2 |
26 Feb 07 |
jari |
2168 |
if(pPanel.permutButton.isSelected() && pPanel.randomGroupsButton.isSelected()){ |
2 |
26 Feb 07 |
jari |
2169 |
String iter = pPanel.timesField.getText(); |
2 |
26 Feb 07 |
jari |
2170 |
if(!validatePermutations(iter)){ |
2 |
26 Feb 07 |
jari |
2171 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
2172 |
return; |
2 |
26 Feb 07 |
jari |
2173 |
} |
2 |
26 Feb 07 |
jari |
2174 |
} |
2 |
26 Feb 07 |
jari |
2175 |
if(!validateAlpha(alpha)){ |
2 |
26 Feb 07 |
jari |
2176 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
2177 |
return; |
2 |
26 Feb 07 |
jari |
2178 |
} |
2 |
26 Feb 07 |
jari |
2179 |
|
2 |
26 Feb 07 |
jari |
2180 |
if (sPanel.falseNumButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
2181 |
if (!validateFalseNum()) { |
2 |
26 Feb 07 |
jari |
2182 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
2183 |
return; |
2 |
26 Feb 07 |
jari |
2184 |
} |
2 |
26 Feb 07 |
jari |
2185 |
} |
2 |
26 Feb 07 |
jari |
2186 |
if (sPanel.falsePropButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
2187 |
if (!validateFalseProp()) { |
2 |
26 Feb 07 |
jari |
2188 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
2189 |
return; |
2 |
26 Feb 07 |
jari |
2190 |
} |
2 |
26 Feb 07 |
jari |
2191 |
} |
2 |
26 Feb 07 |
jari |
2192 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
2193 |
hide(); |
2 |
26 Feb 07 |
jari |
2194 |
dispose(); |
2 |
26 Feb 07 |
jari |
2195 |
} else if (getTestDesign() == TtestInitDialog.PAIRED) { |
2 |
26 Feb 07 |
jari |
2196 |
if (tcpmPanel.tcpPanel.pairedListModel.size() < 2) { |
2 |
26 Feb 07 |
jari |
2197 |
JOptionPane.showMessageDialog(null, "Need at least two pairs of samples!", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
2198 |
} else { |
2 |
26 Feb 07 |
jari |
2199 |
if (tcpmPanel.tcpPanel.pairedListModel.size() <= 29) { |
2 |
26 Feb 07 |
jari |
2200 |
int numCombs = getUserNumCombs(); |
2 |
26 Feb 07 |
jari |
2201 |
int numUniquePerms = (int)(Math.pow(2, tcpmPanel.tcpPanel.pairedListModel.size())); |
2 |
26 Feb 07 |
jari |
//SAMAllPermsDialog sapDialog = new SAMAllPermsDialog(SAMGUI.SAMFrame, true, numUniquePerms, numCombs); |
2 |
26 Feb 07 |
jari |
//sapDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
//allUniquePermsUsed = sapDialog.useAllPerms(); |
2 |
26 Feb 07 |
jari |
2205 |
} |
2 |
26 Feb 07 |
jari |
2206 |
|
2 |
26 Feb 07 |
jari |
2207 |
|
2 |
26 Feb 07 |
jari |
2208 |
String alpha = pPanel.alphaInputField.getText(); |
2 |
26 Feb 07 |
jari |
2209 |
|
2 |
26 Feb 07 |
jari |
2210 |
float a; |
2 |
26 Feb 07 |
jari |
2211 |
if(pPanel.permutButton.isSelected() && pPanel.randomGroupsButton.isSelected()){ |
2 |
26 Feb 07 |
jari |
2212 |
String iter = pPanel.timesField.getText(); |
2 |
26 Feb 07 |
jari |
2213 |
if(!validatePermutations(iter)){ |
2 |
26 Feb 07 |
jari |
2214 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
2215 |
return; |
2 |
26 Feb 07 |
jari |
2216 |
} |
2 |
26 Feb 07 |
jari |
2217 |
} |
2 |
26 Feb 07 |
jari |
2218 |
if(!validateAlpha(alpha)){ |
2 |
26 Feb 07 |
jari |
2219 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
2220 |
return; |
2 |
26 Feb 07 |
jari |
2221 |
} |
2 |
26 Feb 07 |
jari |
2222 |
|
2 |
26 Feb 07 |
jari |
2223 |
if (sPanel.falseNumButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
2224 |
if (!validateFalseNum()) { |
2 |
26 Feb 07 |
jari |
2225 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
2226 |
return; |
2 |
26 Feb 07 |
jari |
2227 |
} |
2 |
26 Feb 07 |
jari |
2228 |
} |
2 |
26 Feb 07 |
jari |
2229 |
if (sPanel.falsePropButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
2230 |
if (!validateFalseProp()) { |
2 |
26 Feb 07 |
jari |
2231 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
2232 |
return; |
2 |
26 Feb 07 |
jari |
2233 |
} |
2 |
26 Feb 07 |
jari |
2234 |
} |
2 |
26 Feb 07 |
jari |
2235 |
|
2 |
26 Feb 07 |
jari |
2236 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
2237 |
javax.swing.UIManager.put("TabbedPane.selected", Color.lightGray); |
2 |
26 Feb 07 |
jari |
2238 |
dispose(); |
2 |
26 Feb 07 |
jari |
2239 |
} |
2 |
26 Feb 07 |
jari |
2240 |
|
2 |
26 Feb 07 |
jari |
2241 |
} |
2 |
26 Feb 07 |
jari |
2242 |
} else if(command.equals("reset-command")){ |
2 |
26 Feb 07 |
jari |
2243 |
if (getTestDesign() == TtestInitDialog.BETWEEN_SUBJECTS) { |
2 |
26 Feb 07 |
jari |
2244 |
gPanel.reset(); |
2 |
26 Feb 07 |
jari |
2245 |
} else if (getTestDesign() == TtestInitDialog.ONE_CLASS) { |
2 |
26 Feb 07 |
jari |
2246 |
oPanel.reset(); |
2 |
26 Feb 07 |
jari |
2247 |
} else if (getTestDesign() == TtestInitDialog.PAIRED) { |
2 |
26 Feb 07 |
jari |
2248 |
tcpmPanel.tcpPanel.reset(); |
2 |
26 Feb 07 |
jari |
2249 |
} |
2 |
26 Feb 07 |
jari |
2250 |
pPanel.tDistButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
2251 |
pPanel.randomGroupsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2252 |
pPanel.allCombsButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2253 |
pPanel.timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
2254 |
pPanel.timesField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
2255 |
pPanel.timesField.setText("100"); |
2 |
26 Feb 07 |
jari |
2256 |
pPanel.numCombsLabel.setText(" "); |
2 |
26 Feb 07 |
jari |
2257 |
pPanel.alphaInputField.setText("0.01"); |
2 |
26 Feb 07 |
jari |
2258 |
sPanel.justAlphaButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
2259 |
sPanel.falseNumField.setText("10"); |
2 |
26 Feb 07 |
jari |
2260 |
sPanel.falsePropField.setText("0.05"); |
2 |
26 Feb 07 |
jari |
2261 |
hclOpsPanel.setHCLSelected(false); |
2 |
26 Feb 07 |
jari |
2262 |
dPanel.reset(); |
2 |
26 Feb 07 |
jari |
2263 |
} else if(command.equals("cancel-command")){ |
2 |
26 Feb 07 |
jari |
2264 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
2265 |
setVisible(false); |
2 |
26 Feb 07 |
jari |
2266 |
dispose(); |
2 |
26 Feb 07 |
jari |
2267 |
} else if(command.equals("info-command")){ |
2 |
26 Feb 07 |
jari |
2268 |
HelpWindow helpWindow = new HelpWindow(TtestInitDialog.this, "TTEST Initialization Dialog"); |
2 |
26 Feb 07 |
jari |
2269 |
if(helpWindow.getWindowContent()){ |
2 |
26 Feb 07 |
jari |
2270 |
helpWindow.setSize(450, 600); |
2 |
26 Feb 07 |
jari |
2271 |
helpWindow.setLocation(); |
2 |
26 Feb 07 |
jari |
2272 |
helpWindow.show(); |
2 |
26 Feb 07 |
jari |
2273 |
} else{ |
2 |
26 Feb 07 |
jari |
2274 |
helpWindow.dispose(); |
2 |
26 Feb 07 |
jari |
2275 |
} |
2 |
26 Feb 07 |
jari |
2276 |
} |
2 |
26 Feb 07 |
jari |
2277 |
} |
2 |
26 Feb 07 |
jari |
2278 |
} |
2 |
26 Feb 07 |
jari |
2279 |
|
2 |
26 Feb 07 |
jari |
2280 |
|
2 |
26 Feb 07 |
jari |
2281 |
public Vector getPairedAExpts() { |
2 |
26 Feb 07 |
jari |
2282 |
return tcpmPanel.tcpPanel.pairedAExpts; |
2 |
26 Feb 07 |
jari |
2283 |
} |
2 |
26 Feb 07 |
jari |
2284 |
|
2 |
26 Feb 07 |
jari |
2285 |
public Vector getPairedBExpts() { |
2 |
26 Feb 07 |
jari |
2286 |
return tcpmPanel.tcpPanel.pairedBExpts; |
2 |
26 Feb 07 |
jari |
2287 |
} |
2 |
26 Feb 07 |
jari |
2288 |
|
2 |
26 Feb 07 |
jari |
2289 |
public int getSignificanceMethod() { |
2 |
26 Feb 07 |
jari |
2290 |
if (sPanel.justAlphaButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
2291 |
return TtestInitDialog.JUST_ALPHA; |
2 |
26 Feb 07 |
jari |
2292 |
} else if (sPanel.stdBonfButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
2293 |
return TtestInitDialog.STD_BONFERRONI; |
2 |
26 Feb 07 |
jari |
2294 |
} else if (sPanel.adjBonfButton.isSelected()){ |
2 |
26 Feb 07 |
jari |
2295 |
return TtestInitDialog.ADJ_BONFERRONI; |
2 |
26 Feb 07 |
jari |
2296 |
} else if (sPanel.maxTButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
2297 |
return TtestInitDialog.MAX_T; |
2 |
26 Feb 07 |
jari |
2298 |
} else if (sPanel.minPButton.isSelected()){ |
2 |
26 Feb 07 |
jari |
2299 |
return TtestInitDialog.MIN_P; |
2 |
26 Feb 07 |
jari |
2300 |
} else if (sPanel.falseNumButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
2301 |
return TtestInitDialog.FALSE_NUM; |
2 |
26 Feb 07 |
jari |
2302 |
} else if (sPanel.falsePropButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
2303 |
return TtestInitDialog.FALSE_PROP; |
2 |
26 Feb 07 |
jari |
2304 |
} else { |
2 |
26 Feb 07 |
jari |
2305 |
return -1; |
2 |
26 Feb 07 |
jari |
2306 |
} |
2 |
26 Feb 07 |
jari |
2307 |
} |
2 |
26 Feb 07 |
jari |
2308 |
|
2 |
26 Feb 07 |
jari |
2309 |
public boolean calculateFDRPVals() { |
2 |
26 Feb 07 |
jari |
2310 |
return sPanel.calcFDRPVals.isSelected(); |
2 |
26 Feb 07 |
jari |
2311 |
} |
2 |
26 Feb 07 |
jari |
2312 |
|
2 |
26 Feb 07 |
jari |
2313 |
public boolean doFastFDRApprox() { |
2 |
26 Feb 07 |
jari |
2314 |
return sPanel.fastFDRButton.isSelected(); |
2 |
26 Feb 07 |
jari |
2315 |
} |
2 |
26 Feb 07 |
jari |
2316 |
|
2 |
26 Feb 07 |
jari |
2317 |
public boolean useWelchDf() { |
2 |
26 Feb 07 |
jari |
2318 |
return dPanel.welchButton.isSelected(); |
2 |
26 Feb 07 |
jari |
2319 |
} |
2 |
26 Feb 07 |
jari |
2320 |
|
2 |
26 Feb 07 |
jari |
2321 |
public boolean useAllCombs() { |
2 |
26 Feb 07 |
jari |
2322 |
return pPanel.allCombsButton.isSelected(); |
2 |
26 Feb 07 |
jari |
2323 |
} |
2 |
26 Feb 07 |
jari |
2324 |
|
2 |
26 Feb 07 |
jari |
2325 |
public static void main(String[] args) { |
2 |
26 Feb 07 |
jari |
2326 |
JFrame dummyFrame = new JFrame(); |
2 |
26 Feb 07 |
jari |
2327 |
Vector nameVector = new Vector(); |
2 |
26 Feb 07 |
jari |
2328 |
|
2 |
26 Feb 07 |
jari |
2329 |
for (int i = 0; i < 10; i++) { |
2 |
26 Feb 07 |
jari |
2330 |
nameVector.add("Exp " + i); |
2 |
26 Feb 07 |
jari |
2331 |
} |
2 |
26 Feb 07 |
jari |
2332 |
TtestInitDialog tDialog= new TtestInitDialog(dummyFrame, true, nameVector); |
2 |
26 Feb 07 |
jari |
2333 |
for (int i = 0; i < 50; i++) { |
2 |
26 Feb 07 |
jari |
2334 |
System.out.println("2^" + i + " = " + (int)Math.pow(2, i)); |
2 |
26 Feb 07 |
jari |
2335 |
} |
2 |
26 Feb 07 |
jari |
2336 |
|
2 |
26 Feb 07 |
jari |
2337 |
tDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
2338 |
|
2 |
26 Feb 07 |
jari |
2339 |
System.exit(0); |
2 |
26 Feb 07 |
jari |
2340 |
} |
2 |
26 Feb 07 |
jari |
2341 |
} |