2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
* SAMAllPermsDialog.java |
2 |
26 Feb 07 |
jari |
3 |
* |
2 |
26 Feb 07 |
jari |
* Created on November 13, 2003, 3:50 PM |
2 |
26 Feb 07 |
jari |
5 |
*/ |
2 |
26 Feb 07 |
jari |
6 |
|
2 |
26 Feb 07 |
jari |
7 |
package org.tigr.microarray.mev.cluster.gui.impl.sam; |
2 |
26 Feb 07 |
jari |
8 |
|
2 |
26 Feb 07 |
jari |
9 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
10 |
import java.awt.GridBagConstraints; |
2 |
26 Feb 07 |
jari |
11 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
12 |
import java.awt.Toolkit; |
2 |
26 Feb 07 |
jari |
13 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
14 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
15 |
|
2 |
26 Feb 07 |
jari |
16 |
import javax.swing.ButtonGroup; |
2 |
26 Feb 07 |
jari |
17 |
import javax.swing.JButton; |
2 |
26 Feb 07 |
jari |
18 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
19 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
20 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
21 |
import javax.swing.JRadioButton; |
2 |
26 Feb 07 |
jari |
22 |
|
2 |
26 Feb 07 |
jari |
23 |
import org.tigr.util.awt.ActionInfoDialog; |
2 |
26 Feb 07 |
jari |
24 |
|
2 |
26 Feb 07 |
jari |
25 |
/** |
2 |
26 Feb 07 |
jari |
26 |
* |
2 |
26 Feb 07 |
jari |
* @author nbhagaba |
2 |
26 Feb 07 |
jari |
28 |
*/ |
2 |
26 Feb 07 |
jari |
29 |
public class SAMAllPermsDialog extends ActionInfoDialog { |
2 |
26 Feb 07 |
jari |
30 |
|
2 |
26 Feb 07 |
jari |
31 |
|
2 |
26 Feb 07 |
jari |
32 |
JRadioButton allPermsButton, somePermsButton; |
2 |
26 Feb 07 |
jari |
//JLabel numUniquePermsLabel; |
2 |
26 Feb 07 |
jari |
34 |
int numUniquePerms, numUserPerms; |
2 |
26 Feb 07 |
jari |
35 |
JButton okButton; |
2 |
26 Feb 07 |
jari |
36 |
boolean okPressed = false; |
2 |
26 Feb 07 |
jari |
37 |
|
2 |
26 Feb 07 |
jari |
/** Creates a new instance of SAMAllPermsDialog */ |
2 |
26 Feb 07 |
jari |
39 |
public SAMAllPermsDialog(JFrame parentFrame, boolean modality, int numUniquePerms, int numUserPerms) { |
2 |
26 Feb 07 |
jari |
40 |
super(parentFrame, "Use all possible unique permutations?", modality); |
2 |
26 Feb 07 |
jari |
41 |
this.numUniquePerms = numUniquePerms; |
2 |
26 Feb 07 |
jari |
42 |
this.numUserPerms = numUserPerms; |
2 |
26 Feb 07 |
jari |
43 |
setBounds(0, 0, 400, 150); |
2 |
26 Feb 07 |
jari |
44 |
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); |
2 |
26 Feb 07 |
jari |
45 |
GridBagLayout gridbag = new GridBagLayout(); |
2 |
26 Feb 07 |
jari |
46 |
GridBagConstraints constraints = new GridBagConstraints(); |
2 |
26 Feb 07 |
jari |
//constraints.fill = GridBagConstraints.BOTH; |
2 |
26 Feb 07 |
jari |
48 |
JPanel pane = new JPanel(); |
2 |
26 Feb 07 |
jari |
49 |
pane.setLayout(gridbag); |
2 |
26 Feb 07 |
jari |
50 |
|
2 |
26 Feb 07 |
jari |
51 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
52 |
|
2 |
26 Feb 07 |
jari |
53 |
JLabel numUniquePermsLabel = new JLabel("There are " + numUniquePerms + " unique permutations"); |
2 |
26 Feb 07 |
jari |
54 |
|
2 |
26 Feb 07 |
jari |
55 |
buildConstraints(constraints, 0, 0, 1, 1, 100, 25); |
2 |
26 Feb 07 |
jari |
56 |
gridbag.setConstraints(numUniquePermsLabel, constraints); |
2 |
26 Feb 07 |
jari |
57 |
pane.add(numUniquePermsLabel); |
2 |
26 Feb 07 |
jari |
58 |
|
2 |
26 Feb 07 |
jari |
59 |
allPermsButton = new JRadioButton("Use all of them", true); |
2 |
26 Feb 07 |
jari |
60 |
somePermsButton = new JRadioButton("Use just " + numUserPerms + " random permutations as previously specified", false); |
2 |
26 Feb 07 |
jari |
61 |
|
2 |
26 Feb 07 |
jari |
62 |
ButtonGroup chooseAllOrSome = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
63 |
chooseAllOrSome.add(allPermsButton); |
2 |
26 Feb 07 |
jari |
64 |
chooseAllOrSome.add(somePermsButton); |
2 |
26 Feb 07 |
jari |
65 |
|
2 |
26 Feb 07 |
jari |
66 |
constraints.anchor = GridBagConstraints.WEST; |
2 |
26 Feb 07 |
jari |
67 |
|
2 |
26 Feb 07 |
jari |
68 |
buildConstraints(constraints, 0, 1, 1, 1, 0, 25); |
2 |
26 Feb 07 |
jari |
69 |
gridbag.setConstraints(allPermsButton, constraints); |
2 |
26 Feb 07 |
jari |
70 |
pane.add(allPermsButton); |
2 |
26 Feb 07 |
jari |
71 |
|
2 |
26 Feb 07 |
jari |
72 |
buildConstraints(constraints, 0, 2, 1, 1, 0, 25); |
2 |
26 Feb 07 |
jari |
73 |
gridbag.setConstraints(somePermsButton, constraints); |
2 |
26 Feb 07 |
jari |
74 |
pane.add(somePermsButton); |
2 |
26 Feb 07 |
jari |
75 |
|
2 |
26 Feb 07 |
jari |
76 |
constraints.anchor = GridBagConstraints.CENTER; |
2 |
26 Feb 07 |
jari |
77 |
|
2 |
26 Feb 07 |
jari |
78 |
okButton = new JButton("OK"); |
2 |
26 Feb 07 |
jari |
79 |
buildConstraints(constraints, 0, 3, 1, 1, 0, 25); |
2 |
26 Feb 07 |
jari |
80 |
gridbag.setConstraints(okButton, constraints); |
2 |
26 Feb 07 |
jari |
81 |
okButton.addActionListener(new ActionListener(){ |
2 |
26 Feb 07 |
jari |
82 |
public void actionPerformed(ActionEvent evt) { |
2 |
26 Feb 07 |
jari |
83 |
okPressed = true; |
2 |
26 Feb 07 |
jari |
84 |
dispose(); |
2 |
26 Feb 07 |
jari |
85 |
} |
2 |
26 Feb 07 |
jari |
86 |
}); |
2 |
26 Feb 07 |
jari |
87 |
pane.add(okButton); |
2 |
26 Feb 07 |
jari |
88 |
|
2 |
26 Feb 07 |
jari |
89 |
setContentPane(pane); |
2 |
26 Feb 07 |
jari |
90 |
} |
2 |
26 Feb 07 |
jari |
91 |
|
2 |
26 Feb 07 |
jari |
92 |
public void setVisible(boolean visible) { |
2 |
26 Feb 07 |
jari |
93 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
94 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
95 |
|
2 |
26 Feb 07 |
jari |
96 |
super.setVisible(visible); |
2 |
26 Feb 07 |
jari |
97 |
|
2 |
26 Feb 07 |
jari |
98 |
} |
2 |
26 Feb 07 |
jari |
99 |
|
2 |
26 Feb 07 |
jari |
100 |
void buildConstraints(GridBagConstraints gbc, int gx, int gy, |
2 |
26 Feb 07 |
jari |
101 |
int gw, int gh, int wx, int wy) { |
2 |
26 Feb 07 |
jari |
102 |
|
2 |
26 Feb 07 |
jari |
103 |
gbc.gridx = gx; |
2 |
26 Feb 07 |
jari |
104 |
gbc.gridy = gy; |
2 |
26 Feb 07 |
jari |
105 |
gbc.gridwidth = gw; |
2 |
26 Feb 07 |
jari |
106 |
gbc.gridheight = gh; |
2 |
26 Feb 07 |
jari |
107 |
gbc.weightx = wx; |
2 |
26 Feb 07 |
jari |
108 |
gbc.weighty = wy; |
2 |
26 Feb 07 |
jari |
109 |
} |
2 |
26 Feb 07 |
jari |
110 |
|
2 |
26 Feb 07 |
jari |
111 |
|
2 |
26 Feb 07 |
jari |
112 |
public boolean isOkPressed() { |
2 |
26 Feb 07 |
jari |
113 |
return okPressed; |
2 |
26 Feb 07 |
jari |
114 |
} |
2 |
26 Feb 07 |
jari |
115 |
|
2 |
26 Feb 07 |
jari |
116 |
public boolean useAllPerms() { |
2 |
26 Feb 07 |
jari |
117 |
return allPermsButton.isSelected(); |
2 |
26 Feb 07 |
jari |
118 |
} |
2 |
26 Feb 07 |
jari |
119 |
|
2 |
26 Feb 07 |
jari |
120 |
public static void main(String[] args) { |
2 |
26 Feb 07 |
jari |
121 |
|
2 |
26 Feb 07 |
jari |
122 |
JFrame dummyFrame = new JFrame(); |
2 |
26 Feb 07 |
jari |
123 |
SAMAllPermsDialog sDialog = new SAMAllPermsDialog(dummyFrame, true, 20, 100); |
2 |
26 Feb 07 |
jari |
124 |
sDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
125 |
} |
2 |
26 Feb 07 |
jari |
126 |
|
2 |
26 Feb 07 |
jari |
127 |
} |
2 |
26 Feb 07 |
jari |
128 |
|
2 |
26 Feb 07 |
jari |
129 |
|
2 |
26 Feb 07 |
jari |
130 |
|
2 |
26 Feb 07 |
jari |
131 |
|
2 |
26 Feb 07 |
jari |
132 |
|
2 |
26 Feb 07 |
jari |
133 |
|
2 |
26 Feb 07 |
jari |
134 |
|
2 |
26 Feb 07 |
jari |
135 |
|
2 |
26 Feb 07 |
jari |
136 |
|
2 |
26 Feb 07 |
jari |
137 |
|
2 |
26 Feb 07 |
jari |
138 |
|
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 |
|
2 |
26 Feb 07 |
jari |
144 |
|
2 |
26 Feb 07 |
jari |
145 |
|
2 |
26 Feb 07 |
jari |
146 |
|
2 |
26 Feb 07 |
jari |
147 |
|
2 |
26 Feb 07 |
jari |
148 |
|
2 |
26 Feb 07 |
jari |
149 |
|
2 |
26 Feb 07 |
jari |
150 |
|
2 |
26 Feb 07 |
jari |
151 |
|
2 |
26 Feb 07 |
jari |
152 |
|
2 |
26 Feb 07 |
jari |
153 |
|
2 |
26 Feb 07 |
jari |
154 |
|
2 |
26 Feb 07 |
jari |
155 |
|