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 |
* SAMPreDialog.java |
2 |
26 Feb 07 |
jari |
7 |
* |
2 |
26 Feb 07 |
jari |
* Created on January 31, 2003, 1:45 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.sam; |
2 |
26 Feb 07 |
jari |
12 |
|
2 |
26 Feb 07 |
jari |
13 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
14 |
import java.awt.GridBagConstraints; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Toolkit; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.event.ItemEvent; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.event.ItemListener; |
2 |
26 Feb 07 |
jari |
21 |
|
2 |
26 Feb 07 |
jari |
22 |
import javax.swing.ButtonGroup; |
2 |
26 Feb 07 |
jari |
23 |
import javax.swing.JButton; |
2 |
26 Feb 07 |
jari |
24 |
import javax.swing.JCheckBox; |
2 |
26 Feb 07 |
jari |
25 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
26 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
27 |
import javax.swing.JRadioButton; |
2 |
26 Feb 07 |
jari |
28 |
|
2 |
26 Feb 07 |
jari |
29 |
import org.tigr.util.awt.ActionInfoDialog; |
2 |
26 Feb 07 |
jari |
30 |
|
2 |
26 Feb 07 |
jari |
31 |
/** |
2 |
26 Feb 07 |
jari |
32 |
* |
2 |
26 Feb 07 |
jari |
* @author nbhagaba |
2 |
26 Feb 07 |
jari |
* @version |
2 |
26 Feb 07 |
jari |
35 |
*/ |
2 |
26 Feb 07 |
jari |
36 |
public class SAMPreDialog extends ActionInfoDialog { |
2 |
26 Feb 07 |
jari |
37 |
|
2 |
26 Feb 07 |
jari |
38 |
JRadioButton previousButton, newButton; |
2 |
26 Feb 07 |
jari |
39 |
JButton okButton, cancelButton; |
2 |
26 Feb 07 |
jari |
40 |
JCheckBox drawTreesBox; |
2 |
26 Feb 07 |
jari |
41 |
private JRadioButton sigOnly, allClusters; |
2 |
26 Feb 07 |
jari |
42 |
boolean okPressed = false; |
2 |
26 Feb 07 |
jari |
43 |
|
2 |
26 Feb 07 |
jari |
/** Creates new SAMPreDialog */ |
2 |
26 Feb 07 |
jari |
45 |
public SAMPreDialog(JFrame parentFrame, boolean modality) { |
2 |
26 Feb 07 |
jari |
46 |
super(parentFrame, "SAM Initialization", modality); |
2 |
26 Feb 07 |
jari |
47 |
setBounds(0, 0, 350, 150); |
2 |
26 Feb 07 |
jari |
48 |
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
2 |
26 Feb 07 |
jari |
49 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
50 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
52 |
JPanel pane = new JPanel(); |
2 |
26 Feb 07 |
jari |
53 |
pane.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
54 |
|
2 |
26 Feb 07 |
jari |
55 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
56 |
|
2 |
26 Feb 07 |
jari |
57 |
previousButton = new JRadioButton("Use SAM Graph and input parameters from last run", true); |
2 |
26 Feb 07 |
jari |
58 |
newButton = new JRadioButton("Start new analysis", false); |
2 |
26 Feb 07 |
jari |
59 |
ButtonGroup choosePrevOrNew = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
60 |
choosePrevOrNew.add(previousButton); |
2 |
26 Feb 07 |
jari |
61 |
choosePrevOrNew.add(newButton); |
2 |
26 Feb 07 |
jari |
62 |
|
2 |
26 Feb 07 |
jari |
63 |
sigOnly = new JRadioButton("Significant genes only", true); |
2 |
26 Feb 07 |
jari |
64 |
allClusters = new JRadioButton("All clusters", false); |
2 |
26 Feb 07 |
jari |
65 |
|
2 |
26 Feb 07 |
jari |
66 |
sigOnly.setEnabled(false); |
2 |
26 Feb 07 |
jari |
67 |
allClusters.setEnabled(false); |
2 |
26 Feb 07 |
jari |
68 |
|
2 |
26 Feb 07 |
jari |
69 |
ButtonGroup allOrSig = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
70 |
allOrSig.add(sigOnly); |
2 |
26 Feb 07 |
jari |
71 |
allOrSig.add(allClusters); |
2 |
26 Feb 07 |
jari |
72 |
|
2 |
26 Feb 07 |
jari |
73 |
buildConstraints(constraints, 0, 0, 2, 1, 0, 30); |
2 |
26 Feb 07 |
jari |
74 |
gridbag.setConstraints(previousButton, constraints); |
2 |
26 Feb 07 |
jari |
75 |
pane.add(previousButton); |
2 |
26 Feb 07 |
jari |
76 |
|
2 |
26 Feb 07 |
jari |
77 |
buildConstraints(constraints, 0, 1, 2, 1, 0, 30); |
2 |
26 Feb 07 |
jari |
78 |
gridbag.setConstraints(newButton, constraints); |
2 |
26 Feb 07 |
jari |
79 |
pane.add(newButton); |
2 |
26 Feb 07 |
jari |
80 |
|
2 |
26 Feb 07 |
jari |
81 |
drawTreesBox = new JCheckBox("Draw Hierarchichal Trees for: ", false); |
2 |
26 Feb 07 |
jari |
82 |
|
2 |
26 Feb 07 |
jari |
83 |
drawTreesBox.addItemListener(new ItemListener() { |
2 |
26 Feb 07 |
jari |
84 |
public void itemStateChanged(ItemEvent e) { |
2 |
26 Feb 07 |
jari |
85 |
if (e.getStateChange() == ItemEvent.DESELECTED) { |
2 |
26 Feb 07 |
jari |
86 |
sigOnly.setEnabled(false); |
2 |
26 Feb 07 |
jari |
87 |
allClusters.setEnabled(false); |
2 |
26 Feb 07 |
jari |
88 |
} else { |
2 |
26 Feb 07 |
jari |
89 |
sigOnly.setEnabled(true); |
2 |
26 Feb 07 |
jari |
90 |
allClusters.setEnabled(true); |
2 |
26 Feb 07 |
jari |
91 |
} |
2 |
26 Feb 07 |
jari |
92 |
} |
2 |
26 Feb 07 |
jari |
93 |
}); |
2 |
26 Feb 07 |
jari |
94 |
|
2 |
26 Feb 07 |
jari |
95 |
buildConstraints(constraints, 0, 2, 2, 1, 0, 30); |
2 |
26 Feb 07 |
jari |
96 |
gridbag.setConstraints(drawTreesBox, constraints); |
2 |
26 Feb 07 |
jari |
97 |
pane.add(drawTreesBox); |
2 |
26 Feb 07 |
jari |
98 |
|
2 |
26 Feb 07 |
jari |
99 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
100 |
|
2 |
26 Feb 07 |
jari |
101 |
buildConstraints(constraints, 0, 3, 1, 1, 50, 10); |
2 |
26 Feb 07 |
jari |
102 |
gridbag.setConstraints(sigOnly, constraints); |
2 |
26 Feb 07 |
jari |
103 |
pane.add(sigOnly); |
2 |
26 Feb 07 |
jari |
104 |
|
2 |
26 Feb 07 |
jari |
105 |
buildConstraints(constraints, 1, 3, 1, 1, 50, 10); |
2 |
26 Feb 07 |
jari |
106 |
gridbag.setConstraints(allClusters, constraints); |
2 |
26 Feb 07 |
jari |
107 |
pane.add(allClusters); |
2 |
26 Feb 07 |
jari |
108 |
|
2 |
26 Feb 07 |
jari |
109 |
okButton = new JButton("OK"); |
2 |
26 Feb 07 |
jari |
110 |
buildConstraints(constraints, 0, 4, 1, 1, 50, 10); |
2 |
26 Feb 07 |
jari |
111 |
gridbag.setConstraints(okButton, constraints); |
2 |
26 Feb 07 |
jari |
112 |
okButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
113 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
114 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
115 |
dispose(); |
2 |
26 Feb 07 |
jari |
116 |
} |
2 |
26 Feb 07 |
jari |
117 |
}); |
2 |
26 Feb 07 |
jari |
118 |
pane.add(okButton); |
2 |
26 Feb 07 |
jari |
119 |
|
2 |
26 Feb 07 |
jari |
120 |
cancelButton = new JButton("Cancel"); |
2 |
26 Feb 07 |
jari |
121 |
buildConstraints(constraints, 1, 4, 1, 1, 50, 0); |
2 |
26 Feb 07 |
jari |
122 |
gridbag.setConstraints(cancelButton, constraints); |
2 |
26 Feb 07 |
jari |
123 |
cancelButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
124 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
125 |
okPressed = false; |
2 |
26 Feb 07 |
jari |
126 |
dispose(); |
2 |
26 Feb 07 |
jari |
127 |
} |
2 |
26 Feb 07 |
jari |
128 |
}); |
2 |
26 Feb 07 |
jari |
129 |
pane.add(cancelButton); |
2 |
26 Feb 07 |
jari |
130 |
|
2 |
26 Feb 07 |
jari |
131 |
setContentPane(pane); |
2 |
26 Feb 07 |
jari |
132 |
} |
2 |
26 Feb 07 |
jari |
133 |
|
2 |
26 Feb 07 |
jari |
134 |
public void setVisible(boolean visible) { |
2 |
26 Feb 07 |
jari |
135 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
136 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
137 |
|
2 |
26 Feb 07 |
jari |
138 |
super.setVisible(visible); |
2 |
26 Feb 07 |
jari |
139 |
|
2 |
26 Feb 07 |
jari |
140 |
if (visible) { |
2 |
26 Feb 07 |
jari |
//bPanel.okButton.requestFocus(); //UNCOMMMENT THIS LATER |
2 |
26 Feb 07 |
jari |
142 |
} |
2 |
26 Feb 07 |
jari |
143 |
} |
2 |
26 Feb 07 |
jari |
144 |
|
2 |
26 Feb 07 |
jari |
145 |
void buildConstraints(GridBagConstraints gbc, int gx, int gy, |
2 |
26 Feb 07 |
jari |
146 |
int gw, int gh, int wx, int wy) { |
2 |
26 Feb 07 |
jari |
147 |
|
2 |
26 Feb 07 |
jari |
148 |
gbc.gridx = gx; |
2 |
26 Feb 07 |
jari |
149 |
gbc.gridy = gy; |
2 |
26 Feb 07 |
jari |
150 |
gbc.gridwidth = gw; |
2 |
26 Feb 07 |
jari |
151 |
gbc.gridheight = gh; |
2 |
26 Feb 07 |
jari |
152 |
gbc.weightx = wx; |
2 |
26 Feb 07 |
jari |
153 |
gbc.weighty = wy; |
2 |
26 Feb 07 |
jari |
154 |
} |
2 |
26 Feb 07 |
jari |
155 |
|
2 |
26 Feb 07 |
jari |
156 |
|
2 |
26 Feb 07 |
jari |
157 |
public boolean isOkPressed() { |
2 |
26 Feb 07 |
jari |
158 |
return okPressed; |
2 |
26 Feb 07 |
jari |
159 |
} |
2 |
26 Feb 07 |
jari |
160 |
|
2 |
26 Feb 07 |
jari |
161 |
public boolean usePrevious() { |
2 |
26 Feb 07 |
jari |
162 |
return previousButton.isSelected(); |
2 |
26 Feb 07 |
jari |
163 |
} |
2 |
26 Feb 07 |
jari |
164 |
|
2 |
26 Feb 07 |
jari |
165 |
public boolean drawTrees() { |
2 |
26 Feb 07 |
jari |
166 |
return drawTreesBox.isSelected(); |
2 |
26 Feb 07 |
jari |
167 |
} |
2 |
26 Feb 07 |
jari |
168 |
|
2 |
26 Feb 07 |
jari |
169 |
public boolean drawSigTreesOnly() { |
2 |
26 Feb 07 |
jari |
170 |
return sigOnly.isSelected(); |
2 |
26 Feb 07 |
jari |
171 |
} |
2 |
26 Feb 07 |
jari |
172 |
|
2 |
26 Feb 07 |
jari |
173 |
public static void main(String[] args) { |
2 |
26 Feb 07 |
jari |
174 |
|
2 |
26 Feb 07 |
jari |
175 |
JFrame dummyFrame = new JFrame(); |
2 |
26 Feb 07 |
jari |
176 |
SAMPreDialog sDialog = new SAMPreDialog(dummyFrame, true); |
2 |
26 Feb 07 |
jari |
177 |
sDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
178 |
} |
2 |
26 Feb 07 |
jari |
179 |
|
2 |
26 Feb 07 |
jari |
180 |
} |