2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2003, 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: SetChartRangeDialog.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.2 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/02/23 20:59:43 $ |
2 |
26 Feb 07 |
jari |
* $Author: caliente $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.microarray.mev.cgh.CGHGuiObj.CGHBrowser; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Container; |
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.WindowAdapter; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.event.WindowEvent; |
2 |
26 Feb 07 |
jari |
23 |
|
2 |
26 Feb 07 |
jari |
24 |
import javax.swing.JButton; |
2 |
26 Feb 07 |
jari |
25 |
import javax.swing.JDialog; |
2 |
26 Feb 07 |
jari |
26 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
27 |
import javax.swing.JLabel; |
2 |
26 Feb 07 |
jari |
28 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
29 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
30 |
|
2 |
26 Feb 07 |
jari |
31 |
import org.tigr.util.awt.GBA; |
2 |
26 Feb 07 |
jari |
32 |
|
2 |
26 Feb 07 |
jari |
33 |
/** |
2 |
26 Feb 07 |
jari |
* @author Adam Margolin |
2 |
26 Feb 07 |
jari |
* @author Raktim Sinha |
2 |
26 Feb 07 |
jari |
36 |
* |
2 |
26 Feb 07 |
jari |
37 |
*/ |
2 |
26 Feb 07 |
jari |
38 |
public class SetChartRangeDialog extends JDialog { |
2 |
26 Feb 07 |
jari |
39 |
private int result; |
2 |
26 Feb 07 |
jari |
40 |
private Dimension size; |
2 |
26 Feb 07 |
jari |
41 |
private JLabel minLabel, maxLabel; |
2 |
26 Feb 07 |
jari |
42 |
float min, max; |
2 |
26 Feb 07 |
jari |
43 |
private JTextField minTextField, maxTextField; |
2 |
26 Feb 07 |
jari |
44 |
private GBA gba; |
2 |
26 Feb 07 |
jari |
45 |
|
2 |
26 Feb 07 |
jari |
46 |
public SetChartRangeDialog(JFrame parent, float origMin, float origMax) { |
2 |
26 Feb 07 |
jari |
47 |
super(parent, true); |
2 |
26 Feb 07 |
jari |
48 |
|
2 |
26 Feb 07 |
jari |
49 |
setTitle("Set Display Range"); |
2 |
26 Feb 07 |
jari |
50 |
gba = new GBA(); |
2 |
26 Feb 07 |
jari |
51 |
minLabel = new JLabel("Min: "); |
2 |
26 Feb 07 |
jari |
52 |
minTextField = new JTextField(10); |
2 |
26 Feb 07 |
jari |
53 |
minTextField.setText("" + origMin); |
2 |
26 Feb 07 |
jari |
54 |
maxLabel = new JLabel("Max: "); |
2 |
26 Feb 07 |
jari |
55 |
maxTextField = new JTextField(10); |
2 |
26 Feb 07 |
jari |
56 |
maxTextField.setText("" + origMax); |
2 |
26 Feb 07 |
jari |
57 |
JButton okButton = new JButton("Okay"); |
2 |
26 Feb 07 |
jari |
58 |
okButton.setActionCommand("ok-command"); |
2 |
26 Feb 07 |
jari |
59 |
okButton.addActionListener(new Listener()); |
2 |
26 Feb 07 |
jari |
60 |
JButton cancelButton = new JButton("Cancel"); |
2 |
26 Feb 07 |
jari |
61 |
cancelButton.setActionCommand("cancel-command"); |
2 |
26 Feb 07 |
jari |
62 |
cancelButton.addActionListener(new Listener()); |
2 |
26 Feb 07 |
jari |
63 |
|
2 |
26 Feb 07 |
jari |
64 |
Container content = getContentPane(); |
2 |
26 Feb 07 |
jari |
65 |
content.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
66 |
gba.add(content, minLabel, 0, 0, 1, 1, 0, 0, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
67 |
gba.add(content, minTextField, 1, 0, 1, 1, 1, 0, GBA.H, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
68 |
gba.add(content, maxLabel, 0, 1, 1, 1, 0, 0, GBA.NONE, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
69 |
gba.add(content, maxTextField, 1, 1, 2, 1, 1, 0, GBA.H, GBA.C, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
70 |
gba.add(content, cancelButton, 0, 2, 1, 1, 0, 0, GBA.NONE, GBA.W, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
71 |
gba.add(content, okButton, 1, 2, 1, 1, 0, 0, GBA.NONE, GBA.E, new Insets(5, 5, 5, 5), 0, 0); |
2 |
26 Feb 07 |
jari |
72 |
|
2 |
26 Feb 07 |
jari |
73 |
setResizable(false); |
2 |
26 Feb 07 |
jari |
74 |
minTextField.grabFocus(); |
2 |
26 Feb 07 |
jari |
75 |
getRootPane().setDefaultButton(okButton); |
2 |
26 Feb 07 |
jari |
76 |
pack(); |
2 |
26 Feb 07 |
jari |
77 |
} |
2 |
26 Feb 07 |
jari |
78 |
|
2 |
26 Feb 07 |
jari |
79 |
public int showModal() { |
2 |
26 Feb 07 |
jari |
80 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
81 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
82 |
show(); |
2 |
26 Feb 07 |
jari |
83 |
return result; |
2 |
26 Feb 07 |
jari |
84 |
} |
2 |
26 Feb 07 |
jari |
85 |
|
2 |
26 Feb 07 |
jari |
/** Getter for property min. |
2 |
26 Feb 07 |
jari |
* @return Value of property min. |
2 |
26 Feb 07 |
jari |
88 |
*/ |
2 |
26 Feb 07 |
jari |
89 |
public float getMin() { |
2 |
26 Feb 07 |
jari |
90 |
return min; |
2 |
26 Feb 07 |
jari |
91 |
} |
2 |
26 Feb 07 |
jari |
92 |
|
2 |
26 Feb 07 |
jari |
/** Setter for property min. |
2 |
26 Feb 07 |
jari |
* @param min New value of property min. |
2 |
26 Feb 07 |
jari |
95 |
*/ |
2 |
26 Feb 07 |
jari |
96 |
public void setMin(float min) { |
2 |
26 Feb 07 |
jari |
97 |
this.min = min; |
2 |
26 Feb 07 |
jari |
98 |
} |
2 |
26 Feb 07 |
jari |
99 |
|
2 |
26 Feb 07 |
jari |
/** Getter for property max. |
2 |
26 Feb 07 |
jari |
* @return Value of property max. |
2 |
26 Feb 07 |
jari |
102 |
*/ |
2 |
26 Feb 07 |
jari |
103 |
public float getMax() { |
2 |
26 Feb 07 |
jari |
104 |
return max; |
2 |
26 Feb 07 |
jari |
105 |
} |
2 |
26 Feb 07 |
jari |
106 |
|
2 |
26 Feb 07 |
jari |
/** Setter for property max. |
2 |
26 Feb 07 |
jari |
* @param max New value of property max. |
2 |
26 Feb 07 |
jari |
109 |
*/ |
2 |
26 Feb 07 |
jari |
110 |
public void setMax(float max) { |
2 |
26 Feb 07 |
jari |
111 |
this.max = max; |
2 |
26 Feb 07 |
jari |
112 |
} |
2 |
26 Feb 07 |
jari |
113 |
|
2 |
26 Feb 07 |
jari |
114 |
private class Listener extends WindowAdapter implements ActionListener { |
2 |
26 Feb 07 |
jari |
115 |
|
2 |
26 Feb 07 |
jari |
116 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
117 |
String command = event.getActionCommand(); |
2 |
26 Feb 07 |
jari |
118 |
if (command.equals("ok-command")) { |
2 |
26 Feb 07 |
jari |
119 |
String minText = minTextField.getText(); |
2 |
26 Feb 07 |
jari |
120 |
String maxText = maxTextField.getText(); |
2 |
26 Feb 07 |
jari |
121 |
try { |
2 |
26 Feb 07 |
jari |
122 |
min = Float.parseFloat(minText); |
2 |
26 Feb 07 |
jari |
123 |
max = Float.parseFloat(maxText); |
2 |
26 Feb 07 |
jari |
124 |
result = JOptionPane.OK_OPTION; |
2 |
26 Feb 07 |
jari |
125 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
126 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
127 |
} |
2 |
26 Feb 07 |
jari |
128 |
dispose(); |
2 |
26 Feb 07 |
jari |
129 |
} else if (command.equals("cancel-command")) { |
2 |
26 Feb 07 |
jari |
130 |
result = JOptionPane.CANCEL_OPTION; |
2 |
26 Feb 07 |
jari |
131 |
dispose(); |
2 |
26 Feb 07 |
jari |
132 |
} |
2 |
26 Feb 07 |
jari |
133 |
} |
2 |
26 Feb 07 |
jari |
134 |
|
2 |
26 Feb 07 |
jari |
135 |
public void windowClosing(WindowEvent e) { |
2 |
26 Feb 07 |
jari |
136 |
result = JOptionPane.CLOSED_OPTION; |
2 |
26 Feb 07 |
jari |
137 |
dispose(); |
2 |
26 Feb 07 |
jari |
138 |
} |
2 |
26 Feb 07 |
jari |
139 |
} |
2 |
26 Feb 07 |
jari |
140 |
|
2 |
26 Feb 07 |
jari |
141 |
} |