Doc generation: add a method HTMLDocbookTagConverter::getGenerationType() to know...
[scilab.git] / scilab / modules / helptools / src / java / org / scilab / modules / helptools / image / ScilabImageConverter.java
index 3aa0407..06591eb 100644 (file)
@@ -24,6 +24,7 @@ import java.io.OutputStream;
 import java.util.Map;
 
 import org.scilab.modules.commons.ScilabCommons;
+import org.scilab.modules.helptools.HTMLDocbookTagConverter;
 
 /**
  * Scilab code to PNG converter
@@ -32,21 +33,23 @@ public class ScilabImageConverter implements ExternalImageConverter {
 
     private static ScilabImageConverter instance;
     private final StringBuilder buffer;
+    private final HTMLDocbookTagConverter.GenerationType type;
 
-    private ScilabImageConverter() {
+    private ScilabImageConverter(HTMLDocbookTagConverter.GenerationType type) {
         buffer = new StringBuilder(8192);
+        this.type = type;
     }
 
     public String getMimeType() {
         return "image/scilab";
     }
 
-    public String getFileWithScilabCode() {
-        if (buffer.length() != 0) {
+    public static String getFileWithScilabCode() {
+        if (instance.buffer.length() != 0) {
             try {
                 File f = File.createTempFile("help-", ".sce", new File(ScilabCommons.getTMPDIR()));
                 BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(f));
-                byte[] arr = buffer.toString().getBytes();
+                byte[] arr = instance.buffer.toString().getBytes();
                 out.write(arr, 0, arr.length);
                 out.flush();
                 out.close();
@@ -68,9 +71,9 @@ public class ScilabImageConverter implements ExternalImageConverter {
      * Since this a singleton class...
      * @return this
      */
-    public static ScilabImageConverter getInstance() {
+    public static ScilabImageConverter getInstance(HTMLDocbookTagConverter.GenerationType type) {
         if (instance == null) {
-            instance = new ScilabImageConverter();
+            instance = new ScilabImageConverter(type);
         }
 
         return instance;
@@ -121,4 +124,4 @@ public class ScilabImageConverter implements ExternalImageConverter {
 
         return " <div rel='tooltip' title='" + code + "'><img src=\'" + imageName + "\'/></div>";
     }
-}
\ No newline at end of file
+}