-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompression.java
More file actions
54 lines (45 loc) · 1.36 KB
/
compression.java
File metadata and controls
54 lines (45 loc) · 1.36 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
import java.util.ArrayList;
import java.util.List;
public class compression {
private String compressed;
private List<Triple> compressedLZ77;
private List<Integer> compressedLZW;
public compression(String algorithm, String content){
if (algorithm == "Huffman"){
this.HuffmanEncoding(content);
}
else if (algorithm == "LZ77"){
this.LZ77Encoding(content);
}
else if (algorithm == "LZW"){
this.LZWEncoding(content);
}
else{
this.getCompressed();
}
}
private void HuffmanEncoding(String content){
Huffman huffman = new Huffman(content);
compressed = huffman.encode();
System.out.println("\nTree visualisation");
python python = new python(content);
python.Huffman_tree_visualisation();
}
private void LZ77Encoding(String content){
LZ77 LZ77 = new LZ77(content,10,5);
compressedLZ77 = LZ77.getcompressedData();
}
private void LZWEncoding(String content){
LZW LZW = new LZW(content);
compressedLZW = LZW.getCompressed();
}
public String getCompressed() {
return compressed;
}
public List<Triple> getCompressedLZ77() {
return compressedLZ77;
}
public List<Integer> getCompressedLZW() {
return compressedLZW;
}
}