/Users/lyon/j4p/src/sound/filterDesign/ParamFrame.java
|
1 package sound.filterDesign;
2
3 // Decompiled by Jad v1.5.8c. Copyright 2001 Pavel Kouznetsov.
4 // Jad home page: http://www.geocities.com/kpdus/jad.html
5 // Decompiler options: packimports(3)
6 // Source File Name: ParamFrame.java
7
8 import java.awt.*;
9 import java.awt.event.ActionEvent;
10 import java.awt.event.ActionListener;
11 import java.awt.event.WindowAdapter;
12 import java.awt.event.WindowEvent;
13 import java.util.Vector;
14
15 public class ParamFrame extends Frame
16 implements ActionListener {
17
18 public ParamFrame(PlotCanvasBean plotcanvasbean) {
19 super("Set Parameters");
20 setSize(500, 200);
21 setResizable(false);
22 setVisible(false);
23 plotCanvas = plotcanvasbean;
24 setLayout(new GridBagLayout());
25 GridBagConstraints gridbagconstraints = new GridBagConstraints();
26 xMin = new Label("Min frequency ", 2);
27 xMax = new Label("Max frequency ", 2);
28 yMagMin = new Label("Min Magnitude ", 2);
29 yMagMax = new Label("Max Magnitude ", 2);
30 yPhaMin = new Label("Min Phase ", 2);
31 yPhaMax = new Label("Max Phase ", 2);
32 precise = new Label("Precision (1-300) ", 2);
33 gain = new Label("Gain ", 2);
34 error =
35 new Label(
36 "There are no errors for now but it could happen !!!",
37 1);
38 minFreq = new TextField(5);
39 maxFreq = new TextField(5);
40 minMag = new TextField(5);
41 maxMag = new TextField(5);
42 minPhase = new TextField(5);
43 maxPhase = new TextField(5);
44 precision = new TextField(5);
45 gainField = new TextField(5);
46 okButton = new Button("OK");
47 cancelButton = new Button("Cancel");
48 Panel panel = new Panel();
49 panel.setLayout(new GridLayout(4, 4));
50 panel.add(xMin);
51 panel.add(minFreq);
52 panel.add(xMax);
53 panel.add(maxFreq);
54 panel.add(yMagMin);
55 panel.add(minMag);
56 panel.add(yMagMax);
57 panel.add(maxMag);
58 panel.add(yPhaMin);
59 panel.add(minPhase);
60 panel.add(yPhaMax);
61 panel.add(maxPhase);
62 panel.add(precise);
63 panel.add(precision);
64 panel.add(gain);
65 panel.add(gainField);
66 gridbagconstraints.gridy = 0;
67 add(panel, gridbagconstraints);
68 Panel panel1 = new Panel();
69 panel1.add(okButton);
70 panel1.add(cancelButton);
71 gridbagconstraints.gridy = 1;
72 add(error, gridbagconstraints);
73 gridbagconstraints.gridy = 2;
74 add(panel1, gridbagconstraints);
75 validate();
76 okButton.addActionListener(this);
77 cancelButton.addActionListener(this);
78 minFreq.addActionListener(this);
79 maxFreq.addActionListener(this);
80 minMag.addActionListener(this);
81 maxMag.addActionListener(this);
82 minPhase.addActionListener(this);
83 maxPhase.addActionListener(this);
84 precision.addActionListener(this);
85 gainField.addActionListener(this);
86 addWindowListener(new WindowAdapter() {
87
88 public void windowClosing(WindowEvent windowevent) {
89 setVisible(false);
90 }
91
92 });
93 error.setText("");
94 }
95
96 public void wake() {
97 para = plotCanvas.oldParams();
98 x1 = ((Double) para.elementAt(0)).doubleValue();
99 x2 = ((Double) para.elementAt(1)).doubleValue();
100 y1 = ((Double) para.elementAt(2)).doubleValue();
101 y2 = ((Double) para.elementAt(3)).doubleValue();
102 y3 = ((Double) para.elementAt(4)).doubleValue();
103 y4 = ((Double) para.elementAt(5)).doubleValue();
104 p = ((Integer) para.elementAt(6)).intValue();
105 g = ((Double) para.elementAt(7)).doubleValue();
106 minFreq.setText(String.valueOf(x1));
107 maxFreq.setText(String.valueOf(x2));
108 minMag.setText(String.valueOf(y1));
109 maxMag.setText(String.valueOf(y2));
110 minPhase.setText(String.valueOf(y3));
111 maxPhase.setText(String.valueOf(y4));
112 precision.setText(String.valueOf(p));
113 gainField.setText(String.valueOf(g));
114 error.setText(
115 "Still a big long enormous string, just because things are strange in this world");
116 setVisible(true);
117 error.setText("");
118 }
119
120 public void actionPerformed(ActionEvent actionevent) {
121 Object obj = actionevent.getSource();
122 if (obj == cancelButton) {
123 setVisible(false);
124 return;
125 }
126 try {
127 x1 = (new Double(minFreq.getText())).doubleValue();
128 x2 = (new Double(maxFreq.getText())).doubleValue();
129 y1 = (new Double(minMag.getText())).doubleValue();
130 y2 = (new Double(maxMag.getText())).doubleValue();
131 y3 = (new Double(minPhase.getText())).doubleValue();
132 y4 = (new Double(maxPhase.getText())).doubleValue();
133 p = (new Integer(precision.getText())).intValue();
134 g = (new Double(gainField.getText())).doubleValue();
135 if (x1 >= x2 ||
136 y1 >= y2 ||
137 y3 >= y4 ||
138 p < 1 ||
139 p > 300 ||
140 x1 < 0.0D ||
141 x2 < 0.0D) {
142 throw new MyException("Please, insert correct values !!!");
143 } else {
144 para = new Vector();
145 para.addElement(new Double(x1));
146 para.addElement(new Double(x2));
147 para.addElement(new Double(y1));
148 para.addElement(new Double(y2));
149 para.addElement(new Double(y3));
150 para.addElement(new Double(y4));
151 para.addElement(new Integer(p));
152 para.addElement(new Double(g));
153 error.setText("");
154 plotCanvas.newParams(para);
155 setVisible(false);
156 return;
157 }
158 } catch (MyException myexception) {
159 error.setText(myexception.getMessage());
160 return;
161 } catch (NumberFormatException _ex) {
162 error.setText(
163 "A number is something with digits (0..9), thanks.");
164 }
165 }
166
167 double x1;
168 double x2;
169 double y1;
170 double y2;
171 double y3;
172 double y4;
173 double g;
174 int p;
175 Label xMin;
176 Label xMax;
177 Label yMagMin;
178 Label yMagMax;
179 Label yPhaMin;
180 Label yPhaMax;
181 Label precise;
182 Label gain;
183 Label error;
184 TextField minFreq;
185 TextField maxFreq;
186 TextField minMag;
187 TextField maxMag;
188 TextField minPhase;
189 TextField maxPhase;
190 TextField precision;
191 TextField gainField;
192 Button okButton;
193 Button cancelButton;
194 PlotCanvasBean plotCanvas;
195 Vector para;
196 }
197