public class normalization extends Thread {
public void run() {
File[] file = FileChooser_txt.getSelectedFiles();
if (file.length == 0) {
Text1.setText("No file loaded.");
} else if (file.length == 1) {
String[] pfad = {file[0].getAbsolutePath().replace("\\", "/")};
String name = file[0].getName().substring(0, file[0].getName().lastIndexOf(46));
File normalize = new File(file[0].getParent(), name + "_normalized.txt");
String[] newfile = {normalize.getAbsolutePath().replace("\\", "/")};
String[] methods = {"mean", "first", "none"};
String[] transformation = {"none", "log"};
JComboBox box1 = new JComboBox(methods);
JComboBox box2 = new JComboBox(transformation);
Object[] message = {"Method of normalization: ", box1, "Transformation: ", box2};
int resp = JOptionPane.showConfirmDialog(null, message, "Parameters of the normalization",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (resp == JOptionPane.OK_OPTION) {
String method = (String) box1.getSelectedItem();
String transform = (String) box2.getSelectedItem();
final ProgressMonitor pbar = new ProgressMonitor(monitor, "Normalization...",
"Waiting...", 0, 100);
monitor.setVisible(true);
String[] meth = {method};
String[] trans = {transform};
if (meth[0] == null || trans[0] == null) {
// Text2.setText("Aborted by user.");
} else {
double counter = 1.0;
.....
double percent = (counter / (double) file.length) * 100;
pbar.setProgress((int) percent);
pbar.setNote("Operation is " + (int) percent + "% complete");
if (pbar.isCanceled()) {
pbar.close();
monitor.setVisible(false);
//System.exit(1);
return;
}
}
File neu = new File(newfile[0].replace("\\", "/"));
if (neu.exists()) {
Text2.setText("Normalized values of " + name + " saved at: " + newfile[0].replace ("\\", "/"));
} else {
Text2.setText("Error. Normalization failed. Check your input data.");
}
} else {
Text2.setText("Normalization aborted by user.");
}
monitor.setVisible(false);
}
}
public class something extends Thread {
public void run() {
File[] file = FileChooser_txt.getSelectedFiles();
if (file.length == 0) {
Text1.setText("No file loaded.");
} else if (file.length == 1) {
String[] pfad = {file[0].getAbsolutePath().replace("\\", "/")};
String name = file[0].getName().substring(0, file[0].getName().lastIndexOf(46));
File normalize = new File(file[0].getParent(), name + "_normalized.txt");
String[] newfile = {normalize.getAbsolutePath().replace("\\", "/")};
String[] methods = {"mean", "first", "none"};
String[] transformation = {"none", "log"};
JComboBox box1 = new JComboBox(methods);
JComboBox box2 = new JComboBox(transformation);
......
}
}
}
private void Automated1ActionPerformed(java.awt.event.ActionEvent evt) {
normalization norm = new normalization();
norm.start();
try {
norm.join();
} catch (InterruptedException ex) {
Logger.getLogger(CyBar2.class.getName()).log(Level.SEVERE, null, ex);
}
something some = new something();
some.start();
try {
some.join();
} catch (InterruptedException ex) {
Logger.getLogger(CyBar2.class.getName()).log(Level.SEVERE, null, ex);
}
}