-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEmbedExtractOptions.java
executable file
·208 lines (152 loc) · 6.96 KB
/
EmbedExtractOptions.java
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
public class EmbedExtractOptions extends javax.swing.table.AbstractTableModel {
private java.io.File inputFile;
private java.io.File outputDirectory;
private java.io.File outputFile;
private String embedText;
private java.io.File embedFile;
private boolean embedTextOrFile;
private String password;
private String comment;
private int quality;
private static final String inputFileDesc = "Input File";
private static final String outputDirectoryDesc = "Output Directory";
private static final String outputFileDesc = "Output File";
private static final String embedTextDesc = "Text to be embedded";
private static final String embedFileDesc = "File to be embedded";
private static final String passwordDesc = "Password";
private static final String commentDesc = "Comment";
private static final String qualityDesc = "Quality";
String[] columnNames = {"Property","Option Selected"};
Object[][] columnData;
public EmbedExtractOptions() {
}
public void createEmbedColumnData(){
char[] mask = new char[password.length()];
java.util.Arrays.fill(mask,'*');
columnData = new Object[][]{
{inputFileDesc,inputFile.getAbsolutePath()},
{outputDirectoryDesc,outputDirectory.getAbsolutePath()},
{(embedTextOrFile)?embedTextDesc:embedFileDesc,(embedTextOrFile)?embedText:embedFile.getAbsolutePath()},
{passwordDesc,new String(mask)},
{commentDesc,comment},
{qualityDesc,new Integer(quality)}};
}
public void createExtractColumnData(){
char[] mask = new char[password.length()];
java.util.Arrays.fill(mask,'*');
columnData = new Object[][]{
{inputFileDesc,inputFile.getAbsolutePath()},
{outputFileDesc,outputFile.getAbsolutePath()},
{passwordDesc,new String(mask)}};
}
public java.io.File createOutputFile(int suffixCount){
String outFileName = inputFile.getName().substring(0, inputFile.getName().lastIndexOf(".")) + ".au";
outputFile = new java.io.File(outputDirectory.getAbsolutePath()+System.getProperty("file.separator")+outFileName);
int i = 1;
while (outputFile.exists()) {
outFileName = outFileName.substring(0, outFileName.lastIndexOf(".")) + (i++) + ".au";
outputFile = new java.io.File(outputDirectory.getAbsolutePath()+System.getProperty("file.separator")+outFileName);
if (i > suffixCount)
return null;
}
return outputFile;
}
/** Getter for property imputImage. */
/* public java.awt.Image getInputImage(){
java.awt.Image image = null;
if (inputFile.getName().endsWith(".bmp")) {
// Bmp bmp = new Bmp(inputFile.getAbsolutePath());
// image = bmp.getImage();
} else
//image = java.awt.Toolkit.getDefaultToolkit().getImage(inputFile.getAbsolutePath());
return image;
}
*/
public java.io.File getEmbedFile() {
if( isEmbedTextOrFile() ){
try{
java.io.File tempFile = java.io.File.createTempFile("ctl","dh");
java.io.FileWriter writer = new java.io.FileWriter(tempFile);
writer.write( getEmbedText() );
writer.close();
return tempFile;
}catch(java.io.IOException ioe){
String errorMessage = "Error creating temporary file";
System.out.println("ALERT! :"+errorMessage);
javax.swing.JOptionPane.showMessageDialog(null,errorMessage);
}
}
return embedFile;
}
public String getColumnName(int index){
return columnNames[index];
}
public int getColumnCount() {
return columnNames.length;
}
public int getRowCount() {
return columnData.length;
}
public Object getValueAt(int row, int column) {
return columnData[row][column];
}
public String toString(){
return "\tInput File\t"+inputFile.getAbsolutePath()+"\n\n"+
"\tOutput Directory\t"+inputFile.getAbsolutePath()+"\n\n"+
((embedTextOrFile)?"\tText to be embedded\t"+embedText+"\n\n":"\tFile to be embedded\t"+embedFile.getAbsolutePath()+"\n\n")+
"\tPassword\t"+password+"\n\n"+
((comment==null)?"\tComment\t"+comment+"\n\n":"")+
"\tQuality\t"+quality+"\n\n";
}
public java.lang.String getComment() {
return comment;
}
public void setComment(java.lang.String comment) {
this.comment = comment;
}
public void setEmbedFile(java.io.File embedFile) {
this.embedFile = embedFile;
}
public java.lang.String getEmbedText() {
return embedText;
}
public void setEmbedText(java.lang.String embedText) {
this.embedText = embedText;
}
public boolean isEmbedTextOrFile() {
return embedTextOrFile;
}
public void setEmbedTextOrFile(boolean embedTextOrFile) {
this.embedTextOrFile = embedTextOrFile;
}
public java.io.File getInputFile() {
return inputFile;
}
public void setInputFile(java.io.File inputFile) {
this.inputFile = inputFile;
}
public java.io.File getOutputDirectory() {
return outputDirectory;
}
public void setOutputDirectory(java.io.File outputDirectory) {
this.outputDirectory = outputDirectory;
}
public java.lang.String getPassword() {
return password;
}
public void setPassword(java.lang.String password) {
this.password = password;
}
public int getQuality() {
return quality;
}
public void setQuality(int quality) {
this.quality = quality;
}
public java.io.File getOutputFile() {
return outputFile;
}
public void setOutputFile(java.io.File outputFile) {
this.outputFile = outputFile;
}
}