-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathLowOptionDialog.java
112 lines (94 loc) · 2.9 KB
/
LowOptionDialog.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
public class LowOptionDialog extends FilterDialog {
private final LowOptionDialog thisDialog = this;
private double freq;
private boolean retVal = false;
public LowOptionDialog(final JFrame thisFrame,
String title,
boolean modal,
final ECGViewHandler handler,
final int index) {
super(thisFrame, title, modal, handler, index, 2);
freq = 40;
this.setLayout(new BorderLayout());
final ECGView[] preview = new ECGView[]{handler.shallowFilter(index,
id,
new Number[]{40.0},
true)};
JPanel controls = new JPanel(new GridBagLayout());
GridBagConstraints labels = new GridBagConstraints();
labels.gridwidth = 6;
labels.ipadx = 10;
labels.anchor = GridBagConstraints.LINE_END;
labels.gridx = 0;
labels.gridy = 0;
GridBagConstraints slider = new GridBagConstraints();
slider.gridwidth = 6;
slider.gridx = 7;
slider.gridy = 0;
this.setBounds(thisFrame.getX(), thisFrame.getY(), 500, 400);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
e.getWindow().dispose();
}
});
controls.add(new JLabel("Frequency Threshold"), labels);
final TextSlide leftSlide = new TextSlide(30, 70, 40, 2);
leftSlide.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
preview[0].filter(id, new Number[]{(double)leftSlide.getValue()});
preview[0].revalidate();
}
});
controls.add(leftSlide, slider);
final JButton accept = new JButton("OK");
final JButton cancel = new JButton("Cancel");
accept.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
accept.setEnabled(false);
cancel.setEnabled(false);
freq = (double)leftSlide.getValue();
thisFrame.revalidate();
thisDialog.dispose();
retVal = true;
}
});
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisDialog.dispose();
}
});
labels.gridy = 1;
labels.anchor = GridBagConstraints.CENTER;
controls.add(cancel, labels);
slider.gridy = 1;
controls.add(accept, slider);
this.add(controls, BorderLayout.NORTH);
this.add(preview[0].getPanel(), BorderLayout.CENTER);
this.setSize(650,650);
this.setVisible(true);
}
public int Id() {
return id;
}
public boolean accepted() {
return retVal;
}
public Number[] returnVals() {
return new Number[]{freq};
}
}