View Javadoc

1   package org.sat4j.tools;
2   
3   import java.io.FileNotFoundException;
4   import java.io.FileOutputStream;
5   import java.io.PrintStream;
6   
7   public class FileBasedVisualizationTool implements IVisualizationTool {
8   
9       private String filename;
10      private PrintStream out;
11  
12      public FileBasedVisualizationTool(String filename) {
13          this.filename = filename;
14          updateWriter();
15      }
16  
17      public void updateWriter() {
18          try {
19              this.out = new PrintStream(new FileOutputStream(this.filename
20                      + ".dat"));
21          } catch (FileNotFoundException e) {
22              this.out = System.out;
23          }
24      }
25  
26      public String getFilename() {
27          return this.filename;
28      }
29  
30      public void setFilename(String filename) {
31          this.filename = filename;
32      }
33  
34      public void addPoint(double x, double y) {
35          this.out.println(x + "\t" + y);
36      }
37  
38      public void addInvisiblePoint(double x, double y) {
39          this.out.println("#" + x + "\t" + "1/0");
40      }
41  
42      public void init() {
43          updateWriter();
44      }
45  
46      public void end() {
47          this.out.close();
48      }
49  
50  }