Generate the image export through a function instead of use the same namespace 54/9054/3
Sylvestre Ledru [Tue, 18 Sep 2012 14:33:42 +0000 (16:33 +0200)]
Change-Id: Iedf75e5f08206e99da592075d483d0eeef089e5a

scilab/modules/helptools/src/java/org/scilab/modules/helptools/image/ScilabImageConverter.java

index 54e3328..64d7cd1 100644 (file)
@@ -121,6 +121,7 @@ public class ScilabImageConverter implements ExternalImageConverter {
     }
 
     private final String convertToPNG(String currentFile, String code, File imageFile, String imageName) {
+        buffer.append("function _generate_image_from_doc\n");
         buffer.append("__olddrv__=driver();\n");
         buffer.append("disp(\"Generate image " + imageName + " from Scilab code from file " + new File(currentFile).getName() + "\");\n");
         buffer.append("driver(\"png\");\n");
@@ -129,6 +130,9 @@ public class ScilabImageConverter implements ExternalImageConverter {
         buffer.append("___f___=gcf();___f___.anti_aliasing=\"2x\";clear(\"___f___\");\n");
         buffer.append("xend();\n");
         buffer.append("driver(__olddrv__);\n");
+        buffer.append("endfunction\n");
+        buffer.append("_generate_image_from_doc();\n");
+        buffer.append("clear _generate_image_from_doc;\n");
 
         return getHTMLCodeToReturn(code, "<img src=\'" + imageName + "\'/>");
     }