-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathDetrendOptionDialog.java
More file actions
137 lines (118 loc) · 3.51 KB
/
Copy pathDetrendOptionDialog.java
File metadata and controls
137 lines (118 loc) · 3.51 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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;
/**
* class DetrendOptionDialog - creates a dialog that provides options for
* detrending data
*
* @author Dakota Williams
*/
public class DetrendOptionDialog extends FilterDialog {
private final DetrendOptionDialog thisDialog = this;
private int degree;
private boolean retVal = false;
/**
* Constructor - creates the dialog
*
* @param thisFrame the parent frame
* @param title the title of the dialog
* @param modal whether the dialog should be modal
* @param view the view to display in the dialog (preview)
*/
public DetrendOptionDialog(final JFrame thisFrame,
String title,
boolean modal,
final ECGViewHandler handler,
final int index) {
super(thisFrame, title, modal, handler, index, 4);
degree = 6;
this.setLayout(new BorderLayout());
final ECGView[] preview = new ECGView[]{handler.shallowFilter(index,
id,
new Number[]{6},
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 = 5;
slider.gridx = 6;
slider.gridy = 0;
this.setBounds(thisFrame.getX(), thisFrame.getY(), 500, 400);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
e.getWindow().dispose();
}
});
final TextSlide degreeSlide = new TextSlide(0, 20, 6, 0);
controls.add(new JLabel("Degree of Fitting Polynomial"), labels);
degreeSlide.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
preview[0].filter(id, new Number[]{degreeSlide.getValue().intValue()});
preview[0].revalidate();
}
});
controls.add(degreeSlide, 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);
degree = degreeSlide.getValue().intValue();
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;
}
/**
* accepted - whether the user clicked ok
*
* @return true if ok
*/
public boolean accepted() {
return retVal;
}
/**
* returnVals - returns the data gathered from the dialog
*
* @return an array of the data gathered from the dialog
*/
public Number[] returnVals() {
return new Number[]{degree};
}
}