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 |
* TFAInitBox2.java |
2 |
26 Feb 07 |
jari |
7 |
* |
2 |
26 Feb 07 |
jari |
* Created on February 12, 2004, 4:15 PM |
2 |
26 Feb 07 |
jari |
9 |
*/ |
2 |
26 Feb 07 |
jari |
10 |
|
2 |
26 Feb 07 |
jari |
11 |
package org.tigr.microarray.mev.cluster.gui.impl.tfa; |
2 |
26 Feb 07 |
jari |
12 |
|
2 |
26 Feb 07 |
jari |
13 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Font; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.GridBagConstraints; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.Toolkit; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.event.WindowAdapter; |
2 |
26 Feb 07 |
jari |
23 |
import java.io.BufferedReader; |
2 |
26 Feb 07 |
jari |
24 |
import java.io.File; |
2 |
26 Feb 07 |
jari |
25 |
import java.io.FileOutputStream; |
2 |
26 Feb 07 |
jari |
26 |
import java.io.FileReader; |
2 |
26 Feb 07 |
jari |
27 |
import java.io.PrintWriter; |
2 |
26 Feb 07 |
jari |
28 |
import java.util.Vector; |
2 |
26 Feb 07 |
jari |
29 |
|
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.JButton; |
2 |
26 Feb 07 |
jari |
33 |
import javax.swing.JFileChooser; |
2 |
26 Feb 07 |
jari |
34 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
35 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
36 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
37 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
38 |
import javax.swing.JRadioButton; |
2 |
26 Feb 07 |
jari |
39 |
import javax.swing.JScrollPane; |
2 |
26 Feb 07 |
jari |
40 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
41 |
import javax.swing.ScrollPaneConstants; |
2 |
26 Feb 07 |
jari |
42 |
import javax.swing.UIManager; |
2 |
26 Feb 07 |
jari |
43 |
import javax.swing.border.BevelBorder; |
2 |
26 Feb 07 |
jari |
44 |
import javax.swing.border.EtchedBorder; |
2 |
26 Feb 07 |
jari |
45 |
import javax.swing.border.TitledBorder; |
2 |
26 Feb 07 |
jari |
46 |
|
2 |
26 Feb 07 |
jari |
47 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.AlgorithmDialog; |
2 |
26 Feb 07 |
jari |
48 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.HCLSigOnlyPanel; |
2 |
26 Feb 07 |
jari |
49 |
import org.tigr.util.StringSplitter; |
2 |
26 Feb 07 |
jari |
50 |
|
2 |
26 Feb 07 |
jari |
51 |
|
2 |
26 Feb 07 |
jari |
52 |
/** |
2 |
26 Feb 07 |
jari |
53 |
* |
2 |
26 Feb 07 |
jari |
* @author nbhagaba |
2 |
26 Feb 07 |
jari |
55 |
*/ |
2 |
26 Feb 07 |
jari |
56 |
public class TFAInitBox2 extends AlgorithmDialog { |
2 |
26 Feb 07 |
jari |
57 |
|
2 |
26 Feb 07 |
jari |
58 |
public static final int JUST_ALPHA = 4; |
2 |
26 Feb 07 |
jari |
59 |
public static final int STD_BONFERRONI = 5; |
2 |
26 Feb 07 |
jari |
60 |
public static final int ADJ_BONFERRONI = 6; |
2 |
26 Feb 07 |
jari |
61 |
public static final int MAX_T = 9; |
2 |
26 Feb 07 |
jari |
62 |
public static final int MIN_P = 10; |
2 |
26 Feb 07 |
jari |
63 |
|
2 |
26 Feb 07 |
jari |
64 |
boolean okPressed = false; |
2 |
26 Feb 07 |
jari |
65 |
private boolean oneSamplePerCell = false; |
2 |
26 Feb 07 |
jari |
66 |
Vector exptNames; |
2 |
26 Feb 07 |
jari |
67 |
String[] factorNames; |
2 |
26 Feb 07 |
jari |
68 |
int[] numFactorLevels; |
2 |
26 Feb 07 |
jari |
69 |
GroupExptsPanel gPanel; |
2 |
26 Feb 07 |
jari |
70 |
PValuePanel pPanel; |
2 |
26 Feb 07 |
jari |
71 |
PValueAdjustmentPanel pAdjPanel; |
2 |
26 Feb 07 |
jari |
72 |
HCLSigOnlyPanel hclOpsPanel; |
2 |
26 Feb 07 |
jari |
//HCLSelectionPanel hclOpsPanel; |
2 |
26 Feb 07 |
jari |
/** Creates a new instance of TFAInitBox2 */ |
2 |
26 Feb 07 |
jari |
75 |
public TFAInitBox2(JFrame parentFrame, boolean modality, Vector exptNames, String[] factorNames, int[] numFactorLevels) { |
2 |
26 Feb 07 |
jari |
76 |
super(parentFrame, "Two-factor ANOVA Initialization", modality); |
2 |
26 Feb 07 |
jari |
77 |
this.exptNames = exptNames; |
2 |
26 Feb 07 |
jari |
78 |
this.factorNames = factorNames; |
2 |
26 Feb 07 |
jari |
79 |
this.numFactorLevels = numFactorLevels; |
2 |
26 Feb 07 |
jari |
80 |
|
2 |
26 Feb 07 |
jari |
81 |
setBounds(0, 0, 800, 720); |
2 |
26 Feb 07 |
jari |
82 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
83 |
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
2 |
26 Feb 07 |
jari |
84 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
85 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
86 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
87 |
|
2 |
26 Feb 07 |
jari |
88 |
JPanel pane = new JPanel(); |
2 |
26 Feb 07 |
jari |
89 |
pane.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
90 |
|
2 |
26 Feb 07 |
jari |
91 |
gPanel = new GroupExptsPanel(); |
2 |
26 Feb 07 |
jari |
92 |
|
2 |
26 Feb 07 |
jari |
93 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 80); |
2 |
26 Feb 07 |
jari |
94 |
gridbag.setConstraints(gPanel, constraints); |
2 |
26 Feb 07 |
jari |
95 |
pane.add(gPanel); |
2 |
26 Feb 07 |
jari |
96 |
|
2 |
26 Feb 07 |
jari |
97 |
pPanel = new PValuePanel(); |
2 |
26 Feb 07 |
jari |
98 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 8); |
2 |
26 Feb 07 |
jari |
99 |
gridbag.setConstraints(pPanel, constraints); |
2 |
26 Feb 07 |
jari |
100 |
pane.add(pPanel); |
2 |
26 Feb 07 |
jari |
101 |
|
2 |
26 Feb 07 |
jari |
102 |
pAdjPanel = new PValueAdjustmentPanel(); |
2 |
26 Feb 07 |
jari |
103 |
buildConstraints(constraints, 0, 2, 1, 1, 0, 8); |
2 |
26 Feb 07 |
jari |
104 |
gridbag.setConstraints(pAdjPanel, constraints); |
2 |
26 Feb 07 |
jari |
105 |
pane.add(pAdjPanel); |
2 |
26 Feb 07 |
jari |
106 |
|
2 |
26 Feb 07 |
jari |
107 |
hclOpsPanel = new HCLSigOnlyPanel(); |
2 |
26 Feb 07 |
jari |
108 |
buildConstraints(constraints, 0, 3, 1, 1, 0, 4); |
2 |
26 Feb 07 |
jari |
109 |
gridbag.setConstraints(hclOpsPanel, constraints); |
2 |
26 Feb 07 |
jari |
110 |
pane.add(hclOpsPanel); |
2 |
26 Feb 07 |
jari |
111 |
|
2 |
26 Feb 07 |
jari |
112 |
addContent(pane); |
2 |
26 Feb 07 |
jari |
113 |
EventListener listener = new EventListener(); |
2 |
26 Feb 07 |
jari |
114 |
setActionListeners(listener); |
2 |
26 Feb 07 |
jari |
115 |
this.addWindowListener(listener); |
2 |
26 Feb 07 |
jari |
116 |
} |
2 |
26 Feb 07 |
jari |
117 |
|
2 |
26 Feb 07 |
jari |
118 |
void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) { |
2 |
26 Feb 07 |
jari |
119 |
gbc.gridx = gx; |
2 |
26 Feb 07 |
jari |
120 |
gbc.gridy = gy; |
2 |
26 Feb 07 |
jari |
121 |
gbc.gridwidth = gw; |
2 |
26 Feb 07 |
jari |
122 |
gbc.gridheight = gh; |
2 |
26 Feb 07 |
jari |
123 |
gbc.weightx = wx; |
2 |
26 Feb 07 |
jari |
124 |
gbc.weighty = wy; |
2 |
26 Feb 07 |
jari |
125 |
} |
2 |
26 Feb 07 |
jari |
126 |
|
2 |
26 Feb 07 |
jari |
127 |
class GroupExptsPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
128 |
MultiGroupExperimentsPanel factorAPanel, factorBPanel; |
2 |
26 Feb 07 |
jari |
129 |
JPanel panel2; |
2 |
26 Feb 07 |
jari |
130 |
GroupExptsPanel() { |
2 |
26 Feb 07 |
jari |
131 |
this.setBorder(new TitledBorder(new EtchedBorder(), "Group Assignments", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
132 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
133 |
factorAPanel = new MultiGroupExperimentsPanel(factorNames[0], numFactorLevels[0]); |
2 |
26 Feb 07 |
jari |
134 |
factorBPanel = new MultiGroupExperimentsPanel(factorNames[1], numFactorLevels[1]); |
2 |
26 Feb 07 |
jari |
135 |
|
2 |
26 Feb 07 |
jari |
136 |
GridBagLayout grid1 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
137 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
138 |
this.setLayout(grid1); |
2 |
26 Feb 07 |
jari |
139 |
|
2 |
26 Feb 07 |
jari |
140 |
buildConstraints(constraints, 0, 0, 1, 1, 50, 90); |
2 |
26 Feb 07 |
jari |
141 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
142 |
grid1.setConstraints(factorAPanel, constraints); |
2 |
26 Feb 07 |
jari |
143 |
this.add(factorAPanel); |
2 |
26 Feb 07 |
jari |
144 |
|
2 |
26 Feb 07 |
jari |
145 |
buildConstraints(constraints, 1, 0, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
146 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
147 |
grid1.setConstraints(factorBPanel, constraints); |
2 |
26 Feb 07 |
jari |
148 |
this.add(factorBPanel); |
2 |
26 Feb 07 |
jari |
149 |
|
2 |
26 Feb 07 |
jari |
150 |
JPanel panel2 = new JPanel(); |
2 |
26 Feb 07 |
jari |
151 |
GridBagLayout gridbag3 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
152 |
panel2.setLayout(gridbag3); |
2 |
26 Feb 07 |
jari |
153 |
panel2.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
154 |
JButton saveButton = new JButton(" Save settings "); |
2 |
26 Feb 07 |
jari |
155 |
saveButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
156 |
saveButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.lightGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
157 |
JButton loadButton = new JButton(" Load settings "); |
2 |
26 Feb 07 |
jari |
158 |
loadButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
159 |
loadButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.lightGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
160 |
JButton resetButton = new JButton(" Reset "); |
2 |
26 Feb 07 |
jari |
161 |
resetButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
162 |
resetButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.lightGray, Color.darkGray)); |
2 |
26 Feb 07 |
jari |
163 |
|
2 |
26 Feb 07 |
jari |
164 |
|
2 |
26 Feb 07 |
jari |
//final int finNum = exptNames.size(); |
2 |
26 Feb 07 |
jari |
166 |
|
2 |
26 Feb 07 |
jari |
167 |
resetButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
168 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
169 |
factorAPanel.reset(); |
2 |
26 Feb 07 |
jari |
170 |
factorBPanel.reset(); |
2 |
26 Feb 07 |
jari |
171 |
} |
2 |
26 Feb 07 |
jari |
172 |
}); |
2 |
26 Feb 07 |
jari |
173 |
|
2 |
26 Feb 07 |
jari |
174 |
final JFileChooser fc = new JFileChooser(); |
2 |
26 Feb 07 |
jari |
175 |
fc.setCurrentDirectory(new File("Data")); |
2 |
26 Feb 07 |
jari |
176 |
|
2 |
26 Feb 07 |
jari |
177 |
saveButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
178 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
179 |
int returnVal = fc.showSaveDialog(GroupExptsPanel.this); |
2 |
26 Feb 07 |
jari |
180 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
181 |
File file = fc.getSelectedFile(); |
2 |
26 Feb 07 |
jari |
182 |
try { |
2 |
26 Feb 07 |
jari |
183 |
PrintWriter out = new PrintWriter(new FileOutputStream(file)); |
2 |
26 Feb 07 |
jari |
184 |
int[] factorAGroupAssgn = factorAPanel.getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
185 |
int[] factorBGroupAssgn = factorBPanel.getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
186 |
for (int i = 0; i < factorAGroupAssgn.length; i++) { |
2 |
26 Feb 07 |
jari |
187 |
out.print(factorAGroupAssgn[i]); |
2 |
26 Feb 07 |
jari |
188 |
if (i < factorAGroupAssgn.length - 1) { |
2 |
26 Feb 07 |
jari |
189 |
out.print("\t"); |
2 |
26 Feb 07 |
jari |
190 |
} |
2 |
26 Feb 07 |
jari |
191 |
} |
2 |
26 Feb 07 |
jari |
192 |
out.println(); |
2 |
26 Feb 07 |
jari |
193 |
|
2 |
26 Feb 07 |
jari |
194 |
for (int i = 0; i < factorBGroupAssgn.length; i++) { |
2 |
26 Feb 07 |
jari |
195 |
out.print(factorBGroupAssgn[i]); |
2 |
26 Feb 07 |
jari |
196 |
if (i < factorBGroupAssgn.length - 1) { |
2 |
26 Feb 07 |
jari |
197 |
out.print("\t"); |
2 |
26 Feb 07 |
jari |
198 |
} |
2 |
26 Feb 07 |
jari |
199 |
} |
2 |
26 Feb 07 |
jari |
200 |
out.println(); |
2 |
26 Feb 07 |
jari |
201 |
|
2 |
26 Feb 07 |
jari |
202 |
out.flush(); |
2 |
26 Feb 07 |
jari |
203 |
out.close(); |
2 |
26 Feb 07 |
jari |
204 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
//e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
206 |
} |
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 |
209 |
} else { |
2 |
26 Feb 07 |
jari |
//log.append("Save command cancelled by user." + newline); |
2 |
26 Feb 07 |
jari |
211 |
} |
2 |
26 Feb 07 |
jari |
212 |
} |
2 |
26 Feb 07 |
jari |
213 |
}); |
2 |
26 Feb 07 |
jari |
214 |
|
2 |
26 Feb 07 |
jari |
215 |
|
2 |
26 Feb 07 |
jari |
216 |
|
2 |
26 Feb 07 |
jari |
217 |
|
2 |
26 Feb 07 |
jari |
218 |
loadButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
219 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
220 |
int returnVal = fc.showOpenDialog(GroupExptsPanel.this); |
2 |
26 Feb 07 |
jari |
221 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
222 |
try { |
2 |
26 Feb 07 |
jari |
223 |
FileReader file = new FileReader(fc.getSelectedFile()); |
2 |
26 Feb 07 |
jari |
224 |
BufferedReader buff = new BufferedReader(file); |
2 |
26 Feb 07 |
jari |
225 |
String line = buff.readLine(); |
2 |
26 Feb 07 |
jari |
//System.out.println(line); |
2 |
26 Feb 07 |
jari |
227 |
StringSplitter st = new StringSplitter('\t'); |
2 |
26 Feb 07 |
jari |
228 |
st.init(line); |
2 |
26 Feb 07 |
jari |
229 |
Vector factorAGroupsVector = new Vector(); |
2 |
26 Feb 07 |
jari |
230 |
Vector factorBGroupsVector = new Vector(); |
2 |
26 Feb 07 |
jari |
231 |
while (st.hasMoreTokens()) { |
2 |
26 Feb 07 |
jari |
232 |
String current = st.nextToken(); |
2 |
26 Feb 07 |
jari |
233 |
factorAGroupsVector.add(new Integer(current)); |
2 |
26 Feb 07 |
jari |
//System.out.print(current); |
2 |
26 Feb 07 |
jari |
235 |
} |
2 |
26 Feb 07 |
jari |
236 |
|
2 |
26 Feb 07 |
jari |
237 |
line = buff.readLine(); |
2 |
26 Feb 07 |
jari |
238 |
st.init(line); |
2 |
26 Feb 07 |
jari |
239 |
while (st.hasMoreTokens()) { |
2 |
26 Feb 07 |
jari |
240 |
String current = st.nextToken(); |
2 |
26 Feb 07 |
jari |
241 |
factorBGroupsVector.add(new Integer(current)); |
2 |
26 Feb 07 |
jari |
//System.out.print(current); |
2 |
26 Feb 07 |
jari |
243 |
} |
2 |
26 Feb 07 |
jari |
244 |
|
2 |
26 Feb 07 |
jari |
245 |
buff.close(); |
2 |
26 Feb 07 |
jari |
246 |
int[] factorAGroupAssgn = factorAPanel.getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
247 |
int[] factorBGroupAssgn = factorBPanel.getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
248 |
if ((factorAGroupsVector.size() != factorAGroupAssgn.length) || (factorBGroupsVector.size() != factorBGroupAssgn.length)){ |
2 |
26 Feb 07 |
jari |
249 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
250 |
} else { |
2 |
26 Feb 07 |
jari |
251 |
int[] factorAAssignments = new int[factorAGroupsVector.size()]; |
2 |
26 Feb 07 |
jari |
252 |
int[] factorBAssignments = new int[factorBGroupsVector.size()]; |
2 |
26 Feb 07 |
jari |
253 |
for (int i = 0; i < factorAAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
254 |
factorAAssignments[i] = ((Integer)(factorAGroupsVector.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
255 |
factorBAssignments[i] = ((Integer)(factorBGroupsVector.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
256 |
} |
2 |
26 Feb 07 |
jari |
257 |
|
2 |
26 Feb 07 |
jari |
258 |
factorAPanel.setGroupAssignments(factorAAssignments); |
2 |
26 Feb 07 |
jari |
259 |
factorBPanel.setGroupAssignments(factorBAssignments); |
2 |
26 Feb 07 |
jari |
260 |
} |
2 |
26 Feb 07 |
jari |
261 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
262 |
JOptionPane.showMessageDialog(gPanel, "Incompatible file!", "Error", JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
263 |
factorAPanel.reset(); |
2 |
26 Feb 07 |
jari |
264 |
factorBPanel.reset(); |
2 |
26 Feb 07 |
jari |
//e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
266 |
} |
2 |
26 Feb 07 |
jari |
267 |
|
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 |
270 |
} else { |
2 |
26 Feb 07 |
jari |
//log.append("Save command cancelled by user." + newline); |
2 |
26 Feb 07 |
jari |
272 |
} |
2 |
26 Feb 07 |
jari |
273 |
} |
2 |
26 Feb 07 |
jari |
274 |
}); |
2 |
26 Feb 07 |
jari |
275 |
// |
2 |
26 Feb 07 |
jari |
276 |
|
2 |
26 Feb 07 |
jari |
277 |
|
2 |
26 Feb 07 |
jari |
278 |
|
2 |
26 Feb 07 |
jari |
279 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
280 |
constraints.fill = GridBagConstraints.NONE; |
2 |
26 Feb 07 |
jari |
281 |
constraints.insets = new Insets(5,5,5,5); |
2 |
26 Feb 07 |
jari |
282 |
buildConstraints(constraints, 0, 0, 1, 1, 33, 100); |
2 |
26 Feb 07 |
jari |
283 |
gridbag3.setConstraints(saveButton, constraints); |
2 |
26 Feb 07 |
jari |
284 |
panel2.add(saveButton); |
2 |
26 Feb 07 |
jari |
285 |
|
2 |
26 Feb 07 |
jari |
286 |
buildConstraints(constraints, 1, 0, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
287 |
gridbag3.setConstraints(loadButton, constraints); |
2 |
26 Feb 07 |
jari |
288 |
panel2.add(loadButton); |
2 |
26 Feb 07 |
jari |
289 |
|
2 |
26 Feb 07 |
jari |
290 |
buildConstraints(constraints, 2, 0, 1, 1, 34, 0); |
2 |
26 Feb 07 |
jari |
291 |
gridbag3.setConstraints(resetButton, constraints); |
2 |
26 Feb 07 |
jari |
292 |
panel2.add(resetButton); |
2 |
26 Feb 07 |
jari |
293 |
constraints.insets = new Insets(0,0,0,0); |
2 |
26 Feb 07 |
jari |
294 |
|
2 |
26 Feb 07 |
jari |
295 |
buildConstraints(constraints, 0, 1, 2, 1, 100, 5); |
2 |
26 Feb 07 |
jari |
296 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
298 |
grid1.setConstraints(panel2, constraints); |
2 |
26 Feb 07 |
jari |
299 |
this.add(panel2); |
2 |
26 Feb 07 |
jari |
300 |
|
2 |
26 Feb 07 |
jari |
301 |
} |
2 |
26 Feb 07 |
jari |
302 |
|
2 |
26 Feb 07 |
jari |
303 |
public void reset() { |
2 |
26 Feb 07 |
jari |
304 |
factorAPanel.reset(); |
2 |
26 Feb 07 |
jari |
305 |
factorBPanel.reset(); |
2 |
26 Feb 07 |
jari |
306 |
} |
2 |
26 Feb 07 |
jari |
307 |
} |
2 |
26 Feb 07 |
jari |
308 |
|
2 |
26 Feb 07 |
jari |
309 |
class MultiGroupExperimentsPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
310 |
JLabel[] expLabels; |
2 |
26 Feb 07 |
jari |
311 |
JRadioButton[][] exptGroupRadioButtons; |
2 |
26 Feb 07 |
jari |
312 |
JRadioButton[] notInGroupRadioButtons; |
2 |
26 Feb 07 |
jari |
313 |
int numGroups; |
2 |
26 Feb 07 |
jari |
314 |
|
2 |
26 Feb 07 |
jari |
315 |
MultiGroupExperimentsPanel(String factorName, int numGroups) { |
2 |
26 Feb 07 |
jari |
316 |
this.setBorder(new TitledBorder(new EtchedBorder(), factorName + " assignments", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
317 |
this.numGroups = numGroups; |
2 |
26 Feb 07 |
jari |
318 |
setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
319 |
JPanel panel1 = new JPanel(); |
2 |
26 Feb 07 |
jari |
320 |
expLabels = new JLabel[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
321 |
exptGroupRadioButtons = new JRadioButton[numGroups][exptNames.size()]; |
2 |
26 Feb 07 |
jari |
//groupARadioButtons = new JRadioButton[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
//groupBRadioButtons = new JRadioButton[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
324 |
notInGroupRadioButtons = new JRadioButton[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
325 |
ButtonGroup chooseGroup[] = new ButtonGroup[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
326 |
|
2 |
26 Feb 07 |
jari |
327 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
328 |
GridBagLayout gridbag2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
329 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
330 |
this.setLayout(gridbag2); |
2 |
26 Feb 07 |
jari |
331 |
panel1.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
332 |
|
2 |
26 Feb 07 |
jari |
333 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
334 |
String s1 = (String)(exptNames.get(i)); |
2 |
26 Feb 07 |
jari |
335 |
expLabels[i] = new JLabel(s1); |
2 |
26 Feb 07 |
jari |
336 |
chooseGroup[i] = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
337 |
for (int j = 0; j < numGroups; j++) { |
2 |
26 Feb 07 |
jari |
338 |
exptGroupRadioButtons[j][i] = new JRadioButton("Group " + (j + 1) + " ", j == 0? true: false); |
2 |
26 Feb 07 |
jari |
339 |
chooseGroup[i].add(exptGroupRadioButtons[j][i]); |
2 |
26 Feb 07 |
jari |
340 |
} |
2 |
26 Feb 07 |
jari |
341 |
|
2 |
26 Feb 07 |
jari |
342 |
notInGroupRadioButtons[i] = new JRadioButton("Not in groups", false); |
2 |
26 Feb 07 |
jari |
343 |
chooseGroup[i].add(notInGroupRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
344 |
|
2 |
26 Feb 07 |
jari |
345 |
for (int j = 0; j < numGroups; j++) { |
2 |
26 Feb 07 |
jari |
346 |
buildConstraints(constraints, j, i, 1, 1, 100, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
348 |
gridbag.setConstraints(exptGroupRadioButtons[j][i], constraints); |
2 |
26 Feb 07 |
jari |
349 |
panel1.add(exptGroupRadioButtons[j][i]); |
2 |
26 Feb 07 |
jari |
350 |
} |
2 |
26 Feb 07 |
jari |
351 |
|
2 |
26 Feb 07 |
jari |
352 |
buildConstraints(constraints, (numGroups + 1), i, 1, 1, 100, 100); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
354 |
gridbag.setConstraints(notInGroupRadioButtons[i], constraints); |
2 |
26 Feb 07 |
jari |
355 |
panel1.add(notInGroupRadioButtons[i]); |
2 |
26 Feb 07 |
jari |
356 |
} |
2 |
26 Feb 07 |
jari |
357 |
|
2 |
26 Feb 07 |
jari |
358 |
int maxLabelWidth = 0; |
2 |
26 Feb 07 |
jari |
359 |
|
2 |
26 Feb 07 |
jari |
360 |
for (int i = 0; i < expLabels.length; i++) { |
2 |
26 Feb 07 |
jari |
361 |
if (expLabels[i].getPreferredSize().getWidth() > maxLabelWidth) { |
2 |
26 Feb 07 |
jari |
362 |
maxLabelWidth = (int)Math.ceil(expLabels[i].getPreferredSize().getWidth()); |
2 |
26 Feb 07 |
jari |
363 |
} |
2 |
26 Feb 07 |
jari |
364 |
} |
2 |
26 Feb 07 |
jari |
365 |
|
2 |
26 Feb 07 |
jari |
366 |
JScrollPane scroll = new JScrollPane(panel1); |
2 |
26 Feb 07 |
jari |
367 |
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
368 |
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); |
2 |
26 Feb 07 |
jari |
369 |
|
2 |
26 Feb 07 |
jari |
370 |
JPanel exptNameHeaderPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
371 |
GridBagLayout exptHeaderGridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
//exptNameHeaderPanel.HEIGHT = panel1.getHeight(); |
2 |
26 Feb 07 |
jari |
//System.out.println("panel1.preferredSise().height = " + panel1.getPreferredSize().height); |
2 |
26 Feb 07 |
jari |
374 |
exptNameHeaderPanel.setSize(50, panel1.getPreferredSize().height); |
2 |
26 Feb 07 |
jari |
375 |
exptNameHeaderPanel.setPreferredSize(new Dimension(maxLabelWidth + 10, panel1.getPreferredSize().height)); |
2 |
26 Feb 07 |
jari |
376 |
exptNameHeaderPanel.setLayout(exptHeaderGridbag); |
2 |
26 Feb 07 |
jari |
//scroll.getRowHeader().setLayout(exptHeaderGridbag); |
2 |
26 Feb 07 |
jari |
378 |
|
2 |
26 Feb 07 |
jari |
379 |
|
2 |
26 Feb 07 |
jari |
380 |
for (int i = 0; i < expLabels.length; i++) { |
2 |
26 Feb 07 |
jari |
381 |
buildConstraints(constraints, 0, i, 1, 1, 100, 100); |
2 |
26 Feb 07 |
jari |
382 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
383 |
exptHeaderGridbag.setConstraints(expLabels[i], constraints); |
2 |
26 Feb 07 |
jari |
384 |
exptNameHeaderPanel.add(expLabels[i]); |
2 |
26 Feb 07 |
jari |
385 |
} |
2 |
26 Feb 07 |
jari |
386 |
|
2 |
26 Feb 07 |
jari |
387 |
scroll.setRowHeaderView(exptNameHeaderPanel); |
2 |
26 Feb 07 |
jari |
388 |
|
2 |
26 Feb 07 |
jari |
389 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 100); |
2 |
26 Feb 07 |
jari |
390 |
constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
391 |
gridbag2.setConstraints(scroll, constraints); |
2 |
26 Feb 07 |
jari |
392 |
this.add(scroll); |
2 |
26 Feb 07 |
jari |
393 |
|
2 |
26 Feb 07 |
jari |
394 |
} |
2 |
26 Feb 07 |
jari |
395 |
|
2 |
26 Feb 07 |
jari |
396 |
public void reset() { |
2 |
26 Feb 07 |
jari |
397 |
for (int i = 0; i < exptNames.size(); i++) { |
2 |
26 Feb 07 |
jari |
398 |
exptGroupRadioButtons[0][i].setSelected(true); |
2 |
26 Feb 07 |
jari |
399 |
} |
2 |
26 Feb 07 |
jari |
400 |
} |
2 |
26 Feb 07 |
jari |
401 |
|
2 |
26 Feb 07 |
jari |
402 |
|
2 |
26 Feb 07 |
jari |
403 |
public int[] getGroupAssignments() { |
2 |
26 Feb 07 |
jari |
404 |
int[] groupAssignments = new int[exptNames.size()]; |
2 |
26 Feb 07 |
jari |
405 |
|
2 |
26 Feb 07 |
jari |
406 |
for (int i = 0; i < groupAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
407 |
groupAssignments[i] = 0; |
2 |
26 Feb 07 |
jari |
408 |
} |
2 |
26 Feb 07 |
jari |
409 |
|
2 |
26 Feb 07 |
jari |
410 |
for (int i = 0; i < groupAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
411 |
for (int j = 0; j < numGroups; j++) { |
2 |
26 Feb 07 |
jari |
412 |
if (exptGroupRadioButtons[j][i].isSelected()) { |
2 |
26 Feb 07 |
jari |
413 |
groupAssignments[i] = j + 1; |
2 |
26 Feb 07 |
jari |
414 |
break; |
2 |
26 Feb 07 |
jari |
415 |
} |
2 |
26 Feb 07 |
jari |
416 |
} |
2 |
26 Feb 07 |
jari |
417 |
} |
2 |
26 Feb 07 |
jari |
418 |
|
2 |
26 Feb 07 |
jari |
419 |
return groupAssignments; |
2 |
26 Feb 07 |
jari |
420 |
} |
2 |
26 Feb 07 |
jari |
421 |
|
2 |
26 Feb 07 |
jari |
422 |
public void setGroupAssignments(int[] assignments) { |
2 |
26 Feb 07 |
jari |
423 |
for (int i = 0; i < assignments.length; i++) { |
2 |
26 Feb 07 |
jari |
424 |
if (assignments[i] == 0) { |
2 |
26 Feb 07 |
jari |
425 |
notInGroupRadioButtons[i].setSelected(true); |
2 |
26 Feb 07 |
jari |
426 |
} else { |
2 |
26 Feb 07 |
jari |
427 |
exptGroupRadioButtons[assignments[i] - 1][i].setSelected(true); |
2 |
26 Feb 07 |
jari |
428 |
} |
2 |
26 Feb 07 |
jari |
429 |
} |
2 |
26 Feb 07 |
jari |
430 |
} |
2 |
26 Feb 07 |
jari |
431 |
|
2 |
26 Feb 07 |
jari |
432 |
} |
2 |
26 Feb 07 |
jari |
433 |
|
2 |
26 Feb 07 |
jari |
434 |
class PValuePanel extends JPanel { |
2 |
26 Feb 07 |
jari |
435 |
JRadioButton tDistButton, permutButton; // randomGroupsButton, allCombsButton; |
2 |
26 Feb 07 |
jari |
436 |
JLabel numPermsLabel; |
2 |
26 Feb 07 |
jari |
437 |
JTextField timesField, alphaInputField; |
2 |
26 Feb 07 |
jari |
//JButton permParamButton; |
2 |
26 Feb 07 |
jari |
439 |
|
2 |
26 Feb 07 |
jari |
440 |
PValuePanel() { |
2 |
26 Feb 07 |
jari |
// this.setBorder(new TitledBorder(new EtchedBorder(), "P-Value parameters")); |
2 |
26 Feb 07 |
jari |
442 |
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 |
443 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
444 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
445 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
//constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
448 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
449 |
|
2 |
26 Feb 07 |
jari |
//permParamButton = new JButton("Permutation parameters"); |
2 |
26 Feb 07 |
jari |
//permParamButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
452 |
|
2 |
26 Feb 07 |
jari |
453 |
ButtonGroup chooseP = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
454 |
|
2 |
26 Feb 07 |
jari |
455 |
tDistButton = new JRadioButton("p-values based on F-distribution", true); |
2 |
26 Feb 07 |
jari |
456 |
tDistButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
457 |
tDistButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
458 |
tDistButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
459 |
|
2 |
26 Feb 07 |
jari |
460 |
numPermsLabel = new JLabel("Enter number of permutations"); |
2 |
26 Feb 07 |
jari |
461 |
numPermsLabel.setEnabled(false); |
2 |
26 Feb 07 |
jari |
462 |
|
2 |
26 Feb 07 |
jari |
463 |
timesField = new JTextField("1000", 7); |
2 |
26 Feb 07 |
jari |
464 |
timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
465 |
timesField.setBackground(Color.darkGray); |
2 |
26 Feb 07 |
jari |
466 |
|
2 |
26 Feb 07 |
jari |
467 |
tDistButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
468 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
469 |
numPermsLabel.setEnabled(false); |
2 |
26 Feb 07 |
jari |
470 |
timesField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
471 |
timesField.setBackground(Color.darkGray); |
2 |
26 Feb 07 |
jari |
472 |
pAdjPanel.maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
473 |
pAdjPanel.minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
474 |
} |
2 |
26 Feb 07 |
jari |
475 |
}); |
2 |
26 Feb 07 |
jari |
476 |
|
2 |
26 Feb 07 |
jari |
477 |
chooseP.add(tDistButton); |
2 |
26 Feb 07 |
jari |
478 |
|
2 |
26 Feb 07 |
jari |
479 |
permutButton = new JRadioButton("p-values based on permutation: ", false); |
2 |
26 Feb 07 |
jari |
480 |
permutButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
481 |
permutButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
482 |
permutButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
483 |
|
2 |
26 Feb 07 |
jari |
484 |
permutButton.addActionListener(new ActionListener() { |
2 |
26 Feb 07 |
jari |
485 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
486 |
numPermsLabel.setEnabled(true); |
2 |
26 Feb 07 |
jari |
487 |
timesField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
488 |
timesField.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
//pAdjPanel.maxTButton.setEnabled(true); //UNCOMMENT THIS WHEN MAXT METHOD HAS BEEN IMPLEMEMTED |
2 |
26 Feb 07 |
jari |
//pAdjPanel.minPButton.setEnabled(true); //UNCOMMENT THIS WHEN MINP METHOD HAS BEEN DEBUGGED |
2 |
26 Feb 07 |
jari |
491 |
} |
2 |
26 Feb 07 |
jari |
492 |
}); |
2 |
26 Feb 07 |
jari |
493 |
|
2 |
26 Feb 07 |
jari |
494 |
chooseP.add(permutButton); |
2 |
26 Feb 07 |
jari |
495 |
|
2 |
26 Feb 07 |
jari |
496 |
|
2 |
26 Feb 07 |
jari |
//constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
498 |
|
2 |
26 Feb 07 |
jari |
//numCombsLabel = new JLabel(" "); |
2 |
26 Feb 07 |
jari |
//numCombsLabel.setOpaque(false); |
2 |
26 Feb 07 |
jari |
501 |
/* |
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 |
506 |
*/ |
2 |
26 Feb 07 |
jari |
507 |
|
2 |
26 Feb 07 |
jari |
508 |
|
2 |
26 Feb 07 |
jari |
509 |
buildConstraints(constraints, 0, 0, 3, 1, 100, 30); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
511 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
512 |
gridbag.setConstraints(tDistButton, constraints); |
2 |
26 Feb 07 |
jari |
513 |
this.add(tDistButton); |
2 |
26 Feb 07 |
jari |
514 |
|
2 |
26 Feb 07 |
jari |
515 |
buildConstraints(constraints, 0, 1, 1, 1, 30, 30); |
2 |
26 Feb 07 |
jari |
516 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
517 |
gridbag.setConstraints(permutButton, constraints); |
2 |
26 Feb 07 |
jari |
518 |
this.add(permutButton); |
2 |
26 Feb 07 |
jari |
519 |
|
2 |
26 Feb 07 |
jari |
//JLabel numPermsLabel = new JLabel("Enter number of permutations"); |
2 |
26 Feb 07 |
jari |
//numPermsLabel.setEnabled(false); |
2 |
26 Feb 07 |
jari |
522 |
buildConstraints(constraints, 1, 1, 1, 1, 30, 0); |
2 |
26 Feb 07 |
jari |
523 |
gridbag.setConstraints(numPermsLabel, constraints); |
2 |
26 Feb 07 |
jari |
524 |
this.add(numPermsLabel); |
2 |
26 Feb 07 |
jari |
525 |
|
2 |
26 Feb 07 |
jari |
526 |
buildConstraints(constraints, 2, 1, 1, 1, 40, 0); |
2 |
26 Feb 07 |
jari |
527 |
gridbag.setConstraints(timesField, constraints); |
2 |
26 Feb 07 |
jari |
528 |
this.add(timesField); |
2 |
26 Feb 07 |
jari |
529 |
|
2 |
26 Feb 07 |
jari |
530 |
JLabel alphaLabel = new JLabel("Enter critical p-value"); |
2 |
26 Feb 07 |
jari |
531 |
buildConstraints(constraints, 0, 2, 2, 1, 60, 40); |
2 |
26 Feb 07 |
jari |
//constraints.anchor = GridBagConstraints.EAST; |
2 |
26 Feb 07 |
jari |
533 |
gridbag.setConstraints(alphaLabel, constraints); |
2 |
26 Feb 07 |
jari |
534 |
this.add(alphaLabel); |
2 |
26 Feb 07 |
jari |
535 |
|
2 |
26 Feb 07 |
jari |
536 |
alphaInputField = new JTextField("0.01", 7); |
2 |
26 Feb 07 |
jari |
537 |
buildConstraints(constraints, 1, 2, 1, 1, 40, 0); |
2 |
26 Feb 07 |
jari |
538 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
539 |
gridbag.setConstraints(alphaInputField, constraints); |
2 |
26 Feb 07 |
jari |
540 |
this.add(alphaInputField); |
2 |
26 Feb 07 |
jari |
541 |
} |
2 |
26 Feb 07 |
jari |
542 |
} |
2 |
26 Feb 07 |
jari |
543 |
|
2 |
26 Feb 07 |
jari |
544 |
class PValueAdjustmentPanel extends JPanel { |
2 |
26 Feb 07 |
jari |
545 |
JRadioButton minPButton, maxTButton, justAlphaButton, stdBonfButton, adjBonfButton; |
2 |
26 Feb 07 |
jari |
546 |
PValueAdjustmentPanel() { |
2 |
26 Feb 07 |
jari |
// this.setBorder(new TitledBorder(new EtchedBorder(), "Significance based on: ")); |
2 |
26 Feb 07 |
jari |
548 |
this.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Alpha Corrections", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black)); |
2 |
26 Feb 07 |
jari |
549 |
this.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
550 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
551 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
552 |
this.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
553 |
|
2 |
26 Feb 07 |
jari |
554 |
/* |
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 |
560 |
*/ |
2 |
26 Feb 07 |
jari |
561 |
|
2 |
26 Feb 07 |
jari |
562 |
ButtonGroup sigGroup = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
563 |
|
2 |
26 Feb 07 |
jari |
564 |
justAlphaButton = new JRadioButton("just alpha (no correction)", true); |
2 |
26 Feb 07 |
jari |
565 |
justAlphaButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
566 |
justAlphaButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
567 |
justAlphaButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
568 |
sigGroup.add(justAlphaButton); |
2 |
26 Feb 07 |
jari |
569 |
|
2 |
26 Feb 07 |
jari |
570 |
stdBonfButton = new JRadioButton("standard Bonferroni correction", false); |
2 |
26 Feb 07 |
jari |
571 |
stdBonfButton.setEnabled(false);//enable this button when this option is implemented |
2 |
26 Feb 07 |
jari |
572 |
stdBonfButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
573 |
stdBonfButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
574 |
stdBonfButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
575 |
sigGroup.add(stdBonfButton); |
2 |
26 Feb 07 |
jari |
576 |
|
2 |
26 Feb 07 |
jari |
577 |
adjBonfButton = new JRadioButton("adjusted Bonferroni correction", false); |
2 |
26 Feb 07 |
jari |
578 |
adjBonfButton.setEnabled(false);//enable this button when this option is implemented |
2 |
26 Feb 07 |
jari |
579 |
adjBonfButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
580 |
adjBonfButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
581 |
adjBonfButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
582 |
sigGroup.add(adjBonfButton); |
2 |
26 Feb 07 |
jari |
583 |
|
2 |
26 Feb 07 |
jari |
584 |
minPButton = new JRadioButton("minP", false); |
2 |
26 Feb 07 |
jari |
585 |
minPButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
586 |
minPButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
587 |
minPButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
588 |
minPButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
589 |
sigGroup.add(minPButton); |
2 |
26 Feb 07 |
jari |
590 |
|
2 |
26 Feb 07 |
jari |
591 |
maxTButton = new JRadioButton("maxT", false); |
2 |
26 Feb 07 |
jari |
592 |
maxTButton.setEnabled(false); |
2 |
26 Feb 07 |
jari |
593 |
maxTButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
594 |
maxTButton.setForeground(UIManager.getColor("Label.foreground")); |
2 |
26 Feb 07 |
jari |
595 |
maxTButton.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
596 |
sigGroup.add(maxTButton); |
2 |
26 Feb 07 |
jari |
597 |
|
2 |
26 Feb 07 |
jari |
598 |
buildConstraints(constraints, 0, 0, 1, 1, 33, 50); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
600 |
gridbag.setConstraints(justAlphaButton, constraints); |
2 |
26 Feb 07 |
jari |
601 |
this.add(justAlphaButton); |
2 |
26 Feb 07 |
jari |
602 |
|
2 |
26 Feb 07 |
jari |
603 |
buildConstraints(constraints, 1, 0, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
605 |
gridbag.setConstraints(stdBonfButton, constraints); |
2 |
26 Feb 07 |
jari |
606 |
this.add(stdBonfButton); |
2 |
26 Feb 07 |
jari |
607 |
|
2 |
26 Feb 07 |
jari |
608 |
buildConstraints(constraints, 2, 0, 1, 1, 34, 0); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
610 |
gridbag.setConstraints(adjBonfButton, constraints); |
2 |
26 Feb 07 |
jari |
611 |
this.add(adjBonfButton); |
2 |
26 Feb 07 |
jari |
612 |
|
2 |
26 Feb 07 |
jari |
613 |
JPanel westfallYoungPanel = new JPanel(); |
2 |
26 Feb 07 |
jari |
614 |
westfallYoungPanel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
615 |
westfallYoungPanel.setBorder(new EtchedBorder()); |
2 |
26 Feb 07 |
jari |
616 |
GridBagLayout grid2 = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
617 |
westfallYoungPanel.setLayout(grid2); |
2 |
26 Feb 07 |
jari |
618 |
|
2 |
26 Feb 07 |
jari |
619 |
JLabel stepDownLabel = new JLabel("Step-down Westfall and Young methods (for permutations only): "); |
2 |
26 Feb 07 |
jari |
620 |
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 |
625 |
grid2.setConstraints(stepDownLabel, constraints); |
2 |
26 Feb 07 |
jari |
//this.add(stepDownLabel); |
2 |
26 Feb 07 |
jari |
627 |
westfallYoungPanel.add(stepDownLabel); |
2 |
26 Feb 07 |
jari |
628 |
|
2 |
26 Feb 07 |
jari |
//buildConstraints(constraints, 1, 1, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
630 |
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 |
634 |
grid2.setConstraints(minPButton, constraints); |
2 |
26 Feb 07 |
jari |
//this.add(minPButton); |
2 |
26 Feb 07 |
jari |
636 |
westfallYoungPanel.add(minPButton); |
2 |
26 Feb 07 |
jari |
637 |
|
2 |
26 Feb 07 |
jari |
638 |
|
2 |
26 Feb 07 |
jari |
//buildConstraints(constraints, 2, 1, 1, 1, 33, 0); |
2 |
26 Feb 07 |
jari |
640 |
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 |
644 |
grid2.setConstraints(maxTButton, constraints); |
2 |
26 Feb 07 |
jari |
//this.add(maxTButton); |
2 |
26 Feb 07 |
jari |
646 |
westfallYoungPanel.add(maxTButton); |
2 |
26 Feb 07 |
jari |
647 |
|
2 |
26 Feb 07 |
jari |
648 |
buildConstraints(constraints, 0, 1, 3, 1, 100, 50); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
650 |
gridbag.setConstraints(westfallYoungPanel, constraints); |
2 |
26 Feb 07 |
jari |
651 |
this.add(westfallYoungPanel); |
2 |
26 Feb 07 |
jari |
652 |
/* |
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 |
658 |
*/ |
2 |
26 Feb 07 |
jari |
659 |
|
2 |
26 Feb 07 |
jari |
660 |
} |
2 |
26 Feb 07 |
jari |
661 |
} |
2 |
26 Feb 07 |
jari |
662 |
|
2 |
26 Feb 07 |
jari |
663 |
public boolean allCellsHaveOneSample() { |
2 |
26 Feb 07 |
jari |
664 |
return this.oneSamplePerCell; |
2 |
26 Feb 07 |
jari |
665 |
} |
2 |
26 Feb 07 |
jari |
666 |
|
2 |
26 Feb 07 |
jari |
667 |
public boolean usePerms() { |
2 |
26 Feb 07 |
jari |
668 |
return pPanel.permutButton.isSelected(); |
2 |
26 Feb 07 |
jari |
669 |
} |
2 |
26 Feb 07 |
jari |
670 |
|
2 |
26 Feb 07 |
jari |
671 |
public float getAlpha() { |
2 |
26 Feb 07 |
jari |
672 |
return Float.parseFloat(pPanel.alphaInputField.getText()); |
2 |
26 Feb 07 |
jari |
673 |
} |
2 |
26 Feb 07 |
jari |
674 |
|
2 |
26 Feb 07 |
jari |
675 |
public int getNumPerms() { |
2 |
26 Feb 07 |
jari |
676 |
return Integer.parseInt(pPanel.timesField.getText()); |
2 |
26 Feb 07 |
jari |
677 |
} |
2 |
26 Feb 07 |
jari |
678 |
|
2 |
26 Feb 07 |
jari |
679 |
public boolean isBalancedDesign() { |
2 |
26 Feb 07 |
jari |
680 |
boolean balanced = true; |
2 |
26 Feb 07 |
jari |
681 |
Vector[][] bothFactorAssignments = getBothFactorAssignments(); |
2 |
26 Feb 07 |
jari |
682 |
int[] cellSizes =new int[bothFactorAssignments.length*bothFactorAssignments[0].length]; |
2 |
26 Feb 07 |
jari |
//System.out.println("cellSizes.length = " + cellSizes.length); |
2 |
26 Feb 07 |
jari |
684 |
int cellCounter = 0; |
2 |
26 Feb 07 |
jari |
685 |
for (int i = 0; i < bothFactorAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
686 |
for (int j = 0; j < bothFactorAssignments[i].length; j++) { |
2 |
26 Feb 07 |
jari |
687 |
cellSizes[cellCounter] = bothFactorAssignments[i][j].size(); |
2 |
26 Feb 07 |
jari |
688 |
cellCounter++; |
2 |
26 Feb 07 |
jari |
689 |
} |
2 |
26 Feb 07 |
jari |
690 |
} |
2 |
26 Feb 07 |
jari |
691 |
|
2 |
26 Feb 07 |
jari |
692 |
int numPerCell = cellSizes[0]; |
2 |
26 Feb 07 |
jari |
693 |
|
2 |
26 Feb 07 |
jari |
694 |
for (int i = 1; i < cellSizes.length; i++) { |
2 |
26 Feb 07 |
jari |
695 |
if (cellSizes[i] != numPerCell) { |
2 |
26 Feb 07 |
jari |
696 |
balanced = false; |
2 |
26 Feb 07 |
jari |
697 |
break; |
2 |
26 Feb 07 |
jari |
698 |
} |
2 |
26 Feb 07 |
jari |
699 |
} |
2 |
26 Feb 07 |
jari |
700 |
|
2 |
26 Feb 07 |
jari |
701 |
return balanced; |
2 |
26 Feb 07 |
jari |
702 |
} |
2 |
26 Feb 07 |
jari |
703 |
|
2 |
26 Feb 07 |
jari |
704 |
public int getAdjustmentMethod() { |
2 |
26 Feb 07 |
jari |
705 |
if (pAdjPanel.justAlphaButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
706 |
return TFAInitBox2.JUST_ALPHA; |
2 |
26 Feb 07 |
jari |
707 |
} else if (pAdjPanel.stdBonfButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
708 |
return TFAInitBox2.STD_BONFERRONI; |
2 |
26 Feb 07 |
jari |
709 |
} else if (pAdjPanel.adjBonfButton.isSelected()){ |
2 |
26 Feb 07 |
jari |
710 |
return TFAInitBox2.ADJ_BONFERRONI; |
2 |
26 Feb 07 |
jari |
711 |
} else if (pAdjPanel.maxTButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
712 |
return TFAInitBox2.MAX_T; |
2 |
26 Feb 07 |
jari |
713 |
} else if (pAdjPanel.minPButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
714 |
return TFAInitBox2.MIN_P; |
2 |
26 Feb 07 |
jari |
715 |
} else { |
2 |
26 Feb 07 |
jari |
716 |
return -1; |
2 |
26 Feb 07 |
jari |
717 |
} |
2 |
26 Feb 07 |
jari |
718 |
} |
2 |
26 Feb 07 |
jari |
719 |
|
2 |
26 Feb 07 |
jari |
720 |
public boolean drawTrees() { |
2 |
26 Feb 07 |
jari |
721 |
return this.hclOpsPanel.isHCLSelected(); |
2 |
26 Feb 07 |
jari |
722 |
} |
2 |
26 Feb 07 |
jari |
723 |
|
2 |
26 Feb 07 |
jari |
724 |
public boolean drawSigTreesOnly() { |
2 |
26 Feb 07 |
jari |
725 |
return hclOpsPanel.drawSigTreesOnly(); |
2 |
26 Feb 07 |
jari |
726 |
} |
2 |
26 Feb 07 |
jari |
727 |
|
2 |
26 Feb 07 |
jari |
728 |
public boolean isOkPressed() { |
2 |
26 Feb 07 |
jari |
729 |
return okPressed; |
2 |
26 Feb 07 |
jari |
730 |
} |
2 |
26 Feb 07 |
jari |
731 |
|
2 |
26 Feb 07 |
jari |
732 |
public void setVisible(boolean visible) { |
2 |
26 Feb 07 |
jari |
733 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
734 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
735 |
super.setVisible(visible); |
2 |
26 Feb 07 |
jari |
736 |
if (visible) { |
2 |
26 Feb 07 |
jari |
//bPanel.okButton.requestFocus(); //UNCOMMMENT THIS LATER |
2 |
26 Feb 07 |
jari |
738 |
} |
2 |
26 Feb 07 |
jari |
739 |
} |
2 |
26 Feb 07 |
jari |
740 |
|
2 |
26 Feb 07 |
jari |
741 |
|
2 |
26 Feb 07 |
jari |
742 |
public class EventListener extends WindowAdapter implements ActionListener{ |
2 |
26 Feb 07 |
jari |
743 |
|
2 |
26 Feb 07 |
jari |
744 |
public void actionPerformed(ActionEvent ae){ |
2 |
26 Feb 07 |
jari |
745 |
|
2 |
26 Feb 07 |
jari |
746 |
String command = ae.getActionCommand(); |
2 |
26 Feb 07 |
jari |
747 |
if(command.equals("ok-command")){ |
2 |
26 Feb 07 |
jari |
748 |
Vector[][] bothFactorAssignments = getBothFactorAssignments(); |
2 |
26 Feb 07 |
jari |
749 |
int[] cellSizes =new int[bothFactorAssignments.length*bothFactorAssignments[0].length]; |
2 |
26 Feb 07 |
jari |
//System.out.println("cellSizes.length = " + cellSizes.length); |
2 |
26 Feb 07 |
jari |
751 |
int cellCounter = 0; |
2 |
26 Feb 07 |
jari |
752 |
for (int i = 0; i < bothFactorAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
753 |
for (int j = 0; j < bothFactorAssignments[i].length; j++) { |
2 |
26 Feb 07 |
jari |
754 |
cellSizes[cellCounter] = bothFactorAssignments[i][j].size(); |
2 |
26 Feb 07 |
jari |
755 |
cellCounter++; |
2 |
26 Feb 07 |
jari |
756 |
} |
2 |
26 Feb 07 |
jari |
757 |
} |
2 |
26 Feb 07 |
jari |
758 |
if (cellSizes[0] == 1) { |
2 |
26 Feb 07 |
jari |
759 |
boolean allOne = true; |
2 |
26 Feb 07 |
jari |
760 |
for (int i = 1; i < cellSizes.length; i++) { |
2 |
26 Feb 07 |
jari |
761 |
if (cellSizes[i] != 1) { |
2 |
26 Feb 07 |
jari |
762 |
allOne = false; |
2 |
26 Feb 07 |
jari |
//oneSamplePerCell = true; |
2 |
26 Feb 07 |
jari |
764 |
break; |
2 |
26 Feb 07 |
jari |
765 |
} |
2 |
26 Feb 07 |
jari |
766 |
} |
2 |
26 Feb 07 |
jari |
767 |
if (!allOne) { |
2 |
26 Feb 07 |
jari |
768 |
JOptionPane.showMessageDialog(null, "All factor combinations must contain more than one sample, or else they must all contain exactly one sample each", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
769 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
770 |
return; |
2 |
26 Feb 07 |
jari |
771 |
} else { |
2 |
26 Feb 07 |
jari |
772 |
oneSamplePerCell = true; |
2 |
26 Feb 07 |
jari |
773 |
} |
2 |
26 Feb 07 |
jari |
774 |
} else { |
2 |
26 Feb 07 |
jari |
775 |
for (int i = 0; i < cellSizes.length; i++) { |
2 |
26 Feb 07 |
jari |
776 |
if (cellSizes[i] < 2) { |
2 |
26 Feb 07 |
jari |
777 |
JOptionPane.showMessageDialog(null, "All factor combinations must contain more than one sample, or else they must all contain exactly one sample each", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
778 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
779 |
return; |
2 |
26 Feb 07 |
jari |
780 |
} |
2 |
26 Feb 07 |
jari |
781 |
} |
2 |
26 Feb 07 |
jari |
782 |
} |
2 |
26 Feb 07 |
jari |
783 |
|
2 |
26 Feb 07 |
jari |
784 |
if (usePerms()) { |
2 |
26 Feb 07 |
jari |
785 |
try { |
2 |
26 Feb 07 |
jari |
786 |
int numPerms = getNumPerms(); |
2 |
26 Feb 07 |
jari |
787 |
if (numPerms <= 0) { |
2 |
26 Feb 07 |
jari |
788 |
JOptionPane.showMessageDialog(null, "Number of permutations should be an integer > 0", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
789 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
790 |
return; |
2 |
26 Feb 07 |
jari |
791 |
} |
2 |
26 Feb 07 |
jari |
792 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
793 |
JOptionPane.showMessageDialog(null, "Number of permutations should be an integer > 0", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
794 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
795 |
return; |
2 |
26 Feb 07 |
jari |
796 |
} |
2 |
26 Feb 07 |
jari |
797 |
} |
2 |
26 Feb 07 |
jari |
798 |
|
2 |
26 Feb 07 |
jari |
799 |
try { |
2 |
26 Feb 07 |
jari |
800 |
float alpha = getAlpha(); |
2 |
26 Feb 07 |
jari |
801 |
if ((alpha <= 0) || (alpha >= 1)) { |
2 |
26 Feb 07 |
jari |
802 |
JOptionPane.showMessageDialog(null, "Critical p-value should be between 0 and 1", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
803 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
804 |
return; |
2 |
26 Feb 07 |
jari |
805 |
} |
2 |
26 Feb 07 |
jari |
806 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
807 |
JOptionPane.showMessageDialog(null, "Critical p-value should be between 0 and 1", "Error", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
808 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
809 |
return; |
2 |
26 Feb 07 |
jari |
810 |
} |
2 |
26 Feb 07 |
jari |
811 |
|
2 |
26 Feb 07 |
jari |
812 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
813 |
hide(); |
2 |
26 Feb 07 |
jari |
814 |
dispose(); |
2 |
26 Feb 07 |
jari |
815 |
} |
2 |
26 Feb 07 |
jari |
816 |
else if(command.equals("reset-command")){ |
2 |
26 Feb 07 |
jari |
817 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
818 |
gPanel.reset(); |
2 |
26 Feb 07 |
jari |
819 |
return; |
2 |
26 Feb 07 |
jari |
820 |
} |
2 |
26 Feb 07 |
jari |
821 |
else if(command.equals("cancel-command")){ |
2 |
26 Feb 07 |
jari |
822 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
823 |
setVisible(false); |
2 |
26 Feb 07 |
jari |
824 |
dispose(); |
2 |
26 Feb 07 |
jari |
825 |
} |
2 |
26 Feb 07 |
jari |
826 |
else if(command.equals("info-command")){ |
2 |
26 Feb 07 |
jari |
827 |
} |
2 |
26 Feb 07 |
jari |
828 |
} |
2 |
26 Feb 07 |
jari |
829 |
|
2 |
26 Feb 07 |
jari |
830 |
} |
2 |
26 Feb 07 |
jari |
831 |
|
2 |
26 Feb 07 |
jari |
832 |
public int[] getFactorAAssignments() { |
2 |
26 Feb 07 |
jari |
833 |
return gPanel.factorAPanel.getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
834 |
} |
2 |
26 Feb 07 |
jari |
835 |
|
2 |
26 Feb 07 |
jari |
836 |
public int[] getFactorBAssignments() { |
2 |
26 Feb 07 |
jari |
837 |
return gPanel.factorBPanel.getGroupAssignments(); |
2 |
26 Feb 07 |
jari |
838 |
} |
2 |
26 Feb 07 |
jari |
839 |
|
2 |
26 Feb 07 |
jari |
840 |
public Vector[][] getBothFactorAssignments() { |
2 |
26 Feb 07 |
jari |
841 |
Vector[][] bothFactorAssignments = new Vector[numFactorLevels[0]][numFactorLevels[1]]; |
2 |
26 Feb 07 |
jari |
842 |
|
2 |
26 Feb 07 |
jari |
843 |
for (int i = 0; i < bothFactorAssignments.length; i++) { |
2 |
26 Feb 07 |
jari |
844 |
for (int j = 0; j < bothFactorAssignments[i].length; j++) { |
2 |
26 Feb 07 |
jari |
845 |
bothFactorAssignments[i][j] = new Vector(); |
2 |
26 Feb 07 |
jari |
846 |
} |
2 |
26 Feb 07 |
jari |
847 |
} |
2 |
26 Feb 07 |
jari |
848 |
|
2 |
26 Feb 07 |
jari |
849 |
int[] factorAAssgn = getFactorAAssignments(); |
2 |
26 Feb 07 |
jari |
850 |
int[] factorBAssgn = getFactorBAssignments(); |
2 |
26 Feb 07 |
jari |
851 |
|
2 |
26 Feb 07 |
jari |
852 |
for (int i = 0; i < factorAAssgn.length; i++) { |
2 |
26 Feb 07 |
jari |
853 |
if ((factorAAssgn[i] != 0)&&(factorBAssgn[i] != 0)) { |
2 |
26 Feb 07 |
jari |
854 |
bothFactorAssignments[factorAAssgn[i] - 1][factorBAssgn[i] - 1].add(new Integer(i)); |
2 |
26 Feb 07 |
jari |
855 |
} |
2 |
26 Feb 07 |
jari |
856 |
} |
2 |
26 Feb 07 |
jari |
857 |
|
2 |
26 Feb 07 |
jari |
858 |
return bothFactorAssignments; |
2 |
26 Feb 07 |
jari |
859 |
} |
2 |
26 Feb 07 |
jari |
860 |
} |