blob: 679c339d0e14554662032c6f499be08d112f7d2b (
plain)
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
|
/*
* Class to write the .dot file
*/
package testapp;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import javax.swing.SwingWorker;
import testapp.data.Item;
import java.util.logging.*;
/**
*
* @author sven
*/
public class DOTGenerator extends SwingWorker<File,Object>{
private Item startItem;
private static final Logger logger = Logger.getLogger(DOTGenerator.class.getName());
public DOTGenerator(Item startItem) {
this.startItem = startItem;
}
@Override
protected File doInBackground() throws Exception {
File tmpDotFile = null;
try {
tmpDotFile = File.createTempFile("tmp", ".gv");
FileWriter fw = new FileWriter(tmpDotFile);
logger.log(Level.INFO, "Path: "+tmpDotFile.getAbsolutePath());
fw.write(startItem.toDOT());
fw.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
return tmpDotFile;
}
@Override
protected void done() {
try {
GraphGenerator gen = new GraphGenerator(get());
gen.execute();
} catch (InterruptedException ie) {
ie.printStackTrace();
} catch (ExecutionException ee) {
ee.printStackTrace();
}
}
}
|