forked from tekrei/JavaExamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelectPanel.java
More file actions
132 lines (112 loc) · 4.17 KB
/
Copy pathSelectPanel.java
File metadata and controls
132 lines (112 loc) · 4.17 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
package jdip;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImageOp;
class SelectPanel extends JPanel {
private static final long serialVersionUID = 1L;
private final MainWindow mainWindow;
private JButton btnFilter = null;
private JComboBox<BufferedImageOp> cmbFilters;
private JButton btnLoadFile = null;
private JFileChooser fileChooser = null;
private JButton btnExit = null;
private JComboBox<BufferedImageOp> cmbMorph;
private JButton btnMorph = null;
private JComboBox<BufferedImageOp> cmbTransform;
private JButton btnTransform = null;
SelectPanel(MainWindow _mainWindow) {
super();
mainWindow = _mainWindow;
initialize();
}
private void initialize() {
this.setSize(200, 308);
this.setLayout(null);
this.add(getCmbFilters());
this.add(getBtnFilter());
this.add(getBtnLoadFile(), null);
this.add(getBtnExit(), null);
this.add(getCmbMorph(), null);
this.add(getBtnMorph(), null);
this.add(getCmbTransform(), null);
this.add(getBtnTransform(), null);
}
private JButton getBtnFilter() {
if (btnFilter == null) {
btnFilter = new JButton();
btnFilter.setText("Apply Filter");
btnFilter.setBounds(0, 50, 191, 21);
btnFilter.setMnemonic('f');
btnFilter.addActionListener(e -> mainWindow.doOperation(cmbFilters.getItemAt(cmbFilters.getSelectedIndex())));
}
return btnFilter;
}
private JComboBox<BufferedImageOp> getCmbFilters() {
if (cmbFilters == null) {
cmbFilters = new JComboBox<>(ImageProcessing.getFilters());
cmbFilters.setBounds(0, 30, 191, 21);
}
return cmbFilters;
}
private JButton getBtnLoadFile() {
if (btnLoadFile == null) {
btnLoadFile = new JButton();
btnLoadFile.setBounds(new Rectangle(0, 0, 191, 31));
btnLoadFile.setText("Load Image");
btnLoadFile.setMnemonic('l');
btnLoadFile.addActionListener(e -> {
fileChooser = new JFileChooser();
if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
mainWindow.loadImage(fileChooser.getSelectedFile()
.getPath());
}
});
}
return btnLoadFile;
}
private JButton getBtnExit() {
if (btnExit == null) {
btnExit = new JButton();
btnExit.setBounds(new Rectangle(0, 280, 191, 31));
btnExit.setText("Exit");
btnExit.setMnemonic('e');
btnExit.addActionListener(e -> System.exit(0));
}
return btnExit;
}
private JComboBox<BufferedImageOp> getCmbMorph() {
if (cmbMorph == null) {
cmbMorph = new JComboBox<>(ImageProcessing.getMorphs());
cmbMorph.setBounds(new Rectangle(0, 80, 191, 21));
}
return cmbMorph;
}
private JButton getBtnMorph() {
if (btnMorph == null) {
btnMorph = new JButton();
btnMorph.setBounds(new Rectangle(0, 100, 191, 21));
btnMorph.setText("Apply Morph");
btnMorph.setMnemonic('m');
btnMorph.addActionListener(e -> mainWindow.doOperation(cmbMorph.getItemAt(cmbMorph.getSelectedIndex())));
}
return btnMorph;
}
private JComboBox<BufferedImageOp> getCmbTransform() {
if (cmbTransform == null) {
cmbTransform = new JComboBox<>(ImageProcessing.getTransformations());
cmbTransform.setBounds(new Rectangle(0, 130, 191, 21));
}
return cmbTransform;
}
private JButton getBtnTransform() {
if (btnTransform == null) {
btnTransform = new JButton();
btnTransform.setBounds(new Rectangle(0, 150, 191, 21));
btnTransform.setText("Apply Transformation");
btnTransform.setMnemonic('t');
btnTransform.addActionListener(e -> mainWindow.doOperation(cmbTransform
.getItemAt(cmbTransform.getSelectedIndex())));
}
return btnTransform;
}
}