2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2004, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: SetPresentCallDialog.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.3 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/02/24 15:44:52 $ |
2 |
26 Feb 07 |
jari |
* $Author: wwang67 $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.microarray.mev; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.Toolkit; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.event.KeyEvent; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.event.KeyListener; |
2 |
26 Feb 07 |
jari |
23 |
import java.awt.event.WindowAdapter; |
2 |
26 Feb 07 |
jari |
24 |
import java.awt.event.WindowEvent; |
2 |
26 Feb 07 |
jari |
25 |
|
2 |
26 Feb 07 |
jari |
26 |
import javax.swing.BorderFactory; |
2 |
26 Feb 07 |
jari |
27 |
import javax.swing.JCheckBox; |
2 |
26 Feb 07 |
jari |
28 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
29 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
30 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
31 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
32 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
33 |
|
2 |
26 Feb 07 |
jari |
34 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.AlgorithmDialog; |
2 |
26 Feb 07 |
jari |
35 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.dialogHelpUtil.HelpWindow; |
2 |
26 Feb 07 |
jari |
36 |
import org.tigr.util.awt.GBA; |
2 |
26 Feb 07 |
jari |
37 |
|
2 |
26 Feb 07 |
jari |
38 |
|
2 |
26 Feb 07 |
jari |
39 |
public class SetPresentCallDialog extends AlgorithmDialog { |
2 |
26 Feb 07 |
jari |
40 |
|
2 |
26 Feb 07 |
jari |
41 |
private float originalValue; |
2 |
26 Feb 07 |
jari |
42 |
private int result; |
2 |
26 Feb 07 |
jari |
43 |
private JTextField textField; |
2 |
26 Feb 07 |
jari |
44 |
private JCheckBox enableCheckBox; |
2 |
26 Feb 07 |
jari |
45 |
private JLabel percentageLabel; |
2 |
26 Feb 07 |
jari |
46 |
|
2 |
26 Feb 07 |
jari |
47 |
public SetPresentCallDialog(JFrame parent, float percentage) { |
2 |
26 Feb 07 |
jari |
48 |
super(parent, "Set Percentage Cutoff", true); |
2 |
26 Feb 07 |
jari |
49 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
50 |
originalValue = percentage; |
2 |
26 Feb 07 |
jari |
51 |
|
2 |
26 Feb 07 |
jari |
52 |
GBA gba = new GBA(); |
2 |
26 Feb 07 |
jari |
53 |
|
2 |
26 Feb 07 |
jari |
54 |
enableCheckBox = new JCheckBox("Enable Percentage Cutoff Filter", true); |
2 |
26 Feb 07 |
jari |
55 |
enableCheckBox.setActionCommand("enable-check-box-command"); |
2 |
26 Feb 07 |
jari |
56 |
enableCheckBox.setOpaque(false); |
2 |
26 Feb 07 |
jari |
57 |
enableCheckBox.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
58 |
enableCheckBox.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
59 |
|
2 |
26 Feb 07 |
jari |
60 |
percentageLabel = new JLabel("Absent Calls Percentage filter(A/(P+M+A)) (" + percentage + "%): "); |
2 |
26 Feb 07 |
jari |
61 |
percentageLabel.setHorizontalTextPosition(JLabel.RIGHT); |
2 |
26 Feb 07 |
jari |
62 |
percentageLabel.setHorizontalAlignment(JLabel.RIGHT); |
2 |
26 Feb 07 |
jari |
63 |
|
2 |
26 Feb 07 |
jari |
64 |
textField = new JTextField(10); |
2 |
26 Feb 07 |
jari |
65 |
textField.setText(String.valueOf(percentage)); |
2 |
26 Feb 07 |
jari |
66 |
textField.selectAll(); |
2 |
26 Feb 07 |
jari |
67 |
textField.addKeyListener(listener); |
2 |
26 Feb 07 |
jari |
68 |
|
2 |
26 Feb 07 |
jari |
69 |
JPanel panel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
70 |
panel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
71 |
panel.setBorder(BorderFactory.createLineBorder(Color.black)); |
2 |
26 Feb 07 |
jari |
72 |
|
2 |
26 Feb 07 |
jari |
73 |
gba.add(panel, enableCheckBox, 0, 0, 2, 1, 0, 0, GBA.V, GBA.C, new Insets(25, 5, 0, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
74 |
gba.add(panel, percentageLabel, 0, 1, 1, 1, 1, 0, GBA.B, GBA.E, new Insets(10, 5, 35, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
75 |
gba.add(panel, textField, 1, 1, 1, 1, 1, 0, GBA.NONE, GBA.W, new Insets(10, 5, 35, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
76 |
|
2 |
26 Feb 07 |
jari |
77 |
addContent(panel); |
2 |
26 Feb 07 |
jari |
78 |
setActionListeners(listener); |
2 |
26 Feb 07 |
jari |
79 |
addWindowListener(listener); |
2 |
26 Feb 07 |
jari |
80 |
pack(); |
2 |
26 Feb 07 |
jari |
81 |
setResizable(false); |
2 |
26 Feb 07 |
jari |
82 |
textField.grabFocus(); |
2 |
26 Feb 07 |
jari |
83 |
} |
2 |
26 Feb 07 |
jari |
84 |
|
2 |
26 Feb 07 |
jari |
85 |
public int showModal() { |
2 |
26 Feb 07 |
jari |
86 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
87 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
88 |
show(); |
2 |
26 Feb 07 |
jari |
89 |
return result; |
2 |
26 Feb 07 |
jari |
90 |
} |
2 |
26 Feb 07 |
jari |
91 |
|
2 |
26 Feb 07 |
jari |
92 |
public boolean isCutoffFilterEnabled() { |
2 |
26 Feb 07 |
jari |
93 |
return enableCheckBox.isSelected(); |
2 |
26 Feb 07 |
jari |
94 |
} |
2 |
26 Feb 07 |
jari |
95 |
|
2 |
26 Feb 07 |
jari |
96 |
public float getPercentageCutoff() { |
2 |
26 Feb 07 |
jari |
97 |
return Float.parseFloat(textField.getText()); |
2 |
26 Feb 07 |
jari |
98 |
} |
2 |
26 Feb 07 |
jari |
99 |
|
2 |
26 Feb 07 |
jari |
100 |
public static void main(String [] args) { |
2 |
26 Feb 07 |
jari |
101 |
SetPercentageCutoffsDialog dialog = new SetPercentageCutoffsDialog(new JFrame(), 0f); |
2 |
26 Feb 07 |
jari |
102 |
dialog.showModal(); |
2 |
26 Feb 07 |
jari |
103 |
} |
2 |
26 Feb 07 |
jari |
104 |
|
2 |
26 Feb 07 |
jari |
105 |
private class Listener extends WindowAdapter implements ActionListener, KeyListener { |
2 |
26 Feb 07 |
jari |
106 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
107 |
String command = event.getActionCommand(); |
2 |
26 Feb 07 |
jari |
108 |
if (command.equals("ok-command")) { |
2 |
26 Feb 07 |
jari |
109 |
try { |
2 |
26 Feb 07 |
jari |
110 |
Float.parseFloat(textField.getText()); |
2 |
26 Feb 07 |
jari |
111 |
result = JOptionPane.OK_OPTION; |
2 |
26 Feb 07 |
jari |
112 |
} catch (Exception exception) { |
2 |
26 Feb 07 |
jari |
113 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
114 |
} |
2 |
26 Feb 07 |
jari |
115 |
dispose(); |
2 |
26 Feb 07 |
jari |
116 |
} else if (command.equals("cancel-command")) { |
2 |
26 Feb 07 |
jari |
117 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
118 |
dispose(); |
2 |
26 Feb 07 |
jari |
119 |
} else if (command.equals("reset-command")) { |
2 |
26 Feb 07 |
jari |
120 |
enableCheckBox.setSelected(true); |
2 |
26 Feb 07 |
jari |
121 |
textField.setEnabled(true); |
2 |
26 Feb 07 |
jari |
122 |
percentageLabel.setEnabled(true); |
2 |
26 Feb 07 |
jari |
123 |
textField.setText(String.valueOf(originalValue)); |
2 |
26 Feb 07 |
jari |
124 |
textField.selectAll(); |
2 |
26 Feb 07 |
jari |
125 |
textField.grabFocus(); |
2 |
26 Feb 07 |
jari |
126 |
} else if (command.equals("info-command")){ |
2 |
26 Feb 07 |
jari |
127 |
HelpWindow hw = new HelpWindow(SetPresentCallDialog.this, "Set Percentage Cutoff"); |
2 |
26 Feb 07 |
jari |
128 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
129 |
if(hw.getWindowContent()){ |
2 |
26 Feb 07 |
jari |
130 |
hw.setSize(450,600); |
2 |
26 Feb 07 |
jari |
131 |
hw.setLocation(); |
2 |
26 Feb 07 |
jari |
132 |
hw.show(); |
2 |
26 Feb 07 |
jari |
133 |
return; |
2 |
26 Feb 07 |
jari |
134 |
} |
2 |
26 Feb 07 |
jari |
135 |
else { |
2 |
26 Feb 07 |
jari |
136 |
hw.setVisible(false); |
2 |
26 Feb 07 |
jari |
137 |
hw.dispose(); |
2 |
26 Feb 07 |
jari |
138 |
return; |
2 |
26 Feb 07 |
jari |
139 |
} |
2 |
26 Feb 07 |
jari |
140 |
} else if (command.equals("enable-check-box-command")) { |
2 |
26 Feb 07 |
jari |
141 |
boolean enabled = enableCheckBox.isSelected(); |
2 |
26 Feb 07 |
jari |
142 |
percentageLabel.setEnabled(enabled); |
2 |
26 Feb 07 |
jari |
143 |
textField.setEnabled(enabled); |
2 |
26 Feb 07 |
jari |
144 |
} |
2 |
26 Feb 07 |
jari |
145 |
} |
2 |
26 Feb 07 |
jari |
146 |
|
2 |
26 Feb 07 |
jari |
147 |
public void windowClosing(WindowEvent e) { |
2 |
26 Feb 07 |
jari |
148 |
result = JOptionPane.CLOSED_OPTION; |
2 |
26 Feb 07 |
jari |
149 |
dispose(); |
2 |
26 Feb 07 |
jari |
150 |
} |
2 |
26 Feb 07 |
jari |
151 |
|
2 |
26 Feb 07 |
jari |
152 |
public void keyPressed(KeyEvent event) { |
2 |
26 Feb 07 |
jari |
153 |
if (event.getKeyCode() == KeyEvent.VK_ENTER) { |
2 |
26 Feb 07 |
jari |
154 |
try { |
2 |
26 Feb 07 |
jari |
155 |
Float.parseFloat(textField.getText()); |
2 |
26 Feb 07 |
jari |
156 |
result = JOptionPane.OK_OPTION; |
2 |
26 Feb 07 |
jari |
157 |
} catch (Exception exception) { |
2 |
26 Feb 07 |
jari |
158 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
159 |
} |
2 |
26 Feb 07 |
jari |
160 |
dispose(); |
2 |
26 Feb 07 |
jari |
161 |
} |
2 |
26 Feb 07 |
jari |
162 |
} |
2 |
26 Feb 07 |
jari |
163 |
|
2 |
26 Feb 07 |
jari |
164 |
public void keyReleased(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
165 |
public void keyTyped(KeyEvent event) {;} |
2 |
26 Feb 07 |
jari |
166 |
} |
2 |
26 Feb 07 |
jari |
167 |
} |