Skip to content

Commit 8204004

Browse files
authored
chore: Renaming (#6)
* chore: Renaming * test message
1 parent f32fb68 commit 8204004

17 files changed

+552
-553
lines changed

src/main/java/prog/Main.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,44 @@
1010
import javax.swing.JOptionPane;
1111
import javax.swing.JPanel;
1212

13-
import prog.huffman.Hzipping;
14-
import prog.huffman.Hunzipping;
15-
import prog.lzw.Lzipping;
16-
import prog.lzw.Lunzipping;
13+
import prog.huffman.HuffmanCompressor;
14+
import prog.huffman.HuffmanDecompressor;
15+
import prog.lzw.LzwCompressor;
16+
import prog.lzw.LzwDecompressor;
1717

1818
public class Main extends JFrame implements ActionListener {
1919
// Definition of global values and items that are part of the GUI.
2020

21-
static public File opened_file, other_file;
22-
static long past, future;
23-
static JLabel redLabel, blueLabel, redScore, blueScore;
21+
static public File openedFile, outputFile;
22+
static long originalSize, compressedSize;
23+
static JLabel originalSizeLabel, compressedSizeLabel, originalSizeValue, compressedSizeValue;
2424
static JPanel buttonPanel, titlePanel, scorePanel;
25-
static JButton ZH, UH, ZL, UL, EX;
25+
static JButton huffmanCompressButton, huffmanDecompressButton, lzwCompressButton, lzwDecompressButton, exitButton;
2626

2727
public JPanel createContentPane() {
2828
return MainPanel.createContentPane(this);
2929
}
3030

3131
private void handleHuffmanCompression() {
32-
Hzipping.beginHzipping(opened_file.getPath());
32+
HuffmanCompressor.beginHuffmanCompression(openedFile.getPath());
3333
showCompressionCompleteDialog("Zipping");
3434
updateFileStats(".huffz");
3535
}
3636

3737
private void handleHuffmanDecompression() {
38-
Hunzipping.beginHunzipping(opened_file.getPath());
38+
HuffmanDecompressor.beginHuffmanDecompression(openedFile.getPath());
3939
showCompressionCompleteDialog("UnZipping");
4040
updateDecompressionStats();
4141
}
4242

4343
private void handleLZWCompression() {
44-
Lzipping.beginLzipping(opened_file.getPath());
44+
LzwCompressor.beginLzwCompression(openedFile.getPath());
4545
showCompressionCompleteDialog("Zipping");
4646
updateFileStats(".LmZWp");
4747
}
4848

4949
private void handleLZWDecompression() {
50-
Lunzipping.beginLunzipping(opened_file.getPath());
50+
LzwDecompressor.beginLzwDecompression(openedFile.getPath());
5151
showCompressionCompleteDialog("UnZipping");
5252
updateDecompressionStats();
5353
}
@@ -59,31 +59,31 @@ private void showCompressionCompleteDialog(String operation) {
5959
}
6060

6161
private void updateFileStats(String extension) {
62-
redScore.setText(opened_file.length() + "Bytes");
63-
other_file = new File(opened_file.getPath() + extension);
64-
future = other_file.length();
65-
blueScore.setText(future + "Bytes");
62+
originalSizeValue.setText(openedFile.length() + "Bytes");
63+
outputFile = new File(openedFile.getPath() + extension);
64+
compressedSize = outputFile.length();
65+
compressedSizeValue.setText(compressedSize + "Bytes");
6666
}
6767

6868
private void updateDecompressionStats() {
69-
redScore.setText(opened_file.length() + "Bytes");
70-
String s = opened_file.getPath();
69+
originalSizeValue.setText(openedFile.length() + "Bytes");
70+
String s = openedFile.getPath();
7171
s = s.substring(0, s.length() - 6);
72-
other_file = new File(s);
73-
future = other_file.length();
74-
blueScore.setText(future + "Bytes");
72+
outputFile = new File(s);
73+
compressedSize = outputFile.length();
74+
compressedSizeValue.setText(compressedSize + "Bytes");
7575
}
7676

7777
public void actionPerformed(ActionEvent e) {
78-
if (e.getSource() == ZH) {
78+
if (e.getSource() == huffmanCompressButton) {
7979
handleHuffmanCompression();
80-
} else if (e.getSource() == UH) {
80+
} else if (e.getSource() == huffmanDecompressButton) {
8181
handleHuffmanDecompression();
82-
} else if (e.getSource() == ZL) {
82+
} else if (e.getSource() == lzwCompressButton) {
8383
handleLZWCompression();
84-
} else if (e.getSource() == UL) {
84+
} else if (e.getSource() == lzwDecompressButton) {
8585
handleLZWDecompression();
86-
} else if (e.getSource() == EX) {
86+
} else if (e.getSource() == exitButton) {
8787
System.exit(0);
8888
}
8989
}

src/main/java/prog/MainFrame.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ private static void handleFileOpen() {
4444
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
4545
int result = fileChooser.showOpenDialog(null);
4646
if (result == JFileChooser.APPROVE_OPTION) {
47-
Main.opened_file = fileChooser.getSelectedFile();
48-
Main.past = Main.opened_file.length();
49-
Main.redScore.setText(Main.past + "Bytes");
50-
Main.blueScore.setText("NotYetCalculated");
47+
Main.openedFile = fileChooser.getSelectedFile();
48+
Main.originalSize = Main.openedFile.length();
49+
Main.originalSizeValue.setText(Main.originalSize + "Bytes");
50+
Main.compressedSizeValue.setText("NotYetCalculated");
5151
}
5252
}
5353

src/main/java/prog/MainPanel.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ private static void createTitlePanel(JPanel mainPanel) {
3131
mainPanel.add(Main.titlePanel);
3232

3333
// Create and add labels
34-
Main.redLabel = createLabel("Selected File Size: ", 43, 0, 150, 30);
35-
Main.blueLabel = createLabel("After zip/unzip the file size: ", 10, 30, 170, 30);
36-
37-
Main.titlePanel.add(Main.redLabel);
38-
Main.titlePanel.add(Main.blueLabel);
34+
Main.originalSizeLabel = createLabel("Selected File Size: ", 43, 0, 150, 30);
35+
Main.compressedSizeLabel = createLabel("After zip/unzip the file size: ", 10, 30, 170, 30);
36+
37+
Main.titlePanel.add(Main.originalSizeLabel);
38+
Main.titlePanel.add(Main.compressedSizeLabel);
3939
}
4040

4141
private static void createScorePanel(JPanel mainPanel) {
@@ -46,11 +46,11 @@ private static void createScorePanel(JPanel mainPanel) {
4646
mainPanel.add(Main.scorePanel);
4747

4848
// Create and add score labels
49-
Main.redScore = createLabel("", 0, 0, 100, 30);
50-
Main.blueScore = createLabel("", 0, 30, 100, 30);
51-
52-
Main.scorePanel.add(Main.redScore);
53-
Main.scorePanel.add(Main.blueScore);
49+
Main.originalSizeValue = createLabel("", 0, 0, 100, 30);
50+
Main.compressedSizeValue = createLabel("", 0, 30, 100, 30);
51+
52+
Main.scorePanel.add(Main.originalSizeValue);
53+
Main.scorePanel.add(Main.compressedSizeValue);
5454
}
5555

5656
private static JLabel createLabel(String text, int x, int y, int width, int height) {
@@ -77,18 +77,18 @@ private static void createButtonPanel(JPanel mainPanel, ActionListener listener)
7777
mainPanel.add(Main.buttonPanel);
7878

7979
// Create compression buttons
80-
Main.ZH = createButton("ZIP HuffZ", 0, 0, 120, 30, listener);
81-
Main.UH = createButton("UNZIP HuffZ", 130, 0, 120, 30, listener);
82-
Main.ZL = createButton("ZIP LmZWp", 260, 0, 120, 30, listener);
83-
Main.UL = createButton("UNZIP LmZWp", 390, 0, 120, 30, listener);
84-
Main.EX = createButton("EXIT", 130, 70, 250, 30, listener);
80+
Main.huffmanCompressButton = createButton("ZIP HuffZ", 0, 0, 120, 30, listener);
81+
Main.huffmanDecompressButton = createButton("UNZIP HuffZ", 130, 0, 120, 30, listener);
82+
Main.lzwCompressButton = createButton("ZIP LmZWp", 260, 0, 120, 30, listener);
83+
Main.lzwDecompressButton = createButton("UNZIP LmZWp", 390, 0, 120, 30, listener);
84+
Main.exitButton = createButton("EXIT", 130, 70, 250, 30, listener);
8585

8686
// Add buttons to panel
87-
Main.buttonPanel.add(Main.ZH);
88-
Main.buttonPanel.add(Main.UH);
89-
Main.buttonPanel.add(Main.ZL);
90-
Main.buttonPanel.add(Main.UL);
91-
Main.buttonPanel.add(Main.EX);
87+
Main.buttonPanel.add(Main.huffmanCompressButton);
88+
Main.buttonPanel.add(Main.huffmanDecompressButton);
89+
Main.buttonPanel.add(Main.lzwCompressButton);
90+
Main.buttonPanel.add(Main.lzwDecompressButton);
91+
Main.buttonPanel.add(Main.exitButton);
9292
}
9393

9494
public static JPanel createContentPane(ActionListener listener) {

0 commit comments

Comments
 (0)