-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCompressPanel.java
More file actions
61 lines (46 loc) · 1.87 KB
/
CompressPanel.java
File metadata and controls
61 lines (46 loc) · 1.87 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
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class CompressPanel extends JPanel {
private JButton loadBtn, compressBtn;
private LabelText qLevels, vWidth, vHeight, filePath;
private String imagePath;
CompressPanel()
{
setLayout(new FlowLayout());
loadBtn = new JButton("Load");
add(loadBtn);
qLevels = new LabelText("Quantization Levels: ", 4);
add(qLevels);
vWidth = new LabelText("Vector Width: ", 4);
add(vWidth);
vHeight = new LabelText("Vector Height: ", 4);
add(vHeight);
filePath = new LabelText("Path: ", 30);
add(filePath);
compressBtn = new JButton("Compress");
add(compressBtn);
loadBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser("D:\\mtest");
int status = fc.showOpenDialog(fc.getParent());
if (status == 0)
imagePath = new String(fc.getSelectedFile().getPath());
else
imagePath = new String();
filePath.setText(imagePath);
System.out.println(filePath.getText());
}
});
compressBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int[] vectorDim = {Integer.parseInt(vWidth.getText()), Integer.parseInt(vHeight.getText())};
VectorQuantizerController controller = new VectorQuantizerController(Integer.parseInt(qLevels.getText()), vectorDim);
controller.compress(imagePath, "compressed.bekh");
}
});
}
}