-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathChartFrame.java
More file actions
695 lines (652 loc) · 22.9 KB
/
ChartFrame.java
File metadata and controls
695 lines (652 loc) · 22.9 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.net.URL;
import java.text.NumberFormat;
import java.util.EmptyStackException;
import javax.swing.ButtonGroup;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JDialog;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSlider;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.JOptionPane;
import org.jfree.chart.plot.XYPlot;
/**
* class ChartFrame - creates a simple frame for displaying one chart in detail
*
* @author Dakota Williams
*/
public class ChartFrame extends JFrame {
private ECGViewHandler handler;
private ECGView view;
private int index;
private final JFormattedTextField startText
= new JFormattedTextField(NumberFormat.getIntegerInstance());
private final JFormattedTextField lenText
= new JFormattedTextField(NumberFormat.getIntegerInstance());
private final JCheckBoxMenuItem file_badlead;
private final ChartFrame thisFrame = this;
private final JCheckBoxMenuItem anno_enable;
private final JCheckBoxMenuItem anno_remove;
private final JToggleButton placeAnnoButton;
private final JToggleButton removeAnnoButton;
/**
* Constructor - creates the frame and everything in it
*
* @param handler the viewhandler to use
* @param index the view to display
* @param title the title of the frame
*/
public ChartFrame(final ECGViewHandler handler, int index, String title) {
super(title);
setBounds(0, 0, 650, 650);
setLayout(new BorderLayout());
this.handler = handler;
this.index = index;
view = handler.getView(index, true);
//start with the menu bar
JMenuBar menu = new JMenuBar();
//dataset menu
JMenu file = new JMenu("Dataset");
file_badlead = new JCheckBoxMenuItem("Bad Lead");
file_badlead.setState(view.isBad());
file_badlead.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisFrame.view.setBackground(thisFrame.view.isBad() ?
UIManager.getColor("Panel.background") :
new Color(233, 174, 174));
thisFrame.revalidate();
thisFrame.view.setBad(!view.isBad());
file_badlead.setState(view.isBad());
}
});
file.add(file_badlead);
JMenuItem file_exit = new JMenuItem("Exit");
file_exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisFrame.setVisible(false);
thisFrame.dispose();
}
});
file.add(file_exit);
menu.add(file);
//edit menu
JMenu edit = new JMenu("Edit");
final JMenuItem edit_undo = new JMenuItem("Undo");
edit_undo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handler.undo();
thisFrame.view.update();
thisFrame.view.redrawAnnotations();
}
});
final JMenuItem edit_redo = new JMenuItem("Redo");
edit_redo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handler.redo();
thisFrame.view.update();
thisFrame.view.redrawAnnotations();
}
});
edit.addMenuListener(new MenuListener() {
public void menuSelected(MenuEvent e) {
edit_undo.setEnabled(handler.canUndo());
edit_undo.setText("Undo " + (handler.canUndo()?handler.undoMessage():""));
edit_redo.setEnabled(handler.canRedo());
edit_redo.setText("Redo " + (handler.canRedo()?handler.redoMessage():""));
}
//don't care
public void menuDeselected(MenuEvent e) {}
public void menuCanceled(MenuEvent e) {}
});
edit.add(edit_undo);
edit.add(edit_redo);
menu.add(edit);
//filter menu
JMenu filter = new JMenu("Filter");
JMenuItem filter_detrend = new JMenuItem("Polynomial Detrend");
filter_detrend.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DetrendOptionDialog dialog = new DetrendOptionDialog(thisFrame,
"Polynomial Detrend",
true,
thisFrame.handler,
thisFrame.index);
if(dialog.accepted()) {
handler.applyFilter(dialog, thisFrame.index);
}
thisFrame.view.revalidate();
}
});
JMenuItem filter_harmonic = new JMenuItem("Harmonic Detrend");
filter_harmonic.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
HarmonicDetrendDialog dialog = new HarmonicDetrendDialog(thisFrame,
"Harmonic Detrend",
true,
thisFrame.handler,
thisFrame.index);
if(dialog.accepted()) {
handler.applyFilter(dialog, thisFrame.index);
}
thisFrame.view.revalidate();
}
});
JMenuItem filter_median = new JMenuItem("Median Offset");
filter_median.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MedianOffsetDialog dialog = new MedianOffsetDialog(thisFrame,
"Median Offset",
true,
thisFrame.handler,
thisFrame.index);
if(dialog.accepted()) {
handler.applyFilter(dialog, thisFrame.index);
}
thisFrame.view.revalidate();
}
});
JMenuItem filter_savitzky = new JMenuItem("Savitzky-Golay");
filter_savitzky.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SGOptionDialog dialog = new SGOptionDialog(thisFrame,
"Savitzky-Golay Filter",
true,
thisFrame.handler,
thisFrame.index);
if(dialog.accepted()) {
handler.applyFilter(dialog, thisFrame.index);
}
thisFrame.view.revalidate();
}
});
JMenuItem filter_high = new JMenuItem("High Pass");
filter_high.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
HighOptionDialog dialog = new HighOptionDialog(thisFrame,
"High Pass Filter",
true,
thisFrame.handler,
thisFrame.index);
if(dialog.accepted()) {
handler.applyFilter(dialog, thisFrame.index);
}
thisFrame.view.revalidate();
}
});
JMenuItem filter_ffthigh = new JMenuItem("FFT High Pass");
filter_ffthigh.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
FFTOptionDialog dialog = new FFTOptionDialog(thisFrame,
"FFT High Pass Filter",
true,
thisFrame.handler,
thisFrame.index);
if(dialog.accepted()) {
handler.applyFilter(dialog, thisFrame.index);
}
thisFrame.view.revalidate();
}
});
JMenuItem filter_low = new JMenuItem("Low Pass");
filter_low.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
LowOptionDialog dialog = new LowOptionDialog(thisFrame,
"Low Pass Filter",
true,
thisFrame.handler,
thisFrame.index);
if(dialog.accepted()) {
handler.applyFilter(dialog, thisFrame.index);
}
thisFrame.view.revalidate();
}
});
JMenuItem filter_wave = new JMenuItem("Wavelet");
filter_wave.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
WaveletOptionDialog dialog = new WaveletOptionDialog(thisFrame,
"Wavelet Filter",
true,
thisFrame.handler,
thisFrame.index);
if(dialog.accepted()) {
handler.applyFilter(dialog, thisFrame.index);
}
thisFrame.view.revalidate();
}
});
JMenuItem filter_constant = new JMenuItem("Constant Offset");
filter_constant.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ConstantOptionDialog dialog = new ConstantOptionDialog(thisFrame,
"Constant Offset",
true,
thisFrame.handler,
thisFrame.index);
if(dialog.accepted()) {
handler.applyFilter(dialog, thisFrame.index);
}
thisFrame.view.revalidate();
}
});
JMenuItem filter_butter = new JMenuItem("Butterworth");
filter_butter.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ButterOptionDialog dialog = new ButterOptionDialog(thisFrame,
"Butterworth",
true,
thisFrame.handler,
thisFrame.index);
if(dialog.accepted()) {
handler.applyFilter(dialog, thisFrame.index);
}
thisFrame.view.revalidate();
}
});
filter.add(filter_detrend);
filter.add(filter_harmonic);
filter.add(filter_constant);
filter.add(filter_median);
filter.addSeparator();
filter.add(filter_savitzky);
filter.add(filter_high);
filter.add(filter_ffthigh);
filter.add(filter_low);
filter.add(filter_wave);
filter.add(filter_butter);
menu.add(filter);
placeAnnoButton = new JToggleButton();
placeAnnoButton.setSelected(false);
removeAnnoButton = new JToggleButton();
removeAnnoButton.setSelected(false);
//annotation menu
JMenu annotations = new JMenu("Annotation");
anno_enable = new JCheckBoxMenuItem("Place Annotations");
anno_enable.setState(false);
anno_enable.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisFrame.view.setCanRemove(false);
thisFrame.view.setCanPlace(anno_enable.getState());
placeAnnoButton.setSelected(anno_enable.getState());
removeAnnoButton.setSelected(false);
anno_remove.setState(false);
}
});
anno_remove = new JCheckBoxMenuItem("Remove Annotations");
anno_remove.setState(false);
anno_remove.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisFrame.view.setCanPlace(false);
thisFrame.view.setCanRemove(anno_enable.getState());
removeAnnoButton.setSelected(anno_enable.getState());
anno_enable.setState(false);
placeAnnoButton.setSelected(false);
}
});
JMenuItem annotations_clear = new JMenuItem("Clear");
annotations_clear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisFrame.view.clearAnnotations();
}
});
JMenuItem annotations_auto = new JMenuItem("Find R-Waves");
annotations_auto.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisFrame.handler.extractFeatures(thisFrame.index);
thisFrame.view.redrawAnnotations();
thisFrame.view.revalidate();
}
});
annotations.add(anno_enable);
annotations.add(anno_remove);
annotations.add(annotations_clear);
annotations.add(annotations_auto);
annotations.addSeparator();
ButtonGroup annoGroup = new ButtonGroup();
JRadioButtonMenuItem[] annotations_colors = new JRadioButtonMenuItem[Settings.numAnnoTypes()];
for(int i = 0; i < annotations_colors.length; i++) {
final int count = i;
annotations_colors[i] = new JRadioButtonMenuItem("Annotation " + (i+1)
+ " (" + Settings.getAnnotationTitle(i) + ")",
Settings.getSelectedAnnotationType()==i);
annotations_colors[i].addActionListener(new ActionListener() {
private final int changeNum = count;
public void actionPerformed(ActionEvent e) {
Settings.setSelectedAnnotationType(changeNum);
}
});
annotations.add(annotations_colors[i]);
annoGroup.add(annotations_colors[i]);
}
menu.add(annotations);
setJMenuBar(menu);
// Toolbar
JToolBar toolbar = new JToolBar("Main");
toolbar.setFloatable(false);
JButton undoButton = makeToolbarButton("Undo24", "Undo");
undoButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
handler.undo();
} catch (EmptyStackException ex) {
JOptionPane.showMessageDialog(null,
"Nothing to undo!",
"Error",
JOptionPane.ERROR_MESSAGE);
}
thisFrame.view.update();
thisFrame.view.redrawAnnotations();
}
});
toolbar.add(undoButton);
JButton redoButton = makeToolbarButton("Redo24", "Redo");
redoButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handler.redo();
thisFrame.view.update();
thisFrame.view.redrawAnnotations();
}
});
toolbar.add(redoButton);
toolbar.addSeparator();
ChartFrame.class.getResource("imgs/toolbarButtonGraphics/general/Bookmarks24.gif");
placeAnnoButton.setToolTipText("Toggle Place Annotation");
placeAnnoButton.setIcon(
new ImageIcon("imgs/toolbarButtonGraphics/general/Bookmarks24.gif",
"Toggle Place Annotation"));
placeAnnoButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisFrame.view.setCanRemove(false);
thisFrame.view.setCanPlace(placeAnnoButton.isSelected());
anno_enable.setState(placeAnnoButton.isSelected());
removeAnnoButton.setSelected(false);
anno_remove.setState(false);
}
});
toolbar.add(placeAnnoButton);
ChartFrame.class.getResource("imgs/toolbarButtonGraphics/general/Remove24.gif");
removeAnnoButton.setToolTipText("Toggle Remove Annotation");
removeAnnoButton.setIcon(
new ImageIcon("imgs/toolbarButtonGraphics/general/Remove24.gif",
"Toggle Remove Annotation"));
removeAnnoButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisFrame.view.setCanPlace(false);
thisFrame.view.setCanRemove(removeAnnoButton.isSelected());
anno_remove.setState(removeAnnoButton.isSelected());
anno_enable.setState(false);
placeAnnoButton.setSelected(false);
}
});
toolbar.add(removeAnnoButton);
add(toolbar, BorderLayout.PAGE_START);
// end toolbar
//add the specified view to the frame
add(thisFrame.view.getPanel(), BorderLayout.CENTER);
JPanel statusBar = new JPanel();
JLabel startLabel = new JLabel("Start offset (ms):");
startText.setValue(0L);
startText.setColumns(10);
startText.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
long start = (Long)startText.getValue();
long len = (Long)lenText.getValue();
thisFrame.view.setViewingDomain(start, start+len);
}
});
JLabel lenLabel = new JLabel("Length (ms):");
lenText.setValue(0L);
lenText.setColumns(10);
lenText.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
long start = (Long)startText.getValue();
long len = (Long)lenText.getValue();
thisFrame.view.setViewingDomain(start, start+len);
}
});
statusBar.add(startLabel);
statusBar.add(startText);
statusBar.add(lenLabel);
statusBar.add(lenText);
lenText.setValue(thisFrame.handler.leadSize(index)*thisFrame.handler.getSampleInterval());
add(statusBar, BorderLayout.SOUTH);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setVisible(true);
}
/**
* Constructor - frame that views a composite view
*
* @param handler the viewhandler to use
*/
public ChartFrame(final ECGViewHandler handler) {
super("Composite");
setBounds(0, 0, 500, 500);
setLayout(new BorderLayout());
this.handler = handler;
this.index = 0;
view = handler.getCompositeView(true);
//start with the menu bar
JMenuBar menu = new JMenuBar();
//dataset menu
JMenu file = new JMenu("Dataset");
file_badlead = new JCheckBoxMenuItem("Bad Lead");
file_badlead.setState(false);
JMenuItem file_exit = new JMenuItem("Exit");
file_exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisFrame.setVisible(false);
thisFrame.dispose();
}
});
file.add(file_exit);
menu.add(file);
//edit menu
JMenu edit = new JMenu("Edit");
final JMenuItem edit_undo = new JMenuItem("Undo");
edit_undo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handler.undo();
thisFrame.view.redrawAnnotations();
}
});
final JMenuItem edit_redo = new JMenuItem("Redo");
edit_redo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handler.redo();
thisFrame.view.redrawAnnotations();
}
});
edit.addMenuListener(new MenuListener() {
public void menuSelected(MenuEvent e) {
edit_undo.setEnabled(handler.canUndo());
edit_undo.setText("Undo " + (handler.canUndo()?handler.undoMessage():""));
edit_redo.setEnabled(handler.canRedo());
edit_redo.setText("Redo " + (handler.canRedo()?handler.redoMessage():""));
}
//don't care
public void menuDeselected(MenuEvent e) {}
public void menuCanceled(MenuEvent e) {}
});
edit.add(edit_undo);
edit.add(edit_redo);
menu.add(edit);
placeAnnoButton = new JToggleButton();
placeAnnoButton.setSelected(false);
removeAnnoButton = new JToggleButton();
removeAnnoButton.setSelected(false);
//annotation menu
JMenu annotations = new JMenu("Annotation");
anno_enable = new JCheckBoxMenuItem("Place Annotations");
anno_enable.setState(false);
anno_enable.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisFrame.view.setCanRemove(false);
thisFrame.view.setCanPlace(anno_enable.getState());
placeAnnoButton.setSelected(anno_enable.getState());
removeAnnoButton.setSelected(false);
anno_remove.setState(false);
}
});
anno_remove = new JCheckBoxMenuItem("Remove Annotations");
anno_remove.setState(false);
anno_remove.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisFrame.view.setCanPlace(false);
thisFrame.view.setCanRemove(anno_enable.getState());
removeAnnoButton.setSelected(anno_enable.getState());
anno_enable.setState(false);
placeAnnoButton.setSelected(false);
}
});
JMenuItem annotations_clear = new JMenuItem("Clear");
annotations_clear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisFrame.view.clearAnnotations();
}
});
JMenuItem annotations_auto = new JMenuItem("Find R-Waves");
annotations_auto.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisFrame.handler.extractFeatures(thisFrame.index);
thisFrame.view.redrawAnnotations();
}
});
annotations.add(anno_enable);
annotations.add(anno_remove);
annotations.add(annotations_clear);
annotations.add(annotations_auto);
annotations.addSeparator();
ButtonGroup annoGroup = new ButtonGroup();
JRadioButtonMenuItem[] annotations_colors = new JRadioButtonMenuItem[Settings.numAnnoTypes()];
for(int i = 0; i < annotations_colors.length; i++) {
final int count = i;
annotations_colors[i] = new JRadioButtonMenuItem("Annotation " + (i+1)
+ " (" + Settings.getAnnotationTitle(i) + ")",
Settings.getSelectedAnnotationType()==i);
annotations_colors[i].addActionListener(new ActionListener() {
private final int changeNum = count;
public void actionPerformed(ActionEvent e) {
Settings.setSelectedAnnotationType(changeNum);
}
});
annotations.add(annotations_colors[i]);
annoGroup.add(annotations_colors[i]);
}
menu.add(annotations);
setJMenuBar(menu);
// Toolbar
JToolBar toolbar = new JToolBar("Main");
toolbar.setFloatable(false);
JButton undoButton = makeToolbarButton("Undo24", "Undo");
undoButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handler.undo();
thisFrame.view.redrawAnnotations();
}
});
toolbar.add(undoButton);
JButton redoButton = makeToolbarButton("Redo24", "Redo");
redoButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
handler.redo();
thisFrame.view.redrawAnnotations();
}
});
toolbar.add(redoButton);
toolbar.addSeparator();
ChartFrame.class.getResource("imgs/toolbarButtonGraphics/general/Bookmarks24.gif");
placeAnnoButton.setToolTipText("Toggle Place Annotation");
placeAnnoButton.setIcon(
new ImageIcon("imgs/toolbarButtonGraphics/general/Bookmarks24.gif",
"Toggle Place Annotation"));
placeAnnoButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisFrame.view.setCanRemove(false);
thisFrame.view.setCanPlace(placeAnnoButton.isSelected());
anno_enable.setState(placeAnnoButton.isSelected());
removeAnnoButton.setSelected(false);
anno_remove.setState(false);
}
});
toolbar.add(placeAnnoButton);
ChartFrame.class.getResource("imgs/toolbarButtonGraphics/general/Remove24.gif");
removeAnnoButton.setToolTipText("Toggle Remove Annotation");
removeAnnoButton.setIcon(
new ImageIcon("imgs/toolbarButtonGraphics/general/Remove24.gif",
"Toggle Remove Annotation"));
removeAnnoButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
thisFrame.view.setCanPlace(false);
thisFrame.view.setCanRemove(removeAnnoButton.isSelected());
anno_remove.setState(removeAnnoButton.isSelected());
anno_enable.setState(false);
placeAnnoButton.setSelected(false);
}
});
toolbar.add(removeAnnoButton);
add(toolbar, BorderLayout.PAGE_START);
// end toolbar
//add the specified view to the frame
add(thisFrame.view.getPanel(), BorderLayout.CENTER);
JPanel statusBar = new JPanel();
JLabel startLabel = new JLabel("Start offset (ms):");
startText.setValue(0L);
startText.setColumns(10);
startText.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
long start = (Long)startText.getValue();
long len = (Long)lenText.getValue();
thisFrame.view.setViewingDomain(start, start+len);
}
});
JLabel lenLabel = new JLabel("Length (ms):");
lenText.setValue(0L);
lenText.setColumns(10);
lenText.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
long start = (Long)startText.getValue();
long len = (Long)lenText.getValue();
thisFrame.view.setViewingDomain(start, start+len);
}
});
statusBar.add(startLabel);
statusBar.add(startText);
statusBar.add(lenLabel);
statusBar.add(lenText);
lenText.setValue(thisFrame.handler.leadSize(index)*thisFrame.handler.getSampleInterval());
add(statusBar, BorderLayout.SOUTH);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setVisible(true);
}
private JButton makeToolbarButton(String imgName, String toolTip) {
String imgLoc = "imgs/toolbarButtonGraphics/general/" + imgName + ".gif";
URL imageURL = ChartFrame.class.getResource(imgLoc);
JButton button = new JButton();
button.setToolTipText(toolTip);
button.setIcon(new ImageIcon(imageURL, toolTip));
return button;
}
}