-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMedianOffsetDialog.java
More file actions
124 lines (107 loc) · 3.07 KB
/
Copy pathMedianOffsetDialog.java
File metadata and controls
124 lines (107 loc) · 3.07 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
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 MedianOffsetDialog - creates a dialog that displays the output of a median offset
*
* @author Dakota Williams
*/
public class MedianOffsetDialog extends FilterDialog {
private final MedianOffsetDialog 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 MedianOffsetDialog(final JFrame thisFrame,
String title,
boolean modal,
final ECGViewHandler handler,
final int index) {
super(thisFrame, title, modal, handler, index, 9);
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 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);
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[]{};
}
}