2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2006, 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 |
package org.tigr.microarray.mev.cluster.gui.impl.lem; |
2 |
26 Feb 07 |
jari |
6 |
|
2 |
26 Feb 07 |
jari |
7 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
8 |
import java.awt.Component; |
2 |
26 Feb 07 |
jari |
9 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
10 |
import java.awt.Frame; |
2 |
26 Feb 07 |
jari |
11 |
import java.awt.GridBagConstraints; |
2 |
26 Feb 07 |
jari |
12 |
import java.awt.GridBagLayout; |
2 |
26 Feb 07 |
jari |
13 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Toolkit; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.event.WindowAdapter; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.event.WindowEvent; |
2 |
26 Feb 07 |
jari |
19 |
import java.util.Properties; |
2 |
26 Feb 07 |
jari |
20 |
|
2 |
26 Feb 07 |
jari |
21 |
import javax.swing.BorderFactory; |
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.JLabel; |
2 |
26 Feb 07 |
jari |
26 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
27 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
28 |
import javax.swing.JRadioButton; |
2 |
26 Feb 07 |
jari |
29 |
import javax.swing.JSeparator; |
2 |
26 Feb 07 |
jari |
30 |
import javax.swing.JTextField; |
2 |
26 Feb 07 |
jari |
31 |
import javax.swing.border.BevelBorder; |
2 |
26 Feb 07 |
jari |
32 |
|
2 |
26 Feb 07 |
jari |
33 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.AlgorithmDialog; |
2 |
26 Feb 07 |
jari |
34 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.ParameterPanel; |
2 |
26 Feb 07 |
jari |
35 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.dialogHelpUtil.HelpWindow; |
2 |
26 Feb 07 |
jari |
36 |
|
2 |
26 Feb 07 |
jari |
37 |
/** |
2 |
26 Feb 07 |
jari |
* @author braisted |
2 |
26 Feb 07 |
jari |
39 |
* |
2 |
26 Feb 07 |
jari |
* The LEMViewerAttributDialog presents controls to permit customization of |
2 |
26 Feb 07 |
jari |
* the LEM. This includes fixed vs. scaled arrow length, gradient vs. binned |
2 |
26 Feb 07 |
jari |
* arrow color, fixed vs. scaled/constrained intergenic length, showing replicates |
2 |
26 Feb 07 |
jari |
43 |
*/ |
2 |
26 Feb 07 |
jari |
44 |
public class LEMViewerAttributeDialog extends AlgorithmDialog { |
2 |
26 Feb 07 |
jari |
45 |
|
2 |
26 Feb 07 |
jari |
46 |
|
2 |
26 Feb 07 |
jari |
47 |
private LinearExpressionMapViewer lem; |
2 |
26 Feb 07 |
jari |
48 |
|
2 |
26 Feb 07 |
jari |
49 |
private boolean isFixedArrowLength; |
2 |
26 Feb 07 |
jari |
50 |
private boolean isFixedOpenLength; |
2 |
26 Feb 07 |
jari |
51 |
private int fixedArrowLength; |
2 |
26 Feb 07 |
jari |
52 |
private int bpPerPixel; |
2 |
26 Feb 07 |
jari |
53 |
private int minArrowLength; |
2 |
26 Feb 07 |
jari |
54 |
private int maxArrowLength; |
2 |
26 Feb 07 |
jari |
55 |
private int maxOpenLength; |
2 |
26 Feb 07 |
jari |
56 |
private boolean showReps; |
2 |
26 Feb 07 |
jari |
57 |
|
2 |
26 Feb 07 |
jari |
58 |
private JRadioButton fixedArrowButton; |
2 |
26 Feb 07 |
jari |
59 |
private JRadioButton scaledArrowButton; |
2 |
26 Feb 07 |
jari |
60 |
|
2 |
26 Feb 07 |
jari |
61 |
private JLabel minArrowLabel; |
2 |
26 Feb 07 |
jari |
62 |
private JTextField minArrowField; |
2 |
26 Feb 07 |
jari |
63 |
|
2 |
26 Feb 07 |
jari |
64 |
private JLabel maxArrowLabel; |
2 |
26 Feb 07 |
jari |
65 |
private JTextField maxArrowField; |
2 |
26 Feb 07 |
jari |
66 |
|
2 |
26 Feb 07 |
jari |
67 |
private JLabel fixedArrowLabel; |
2 |
26 Feb 07 |
jari |
68 |
private JTextField fixedArrowField; |
2 |
26 Feb 07 |
jari |
69 |
|
2 |
26 Feb 07 |
jari |
70 |
private JLabel basePairScaleLabel; |
2 |
26 Feb 07 |
jari |
71 |
private JTextField basePairScaleField; |
2 |
26 Feb 07 |
jari |
72 |
|
2 |
26 Feb 07 |
jari |
73 |
private JCheckBox fixedOpenBox; |
2 |
26 Feb 07 |
jari |
74 |
private JLabel maxOpenLabel; |
2 |
26 Feb 07 |
jari |
75 |
private JTextField maxOpenField; |
2 |
26 Feb 07 |
jari |
76 |
|
2 |
26 Feb 07 |
jari |
77 |
private JCheckBox showReplicatesBox; |
2 |
26 Feb 07 |
jari |
78 |
|
2 |
26 Feb 07 |
jari |
79 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a LEMViewerAttributDialog |
2 |
26 Feb 07 |
jari |
* @param parent parent frame |
2 |
26 Feb 07 |
jari |
* @param lem associated LEM |
2 |
26 Feb 07 |
jari |
* @param isFixedArrowLength current arrow length mode (fixed/scaled) |
2 |
26 Feb 07 |
jari |
* @param isFixedOpenLength current intergenic mode (fixed/scaled) |
2 |
26 Feb 07 |
jari |
* @param fixedArrowLength current arrow length (when fixed) |
2 |
26 Feb 07 |
jari |
* @param minArrowLength current min. arrow length when scaled |
2 |
26 Feb 07 |
jari |
* @param maxArrowLength current max. arrow length when scaled |
2 |
26 Feb 07 |
jari |
* @param maxOpenLength current max. intergenic lenght when scaled |
2 |
26 Feb 07 |
jari |
* @param bpPerPixel scaling factor, bases per pixel |
2 |
26 Feb 07 |
jari |
* @param showReps indicates state of replicate display mode |
2 |
26 Feb 07 |
jari |
91 |
*/ |
2 |
26 Feb 07 |
jari |
92 |
public LEMViewerAttributeDialog(Frame parent, LinearExpressionMapViewer lem, boolean isFixedArrowLength, boolean isFixedOpenLength, |
2 |
26 Feb 07 |
jari |
93 |
int fixedArrowLength, int minArrowLength, int maxArrowLength, int maxOpenLength, int bpPerPixel, boolean showReps) { |
2 |
26 Feb 07 |
jari |
94 |
|
2 |
26 Feb 07 |
jari |
95 |
super(parent, "Customize LEM Viewer", true); |
2 |
26 Feb 07 |
jari |
96 |
this.lem = lem; |
2 |
26 Feb 07 |
jari |
97 |
this.isFixedArrowLength = isFixedArrowLength; |
2 |
26 Feb 07 |
jari |
98 |
this.isFixedOpenLength = isFixedOpenLength; |
2 |
26 Feb 07 |
jari |
99 |
this.fixedArrowLength = fixedArrowLength; |
2 |
26 Feb 07 |
jari |
100 |
this.minArrowLength = minArrowLength; |
2 |
26 Feb 07 |
jari |
101 |
this.maxArrowLength = maxArrowLength; |
2 |
26 Feb 07 |
jari |
102 |
this.maxOpenLength = maxOpenLength; |
2 |
26 Feb 07 |
jari |
103 |
this.bpPerPixel = bpPerPixel; |
2 |
26 Feb 07 |
jari |
104 |
this.showReps = showReps; |
2 |
26 Feb 07 |
jari |
105 |
|
2 |
26 Feb 07 |
jari |
106 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
107 |
|
2 |
26 Feb 07 |
jari |
108 |
ParameterPanel arrowPanel = new ParameterPanel("Locus Arrow Dimensions"); |
2 |
26 Feb 07 |
jari |
109 |
arrowPanel.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
110 |
|
2 |
26 Feb 07 |
jari |
111 |
ButtonGroup bg = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
112 |
|
2 |
26 Feb 07 |
jari |
113 |
fixedArrowButton = createRadioButton("Use Fixed Arrow Length", "fixed-arrow-length", listener, this.isFixedArrowLength, bg); |
2 |
26 Feb 07 |
jari |
114 |
|
2 |
26 Feb 07 |
jari |
115 |
fixedArrowLabel = new JLabel("Fixed Arrow Length (pixels, >= 15))"); |
2 |
26 Feb 07 |
jari |
116 |
fixedArrowField = new JTextField(String.valueOf(this.fixedArrowLength),10); |
2 |
26 Feb 07 |
jari |
117 |
|
2 |
26 Feb 07 |
jari |
118 |
Dimension dim = new Dimension(60,22); |
2 |
26 Feb 07 |
jari |
119 |
|
2 |
26 Feb 07 |
jari |
120 |
fixedArrowField.setPreferredSize(dim); |
2 |
26 Feb 07 |
jari |
121 |
fixedArrowField.setSize(dim); |
2 |
26 Feb 07 |
jari |
122 |
|
2 |
26 Feb 07 |
jari |
123 |
this.scaledArrowButton = createRadioButton("Use Scaled Arrow Length", "scale-arrow-command", listener, !this.isFixedArrowLength, bg); |
2 |
26 Feb 07 |
jari |
124 |
|
2 |
26 Feb 07 |
jari |
125 |
basePairScaleLabel = new JLabel("Scaling Factor (bases/pixel)"); |
2 |
26 Feb 07 |
jari |
126 |
basePairScaleField = new JTextField(String.valueOf(this.bpPerPixel)); |
2 |
26 Feb 07 |
jari |
127 |
basePairScaleField.setPreferredSize(dim); |
2 |
26 Feb 07 |
jari |
128 |
basePairScaleField.setSize(dim); |
2 |
26 Feb 07 |
jari |
129 |
|
2 |
26 Feb 07 |
jari |
130 |
minArrowLabel = new JLabel("Minimum Scaled Arrow Length (>=15)"); |
2 |
26 Feb 07 |
jari |
131 |
minArrowField = new JTextField(String.valueOf(this.minArrowLength)); |
2 |
26 Feb 07 |
jari |
132 |
minArrowField.setPreferredSize(dim); |
2 |
26 Feb 07 |
jari |
133 |
minArrowField.setSize(dim); |
2 |
26 Feb 07 |
jari |
134 |
|
2 |
26 Feb 07 |
jari |
135 |
maxArrowLabel = new JLabel("Maximum Scaled Arrow Length"); |
2 |
26 Feb 07 |
jari |
136 |
maxArrowField = new JTextField(String.valueOf(this.maxArrowLength)); |
2 |
26 Feb 07 |
jari |
137 |
maxArrowField.setPreferredSize(dim); |
2 |
26 Feb 07 |
jari |
138 |
maxArrowField.setSize(dim); |
2 |
26 Feb 07 |
jari |
139 |
|
2 |
26 Feb 07 |
jari |
//validate state |
2 |
26 Feb 07 |
jari |
141 |
if(fixedArrowButton.isSelected()) { |
2 |
26 Feb 07 |
jari |
142 |
minArrowField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
143 |
minArrowLabel.setEnabled(false); |
2 |
26 Feb 07 |
jari |
144 |
maxArrowField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
145 |
maxArrowLabel.setEnabled(false); |
2 |
26 Feb 07 |
jari |
146 |
|
2 |
26 Feb 07 |
jari |
147 |
basePairScaleLabel.setEnabled(false); |
2 |
26 Feb 07 |
jari |
148 |
basePairScaleField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
149 |
} else { |
2 |
26 Feb 07 |
jari |
150 |
fixedArrowField.setEnabled(false); |
2 |
26 Feb 07 |
jari |
151 |
} |
2 |
26 Feb 07 |
jari |
152 |
|
2 |
26 Feb 07 |
jari |
153 |
arrowPanel.add(fixedArrowButton, new GridBagConstraints(0,0,2,1,0,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10,10,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
154 |
arrowPanel.add(fixedArrowLabel, new GridBagConstraints(0,1,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10,10,10,0), 0,0)); |
2 |
26 Feb 07 |
jari |
155 |
arrowPanel.add(fixedArrowField, new GridBagConstraints(1,1,1,1,0,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,5,10,40), 0,0)); |
2 |
26 Feb 07 |
jari |
156 |
|
2 |
26 Feb 07 |
jari |
157 |
JSeparator sep = new JSeparator(JSeparator.HORIZONTAL); |
2 |
26 Feb 07 |
jari |
158 |
sep.setPreferredSize(new Dimension(150, 2)); |
2 |
26 Feb 07 |
jari |
159 |
sep.setSize(150,2); |
2 |
26 Feb 07 |
jari |
160 |
|
2 |
26 Feb 07 |
jari |
161 |
arrowPanel.add(sep, new GridBagConstraints(0,2,2,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,15,0,15), 0,0)); |
2 |
26 Feb 07 |
jari |
162 |
|
2 |
26 Feb 07 |
jari |
163 |
arrowPanel.add(scaledArrowButton, new GridBagConstraints(0,3,2,1,0,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10,10,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
164 |
|
2 |
26 Feb 07 |
jari |
165 |
arrowPanel.add(basePairScaleLabel, new GridBagConstraints(0,4,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10,10,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
166 |
arrowPanel.add(basePairScaleField, new GridBagConstraints(1,4,1,1,0,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,5,0,40), 0,0)); |
2 |
26 Feb 07 |
jari |
167 |
|
2 |
26 Feb 07 |
jari |
168 |
arrowPanel.add(minArrowLabel, new GridBagConstraints(0,5,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10,10,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
169 |
arrowPanel.add(minArrowField, new GridBagConstraints(1,5,1,1,0,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,5,0,40), 0,0)); |
2 |
26 Feb 07 |
jari |
170 |
|
2 |
26 Feb 07 |
jari |
171 |
arrowPanel.add(maxArrowLabel, new GridBagConstraints(0,6,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10,10,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
172 |
arrowPanel.add(maxArrowField, new GridBagConstraints(1,6,1,1,0,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,5,0,40), 0,0)); |
2 |
26 Feb 07 |
jari |
173 |
|
2 |
26 Feb 07 |
jari |
174 |
|
2 |
26 Feb 07 |
jari |
175 |
ParameterPanel openPanel = new ParameterPanel("Intergenic or Unsampled Region Dimensions"); |
2 |
26 Feb 07 |
jari |
176 |
openPanel.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
177 |
|
2 |
26 Feb 07 |
jari |
178 |
this.fixedOpenBox = createCheckBox("Use Fixed Intergenic Length (1 pixel)", "fixed-open-length", listener, this.isFixedOpenLength); |
2 |
26 Feb 07 |
jari |
179 |
this.maxOpenLabel = new JLabel("Max Intergenic (or unsampled) Length"); |
2 |
26 Feb 07 |
jari |
180 |
this.maxOpenField = new JTextField(String.valueOf(this.maxOpenLength)); |
2 |
26 Feb 07 |
jari |
181 |
maxOpenField.setPreferredSize(dim); |
2 |
26 Feb 07 |
jari |
182 |
maxOpenField.setSize(dim); |
2 |
26 Feb 07 |
jari |
183 |
|
2 |
26 Feb 07 |
jari |
184 |
boolean fixedOpen = this.fixedOpenBox.isSelected(); |
2 |
26 Feb 07 |
jari |
185 |
|
2 |
26 Feb 07 |
jari |
186 |
this.maxOpenField.setEnabled(!fixedOpen); |
2 |
26 Feb 07 |
jari |
187 |
this.maxOpenLabel.setEnabled(!fixedOpen); |
2 |
26 Feb 07 |
jari |
188 |
|
2 |
26 Feb 07 |
jari |
189 |
openPanel.add(fixedOpenBox, new GridBagConstraints(0,0,1,1,0,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10,10,0,0),0,0)); |
2 |
26 Feb 07 |
jari |
190 |
openPanel.add(maxOpenLabel, new GridBagConstraints(0,1,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10,10,10,0),0,0)); |
2 |
26 Feb 07 |
jari |
191 |
openPanel.add(maxOpenField, new GridBagConstraints(1,1,1,1,0,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,5,10,40),0,0)); |
2 |
26 Feb 07 |
jari |
192 |
|
2 |
26 Feb 07 |
jari |
193 |
ParameterPanel repPanel = new ParameterPanel("Locus Replicate Rendering"); |
2 |
26 Feb 07 |
jari |
194 |
repPanel.setLayout(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
195 |
|
2 |
26 Feb 07 |
jari |
196 |
String label = "<html><body>This option will display an arrow"; |
2 |
26 Feb 07 |
jari |
197 |
label += " for each of the spots related to the locus.<br>"; |
2 |
26 Feb 07 |
jari |
198 |
label += "Because of the complex structure, arrow lengths and intergenic lengths <br>will be fixed when this option is selected.</body><html>"; |
2 |
26 Feb 07 |
jari |
199 |
|
2 |
26 Feb 07 |
jari |
200 |
JLabel repLabel = new JLabel(label); |
2 |
26 Feb 07 |
jari |
201 |
this.showReplicatesBox = createCheckBox("Show Locus Replicates (representative spots)", "show-reps-command", listener, showReps); |
2 |
26 Feb 07 |
jari |
202 |
|
2 |
26 Feb 07 |
jari |
203 |
repPanel.add(repLabel, new GridBagConstraints(0,0,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10,10,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
204 |
repPanel.add(showReplicatesBox, new GridBagConstraints(0,1,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10,10,10,0), 0,0)); |
2 |
26 Feb 07 |
jari |
205 |
|
2 |
26 Feb 07 |
jari |
206 |
JPanel panel = new JPanel(new GridBagLayout()); |
2 |
26 Feb 07 |
jari |
207 |
panel.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
208 |
panel.add(arrowPanel, new GridBagConstraints(0,0,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5,0,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
209 |
panel.add(openPanel, new GridBagConstraints(0,1,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5,0,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
210 |
panel.add(repPanel, new GridBagConstraints(0,2,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5,0,0,0), 0,0)); |
2 |
26 Feb 07 |
jari |
211 |
|
2 |
26 Feb 07 |
jari |
212 |
reconfigureButtons(listener); |
2 |
26 Feb 07 |
jari |
213 |
|
2 |
26 Feb 07 |
jari |
214 |
this.addContent(panel); |
2 |
26 Feb 07 |
jari |
215 |
setActionListeners(listener); |
2 |
26 Feb 07 |
jari |
216 |
|
2 |
26 Feb 07 |
jari |
217 |
pack(); |
2 |
26 Feb 07 |
jari |
218 |
} |
2 |
26 Feb 07 |
jari |
219 |
|
2 |
26 Feb 07 |
jari |
220 |
/** |
2 |
26 Feb 07 |
jari |
* Shows the dialog centered on screen |
2 |
26 Feb 07 |
jari |
222 |
*/ |
2 |
26 Feb 07 |
jari |
223 |
public void showModal() { |
2 |
26 Feb 07 |
jari |
224 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
225 |
setLocation((screenSize.width - getSize().width)/2, (screenSize.height - getSize().height)/2); |
2 |
26 Feb 07 |
jari |
226 |
show(); |
2 |
26 Feb 07 |
jari |
227 |
} |
2 |
26 Feb 07 |
jari |
228 |
|
2 |
26 Feb 07 |
jari |
229 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the value for fixed arrow length |
2 |
26 Feb 07 |
jari |
* @return arrow length |
2 |
26 Feb 07 |
jari |
232 |
*/ |
2 |
26 Feb 07 |
jari |
233 |
public int getFixedArrowLength() { |
2 |
26 Feb 07 |
jari |
234 |
return Integer.parseInt(this.fixedArrowField.getText()); |
2 |
26 Feb 07 |
jari |
235 |
} |
2 |
26 Feb 07 |
jari |
236 |
|
2 |
26 Feb 07 |
jari |
237 |
/** |
2 |
26 Feb 07 |
jari |
* returns the minium arrow length |
2 |
26 Feb 07 |
jari |
* @return returns the minimum arrow length |
2 |
26 Feb 07 |
jari |
240 |
*/ |
2 |
26 Feb 07 |
jari |
241 |
public int getMinArrowLength() { |
2 |
26 Feb 07 |
jari |
242 |
return Integer.parseInt(this.minArrowField.getText()); |
2 |
26 Feb 07 |
jari |
243 |
} |
2 |
26 Feb 07 |
jari |
244 |
|
2 |
26 Feb 07 |
jari |
245 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the maximum arrow length |
2 |
26 Feb 07 |
jari |
* @return max arrow length |
2 |
26 Feb 07 |
jari |
248 |
*/ |
2 |
26 Feb 07 |
jari |
249 |
public int getMaxArrowLength() { |
2 |
26 Feb 07 |
jari |
250 |
return Integer.parseInt(this.maxArrowField.getText()); |
2 |
26 Feb 07 |
jari |
251 |
} |
2 |
26 Feb 07 |
jari |
252 |
|
2 |
26 Feb 07 |
jari |
253 |
/** |
2 |
26 Feb 07 |
jari |
* base per pixel scaling factor |
2 |
26 Feb 07 |
jari |
* @return scaling factor (base/pixel) |
2 |
26 Feb 07 |
jari |
256 |
*/ |
2 |
26 Feb 07 |
jari |
257 |
public int getScalingFactor() { |
2 |
26 Feb 07 |
jari |
258 |
return Integer.parseInt(this.basePairScaleField.getText()); |
2 |
26 Feb 07 |
jari |
259 |
} |
2 |
26 Feb 07 |
jari |
260 |
|
2 |
26 Feb 07 |
jari |
261 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the maximum intergenic length value |
2 |
26 Feb 07 |
jari |
* @return intergenic length constraint |
2 |
26 Feb 07 |
jari |
264 |
*/ |
2 |
26 Feb 07 |
jari |
265 |
public int getMaxIntergenicLength() { |
2 |
26 Feb 07 |
jari |
266 |
return Integer.parseInt(this.maxOpenField.getText()); |
2 |
26 Feb 07 |
jari |
267 |
} |
2 |
26 Feb 07 |
jari |
268 |
|
2 |
26 Feb 07 |
jari |
269 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the state of arrow lengths, true if fixed, else false (scaled) |
2 |
26 Feb 07 |
jari |
* @return true if fixed, else false (fixed) |
2 |
26 Feb 07 |
jari |
272 |
*/ |
2 |
26 Feb 07 |
jari |
273 |
public boolean areArrowsFixed() { |
2 |
26 Feb 07 |
jari |
274 |
return this.fixedArrowButton.isSelected(); |
2 |
26 Feb 07 |
jari |
275 |
} |
2 |
26 Feb 07 |
jari |
276 |
|
2 |
26 Feb 07 |
jari |
277 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the state of intergenic (open) lengths, |
2 |
26 Feb 07 |
jari |
* true if fixed, else false (scaled) |
2 |
26 Feb 07 |
jari |
* @return true if fixed, else false (fixed) |
2 |
26 Feb 07 |
jari |
281 |
*/ |
2 |
26 Feb 07 |
jari |
282 |
public boolean areOpenAreasFixed() { |
2 |
26 Feb 07 |
jari |
283 |
return this.fixedOpenBox.isSelected(); |
2 |
26 Feb 07 |
jari |
284 |
} |
2 |
26 Feb 07 |
jari |
285 |
|
2 |
26 Feb 07 |
jari |
286 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the state of showing all replicate data vs. hiding |
2 |
26 Feb 07 |
jari |
* @return true if replicates should be displayed |
2 |
26 Feb 07 |
jari |
289 |
*/ |
2 |
26 Feb 07 |
jari |
290 |
public boolean showAllReplicates() { |
2 |
26 Feb 07 |
jari |
291 |
return showReplicatesBox.isSelected(); |
2 |
26 Feb 07 |
jari |
292 |
} |
2 |
26 Feb 07 |
jari |
293 |
|
2 |
26 Feb 07 |
jari |
294 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the current values into a <code>Properties</code> object and |
2 |
26 Feb 07 |
jari |
* updates lem as a preview |
2 |
26 Feb 07 |
jari |
297 |
*/ |
2 |
26 Feb 07 |
jari |
298 |
private void previewSettings() { |
2 |
26 Feb 07 |
jari |
299 |
|
2 |
26 Feb 07 |
jari |
//check validity |
2 |
26 Feb 07 |
jari |
301 |
if(!validateValues()) |
2 |
26 Feb 07 |
jari |
302 |
return; |
2 |
26 Feb 07 |
jari |
303 |
|
2 |
26 Feb 07 |
jari |
304 |
System.out.println("preview method, fixed arrows = "+this.fixedArrowButton.isSelected()); |
2 |
26 Feb 07 |
jari |
305 |
System.out.println("preview method, fixed arrows, methodCall = "+this.areArrowsFixed()); |
2 |
26 Feb 07 |
jari |
306 |
Properties props = new Properties(); |
2 |
26 Feb 07 |
jari |
307 |
props.setProperty("fixed-arrows", String.valueOf(areArrowsFixed())); |
2 |
26 Feb 07 |
jari |
308 |
props.setProperty("fixed-arrow-length", String.valueOf(getFixedArrowLength())); |
2 |
26 Feb 07 |
jari |
309 |
props.setProperty("scaling-factor", String.valueOf(getScalingFactor())); |
2 |
26 Feb 07 |
jari |
310 |
props.setProperty("min-arrow-length", String.valueOf(getMinArrowLength())); |
2 |
26 Feb 07 |
jari |
311 |
props.setProperty("max-arrow-length", String.valueOf(getMaxArrowLength())); |
2 |
26 Feb 07 |
jari |
312 |
props.setProperty("fixed-open", String.valueOf(areOpenAreasFixed())); |
2 |
26 Feb 07 |
jari |
313 |
props.setProperty("max-open-length", String.valueOf(getMaxIntergenicLength())); |
2 |
26 Feb 07 |
jari |
314 |
props.setProperty("show-replicates", String.valueOf(showAllReplicates())); |
2 |
26 Feb 07 |
jari |
315 |
|
2 |
26 Feb 07 |
jari |
//apply to viewer |
2 |
26 Feb 07 |
jari |
317 |
lem.setViewerSettings(props); |
2 |
26 Feb 07 |
jari |
318 |
} |
2 |
26 Feb 07 |
jari |
319 |
|
2 |
26 Feb 07 |
jari |
320 |
/** |
2 |
26 Feb 07 |
jari |
* Reconfigures buttons based on current settings. |
2 |
26 Feb 07 |
jari |
* @param listener |
2 |
26 Feb 07 |
jari |
323 |
*/ |
2 |
26 Feb 07 |
jari |
324 |
private void reconfigureButtons(Listener listener) { |
2 |
26 Feb 07 |
jari |
325 |
JButton previewButton = new JButton("Preview"); |
2 |
26 Feb 07 |
jari |
326 |
previewButton.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); |
2 |
26 Feb 07 |
jari |
327 |
previewButton.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
328 |
previewButton.setActionCommand("preview-command"); |
2 |
26 Feb 07 |
jari |
329 |
previewButton.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
330 |
Dimension dim = new Dimension(65, 30); |
2 |
26 Feb 07 |
jari |
331 |
previewButton.setPreferredSize(dim); |
2 |
26 Feb 07 |
jari |
332 |
previewButton.setSize(dim); |
2 |
26 Feb 07 |
jari |
333 |
|
2 |
26 Feb 07 |
jari |
334 |
okButton.setText("Apply"); |
2 |
26 Feb 07 |
jari |
335 |
|
2 |
26 Feb 07 |
jari |
336 |
Component [] comp = buttonPanel.getComponents(); |
2 |
26 Feb 07 |
jari |
337 |
|
2 |
26 Feb 07 |
jari |
//remove buttons |
2 |
26 Feb 07 |
jari |
339 |
for(int i = 0; i < comp.length; i++) { |
2 |
26 Feb 07 |
jari |
340 |
buttonPanel.remove(comp[i]); |
2 |
26 Feb 07 |
jari |
341 |
} |
2 |
26 Feb 07 |
jari |
342 |
|
2 |
26 Feb 07 |
jari |
343 |
buttonPanel.add(comp[0], new GridBagConstraints(0,0,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2,5,2,0), 0,0)); |
2 |
26 Feb 07 |
jari |
344 |
buttonPanel.add(comp[1], new GridBagConstraints(1,0,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2,10,2,0), 0,0)); |
2 |
26 Feb 07 |
jari |
345 |
buttonPanel.add(previewButton, new GridBagConstraints(2,0,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2,5,2,0), 0,0)); |
2 |
26 Feb 07 |
jari |
346 |
buttonPanel.add(comp[2], new GridBagConstraints(3,0,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2,5,2,0), 0,0)); |
2 |
26 Feb 07 |
jari |
347 |
buttonPanel.add(comp[3], new GridBagConstraints(4,0,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2,5,2,0), 0,0)); |
2 |
26 Feb 07 |
jari |
348 |
buttonPanel.add(comp[4], new GridBagConstraints(5,0,1,1,1,0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2,5,2,5), 0,0)); |
2 |
26 Feb 07 |
jari |
349 |
} |
2 |
26 Feb 07 |
jari |
350 |
|
2 |
26 Feb 07 |
jari |
351 |
/** |
2 |
26 Feb 07 |
jari |
* Validates the input values |
2 |
26 Feb 07 |
jari |
* @return true if values are valid based on parsing and values |
2 |
26 Feb 07 |
jari |
354 |
*/ |
2 |
26 Feb 07 |
jari |
355 |
private boolean validateValues() { |
2 |
26 Feb 07 |
jari |
356 |
boolean valid = true; |
2 |
26 Feb 07 |
jari |
//fixed length arrows, check validity of fixed lenght |
2 |
26 Feb 07 |
jari |
358 |
int val, minVal, maxVal; |
2 |
26 Feb 07 |
jari |
359 |
int level = 0; |
2 |
26 Feb 07 |
jari |
360 |
if(areArrowsFixed()) { |
2 |
26 Feb 07 |
jari |
361 |
|
2 |
26 Feb 07 |
jari |
362 |
try { |
2 |
26 Feb 07 |
jari |
363 |
val = Integer.parseInt(this.fixedArrowField.getText()); |
2 |
26 Feb 07 |
jari |
364 |
if(val < 15) { |
2 |
26 Feb 07 |
jari |
365 |
JOptionPane.showMessageDialog(this, "The Fixed Arrow Length should be >= 15 pixels. Please try again.", "Invalid Entry", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
366 |
this.fixedArrowField.grabFocus(); |
2 |
26 Feb 07 |
jari |
367 |
this.fixedArrowField.selectAll(); |
2 |
26 Feb 07 |
jari |
368 |
return false; |
2 |
26 Feb 07 |
jari |
369 |
} |
2 |
26 Feb 07 |
jari |
370 |
|
2 |
26 Feb 07 |
jari |
371 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
372 |
JOptionPane.showMessageDialog(this, "The Fixed Arrow Length value format is not a valid entry. Please try again.", "Invalid Entry", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
373 |
this.fixedArrowField.grabFocus(); |
2 |
26 Feb 07 |
jari |
374 |
this.fixedArrowField.selectAll(); |
2 |
26 Feb 07 |
jari |
375 |
return false; |
2 |
26 Feb 07 |
jari |
376 |
} |
2 |
26 Feb 07 |
jari |
377 |
} else { |
2 |
26 Feb 07 |
jari |
378 |
try { |
2 |
26 Feb 07 |
jari |
379 |
val = Integer.parseInt(this.basePairScaleField.getText()); |
2 |
26 Feb 07 |
jari |
380 |
if(val < 1) { |
2 |
26 Feb 07 |
jari |
381 |
JOptionPane.showMessageDialog(this, "The Scaling Factor should be > 1 base/pixel. Please try again.", "Invalid Entry", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
382 |
this.basePairScaleField.grabFocus(); |
2 |
26 Feb 07 |
jari |
383 |
this.basePairScaleField.selectAll(); |
2 |
26 Feb 07 |
jari |
384 |
return false; |
2 |
26 Feb 07 |
jari |
385 |
} |
2 |
26 Feb 07 |
jari |
386 |
level++; |
2 |
26 Feb 07 |
jari |
387 |
minVal = Integer.parseInt(this.minArrowField.getText()); |
2 |
26 Feb 07 |
jari |
388 |
level++; |
2 |
26 Feb 07 |
jari |
389 |
maxVal = Integer.parseInt(this.maxArrowField.getText()); |
2 |
26 Feb 07 |
jari |
390 |
level++; |
2 |
26 Feb 07 |
jari |
391 |
if(minVal < 15 || maxVal < 15 || maxVal <= minVal) { |
2 |
26 Feb 07 |
jari |
392 |
JOptionPane.showMessageDialog(this, "The min and max values are invalid. (Valid Range: 15 <= min < max). Please try again.", "Invalid Entry", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
393 |
return false; |
2 |
26 Feb 07 |
jari |
394 |
} |
2 |
26 Feb 07 |
jari |
395 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
396 |
String fieldName = ""; |
2 |
26 Feb 07 |
jari |
397 |
if(level == 0) { |
2 |
26 Feb 07 |
jari |
398 |
fieldName = "The Scaling Factor "; |
2 |
26 Feb 07 |
jari |
399 |
this.basePairScaleField.grabFocus(); |
2 |
26 Feb 07 |
jari |
400 |
this.basePairScaleField.selectAll(); |
2 |
26 Feb 07 |
jari |
401 |
} else if(level == 1) { |
2 |
26 Feb 07 |
jari |
402 |
fieldName = "The Minium Arrow Length "; |
2 |
26 Feb 07 |
jari |
403 |
this.minArrowField.grabFocus(); |
2 |
26 Feb 07 |
jari |
404 |
this.minArrowField.selectAll(); |
2 |
26 Feb 07 |
jari |
405 |
} else if(level == 2) { |
2 |
26 Feb 07 |
jari |
406 |
fieldName = "The Maximum Arrow Length "; |
2 |
26 Feb 07 |
jari |
407 |
this.maxArrowField.grabFocus(); |
2 |
26 Feb 07 |
jari |
408 |
this.maxArrowField.selectAll(); |
2 |
26 Feb 07 |
jari |
409 |
} |
2 |
26 Feb 07 |
jari |
410 |
JOptionPane.showMessageDialog(this, fieldName+"value format is not a valid entry. Please try again.", "Invalid Entry", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
411 |
return false; |
2 |
26 Feb 07 |
jari |
412 |
} |
2 |
26 Feb 07 |
jari |
413 |
} |
2 |
26 Feb 07 |
jari |
414 |
|
2 |
26 Feb 07 |
jari |
//if intergenic length is not fixed check the max field |
2 |
26 Feb 07 |
jari |
416 |
if(!this.fixedOpenBox.isSelected()) { |
2 |
26 Feb 07 |
jari |
417 |
try { |
2 |
26 Feb 07 |
jari |
418 |
val = Integer.parseInt(this.maxOpenField.getText()); |
2 |
26 Feb 07 |
jari |
419 |
if(val <= 0) { |
2 |
26 Feb 07 |
jari |
420 |
JOptionPane.showMessageDialog(this, "Maximum Intergenic Length must be > 0. Please try again.", "Invalid Entry", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
421 |
return false; |
2 |
26 Feb 07 |
jari |
422 |
} |
2 |
26 Feb 07 |
jari |
423 |
} catch (NumberFormatException nfe) { |
2 |
26 Feb 07 |
jari |
424 |
JOptionPane.showMessageDialog(this, "Maximum Intergenic Length value format is not a valid entry. Please try again.", "Invalid Entry", JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
425 |
this.maxOpenField.grabFocus(); |
2 |
26 Feb 07 |
jari |
426 |
this.maxOpenField.selectAll(); |
2 |
26 Feb 07 |
jari |
427 |
return false; |
2 |
26 Feb 07 |
jari |
428 |
} |
2 |
26 Feb 07 |
jari |
429 |
} |
2 |
26 Feb 07 |
jari |
430 |
|
2 |
26 Feb 07 |
jari |
431 |
return valid; |
2 |
26 Feb 07 |
jari |
432 |
} |
2 |
26 Feb 07 |
jari |
433 |
|
2 |
26 Feb 07 |
jari |
434 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a <code>JCheckBox</code> |
2 |
26 Feb 07 |
jari |
* @param text label |
2 |
26 Feb 07 |
jari |
* @param command action command |
2 |
26 Feb 07 |
jari |
* @param listener Listener |
2 |
26 Feb 07 |
jari |
* @param selected indicates if should be selected |
2 |
26 Feb 07 |
jari |
* @return returns the <code>JCheckBox</code> |
2 |
26 Feb 07 |
jari |
441 |
*/ |
2 |
26 Feb 07 |
jari |
442 |
private JCheckBox createCheckBox(String text, String command, Listener listener, boolean selected) { |
2 |
26 Feb 07 |
jari |
443 |
JCheckBox box = new JCheckBox(text, selected); |
2 |
26 Feb 07 |
jari |
444 |
box.setOpaque(false); |
2 |
26 Feb 07 |
jari |
445 |
box.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
446 |
box.setActionCommand(command); |
2 |
26 Feb 07 |
jari |
447 |
box.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
448 |
return box; |
2 |
26 Feb 07 |
jari |
449 |
} |
2 |
26 Feb 07 |
jari |
450 |
|
2 |
26 Feb 07 |
jari |
451 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a <code>JRadioButton</code> |
2 |
26 Feb 07 |
jari |
* @param text label |
2 |
26 Feb 07 |
jari |
* @param command action command |
2 |
26 Feb 07 |
jari |
* @param listener Listener |
2 |
26 Feb 07 |
jari |
* @param selected indicates if should be selected |
2 |
26 Feb 07 |
jari |
* @return returns the <code>JRadioButton</code> |
2 |
26 Feb 07 |
jari |
458 |
*/ |
2 |
26 Feb 07 |
jari |
459 |
private JRadioButton createRadioButton(String text, String command, Listener listener, boolean selected, ButtonGroup bg) { |
2 |
26 Feb 07 |
jari |
460 |
JRadioButton button = new JRadioButton(text, selected); |
2 |
26 Feb 07 |
jari |
461 |
bg.add(button); |
2 |
26 Feb 07 |
jari |
462 |
button.setOpaque(false); |
2 |
26 Feb 07 |
jari |
463 |
button.setFocusPainted(false); |
2 |
26 Feb 07 |
jari |
464 |
button.setActionCommand(command); |
2 |
26 Feb 07 |
jari |
465 |
button.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
466 |
return button; |
2 |
26 Feb 07 |
jari |
467 |
} |
2 |
26 Feb 07 |
jari |
468 |
|
2 |
26 Feb 07 |
jari |
469 |
/** |
2 |
26 Feb 07 |
jari |
* Validates the values of the controls based on selections |
2 |
26 Feb 07 |
jari |
* enables or disables controls as needed |
2 |
26 Feb 07 |
jari |
472 |
*/ |
2 |
26 Feb 07 |
jari |
473 |
private void validateControls() { |
2 |
26 Feb 07 |
jari |
474 |
boolean showReplicates = showAllReplicates(); |
2 |
26 Feb 07 |
jari |
//if we are showing replicates, fix arrow lenght and open areas |
2 |
26 Feb 07 |
jari |
476 |
if (showReplicates) { |
2 |
26 Feb 07 |
jari |
477 |
this.fixedArrowButton.setSelected(true); |
2 |
26 Feb 07 |
jari |
478 |
this.fixedOpenBox.setSelected(true); |
2 |
26 Feb 07 |
jari |
479 |
} |
2 |
26 Feb 07 |
jari |
480 |
|
2 |
26 Feb 07 |
jari |
481 |
boolean enable = this.fixedArrowButton.isSelected(); |
2 |
26 Feb 07 |
jari |
482 |
this.fixedArrowLabel.setEnabled(enable); |
2 |
26 Feb 07 |
jari |
483 |
this.fixedArrowField.setEnabled(enable); |
2 |
26 Feb 07 |
jari |
484 |
this.minArrowLabel.setEnabled(!enable); |
2 |
26 Feb 07 |
jari |
485 |
this.minArrowField.setEnabled(!enable); |
2 |
26 Feb 07 |
jari |
486 |
this.maxArrowLabel.setEnabled(!enable); |
2 |
26 Feb 07 |
jari |
487 |
this.maxArrowField.setEnabled(!enable); |
2 |
26 Feb 07 |
jari |
488 |
this.basePairScaleLabel.setEnabled(!enable); |
2 |
26 Feb 07 |
jari |
489 |
this.basePairScaleField.setEnabled(!enable); |
2 |
26 Feb 07 |
jari |
490 |
|
2 |
26 Feb 07 |
jari |
491 |
enable = this.fixedOpenBox.isSelected(); |
2 |
26 Feb 07 |
jari |
492 |
this.maxOpenField.setEnabled(!enable); |
2 |
26 Feb 07 |
jari |
493 |
this.maxOpenLabel.setEnabled(!enable); |
2 |
26 Feb 07 |
jari |
494 |
} |
2 |
26 Feb 07 |
jari |
495 |
|
2 |
26 Feb 07 |
jari |
496 |
/** |
2 |
26 Feb 07 |
jari |
* Resets the controls to intial settings |
2 |
26 Feb 07 |
jari |
498 |
*/ |
2 |
26 Feb 07 |
jari |
499 |
private void resetControls() { |
2 |
26 Feb 07 |
jari |
500 |
this.fixedArrowButton.setSelected(this.isFixedArrowLength); |
2 |
26 Feb 07 |
jari |
501 |
this.fixedArrowField.setText(String.valueOf(this.fixedArrowLength)); |
2 |
26 Feb 07 |
jari |
502 |
|
2 |
26 Feb 07 |
jari |
503 |
this.basePairScaleField.setText(String.valueOf(this.bpPerPixel)); |
2 |
26 Feb 07 |
jari |
504 |
this.minArrowField.setText(String.valueOf(this.minArrowLength)); |
2 |
26 Feb 07 |
jari |
505 |
this.maxArrowField.setText(String.valueOf(this.maxArrowLength)); |
2 |
26 Feb 07 |
jari |
506 |
|
2 |
26 Feb 07 |
jari |
507 |
this.fixedOpenBox.setSelected(this.isFixedOpenLength); |
2 |
26 Feb 07 |
jari |
508 |
this.maxOpenField.setText(String.valueOf(this.fixedArrowLength)); |
2 |
26 Feb 07 |
jari |
509 |
|
2 |
26 Feb 07 |
jari |
510 |
this.showReplicatesBox.setSelected(this.showReps); |
2 |
26 Feb 07 |
jari |
511 |
} |
2 |
26 Feb 07 |
jari |
512 |
|
2 |
26 Feb 07 |
jari |
513 |
/** |
2 |
26 Feb 07 |
jari |
* Handles events |
2 |
26 Feb 07 |
jari |
* @author braisted |
2 |
26 Feb 07 |
jari |
516 |
* |
2 |
26 Feb 07 |
jari |
* TODO To change the template for this generated type comment go to |
2 |
26 Feb 07 |
jari |
* Window - Preferences - Java - Code Style - Code Templates |
2 |
26 Feb 07 |
jari |
519 |
*/ |
2 |
26 Feb 07 |
jari |
520 |
public class Listener extends WindowAdapter implements ActionListener { |
2 |
26 Feb 07 |
jari |
521 |
|
2 |
26 Feb 07 |
jari |
522 |
public void actionPerformed(ActionEvent ae) { |
2 |
26 Feb 07 |
jari |
523 |
validateControls(); |
2 |
26 Feb 07 |
jari |
524 |
|
2 |
26 Feb 07 |
jari |
525 |
String command = ae.getActionCommand(); |
2 |
26 Feb 07 |
jari |
526 |
if(command.equals("ok-command")) { |
2 |
26 Feb 07 |
jari |
527 |
previewSettings(); |
2 |
26 Feb 07 |
jari |
528 |
dispose(); |
2 |
26 Feb 07 |
jari |
529 |
} else if(command.equals("reset-command")) { |
2 |
26 Feb 07 |
jari |
//roll back controls |
2 |
26 Feb 07 |
jari |
531 |
resetControls(); |
2 |
26 Feb 07 |
jari |
//roll back viewer |
2 |
26 Feb 07 |
jari |
533 |
previewSettings(); |
2 |
26 Feb 07 |
jari |
534 |
} else if(command.equals("preview-command")) { |
2 |
26 Feb 07 |
jari |
535 |
previewSettings(); |
2 |
26 Feb 07 |
jari |
536 |
} else if(command.equals("cancel-command")) { |
2 |
26 Feb 07 |
jari |
537 |
resetControls(); |
2 |
26 Feb 07 |
jari |
538 |
previewSettings(); |
2 |
26 Feb 07 |
jari |
539 |
dispose(); |
2 |
26 Feb 07 |
jari |
540 |
} else if(command.equals("info-command")) { |
2 |
26 Feb 07 |
jari |
541 |
HelpWindow hw = new HelpWindow(LEMViewerAttributeDialog.this, "LEM Customization Dialog"); |
2 |
26 Feb 07 |
jari |
542 |
if(hw.getWindowContent()){ |
2 |
26 Feb 07 |
jari |
543 |
hw.setSize(450,600); |
2 |
26 Feb 07 |
jari |
544 |
hw.setLocation(); |
2 |
26 Feb 07 |
jari |
545 |
hw.show(); |
2 |
26 Feb 07 |
jari |
546 |
} |
2 |
26 Feb 07 |
jari |
547 |
else { |
2 |
26 Feb 07 |
jari |
548 |
hw.setVisible(false); |
2 |
26 Feb 07 |
jari |
549 |
hw.dispose(); |
2 |
26 Feb 07 |
jari |
550 |
} |
2 |
26 Feb 07 |
jari |
551 |
} |
2 |
26 Feb 07 |
jari |
552 |
} |
2 |
26 Feb 07 |
jari |
553 |
|
2 |
26 Feb 07 |
jari |
554 |
public void windowClosed(WindowEvent we) { |
2 |
26 Feb 07 |
jari |
555 |
resetControls(); |
2 |
26 Feb 07 |
jari |
556 |
previewSettings(); |
2 |
26 Feb 07 |
jari |
557 |
dispose(); |
2 |
26 Feb 07 |
jari |
558 |
} |
2 |
26 Feb 07 |
jari |
559 |
} |
2 |
26 Feb 07 |
jari |
560 |
|
2 |
26 Feb 07 |
jari |
561 |
} |