summaryrefslogtreecommitdiffstats
path: root/scilab/modules
diff options
context:
space:
mode:
authorSylvestre Ledru <sylvestre.ledru@scilab.org>2010-05-10 12:46:53 +0200
committerClément DAVID <clement.david@scilab.org>2010-05-19 10:23:06 +0200
commit32fce17d94a24fa61a955d1bbce864bf56ff6f5a (patch)
tree5f1d70b5706982c33eee4529cd8baee80e0282b7 /scilab/modules
parent6acaa9709be7728a9296a8f4e0df1437c7e69d36 (diff)
downloadscilab-32fce17d94a24fa61a955d1bbce864bf56ff6f5a.zip
scilab-32fce17d94a24fa61a955d1bbce864bf56ff6f5a.tar.gz
Since java.io.tmpdir is now equal to the Scilab TMPDIR, use the appropriate functions and/or remove the old way to do it
Change-Id: I5f5282cd4dc1d6dea78442e23eb34fedc1ac66fe
Diffstat (limited to 'scilab/modules')
-rw-r--r--scilab/modules/graphic_export/src/java/org/scilab/modules/graphic_export/FileExporter.java130
-rw-r--r--scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/CallScilabBridge.java3
-rw-r--r--scilab/modules/xcos/src/java/org/scilab/modules/xcos/utils/FileUtils.java2
3 files changed, 68 insertions, 67 deletions
diff --git a/scilab/modules/graphic_export/src/java/org/scilab/modules/graphic_export/FileExporter.java b/scilab/modules/graphic_export/src/java/org/scilab/modules/graphic_export/FileExporter.java
index d770bc9..e6cd8b5 100644
--- a/scilab/modules/graphic_export/src/java/org/scilab/modules/graphic_export/FileExporter.java
+++ b/scilab/modules/graphic_export/src/java/org/scilab/modules/graphic_export/FileExporter.java
@@ -29,8 +29,8 @@ public class FileExporter {
29 /** Export waiting message */ 29 /** Export waiting message */
30 private static final String exportingMessage = "Exporting figure, please wait..."; 30 private static final String exportingMessage = "Exporting figure, please wait...";
31 31
32 /** The id used on classpath.xml to load vectorial export JARs */ 32 /** The id used on classpath.xml to load vectorial export JARs */
33 private static final String CLASSPATH_PDF_PS_EPS_EXPORT_NAME = "pdf_ps_eps_graphic_export"; 33 private static final String CLASSPATH_PDF_PS_EPS_EXPORT_NAME = "pdf_ps_eps_graphic_export";
34 34
35 /** 35 /**
36 * Default constructor 36 * Default constructor
@@ -49,20 +49,20 @@ public class FileExporter {
49 * depending on the kind of error 49 * depending on the kind of error
50 */ 50 */
51 public static int fileExport(int figureIndex, String fileName, int fileType, int fileOrientation) { 51 public static int fileExport(int figureIndex, String fileName, int fileType, int fileOrientation) {
52 int saveFileType = -1; 52 int saveFileType = -1;
53 String saveFileName = ""; 53 String saveFileName = "";
54 54
55 DrawableFigureGL exportedFig = FigureMapper.getCorrespondingFigure(figureIndex); 55 DrawableFigureGL exportedFig = FigureMapper.getCorrespondingFigure(figureIndex);
56 56
57 if (exportedFig == null) { 57 if (exportedFig == null) {
58 // figure no longer exists 58 // figure no longer exists
59 return ExportRenderer.IOEXCEPTION_ERROR; 59 return ExportRenderer.IOEXCEPTION_ERROR;
60 } 60 }
61 61
62 //When the graphic-export is too long, we inform the user that the figure is exporting 62 //When the graphic-export is too long, we inform the user that the figure is exporting
63 String oldInfoMessage = exportedFig.getInfoMessage(); 63 String oldInfoMessage = exportedFig.getInfoMessage();
64 exportedFig.setInfoMessage(exportingMessage); 64 exportedFig.setInfoMessage(exportingMessage);
65 if (fileType == ExportRenderer.PDF_EXPORT || fileType == ExportRenderer.EPS_EXPORT || fileType == ExportRenderer.PS_EXPORT ) { 65 if (fileType == ExportRenderer.PDF_EXPORT || fileType == ExportRenderer.EPS_EXPORT || fileType == ExportRenderer.PS_EXPORT ) {
66 66
67 /* Under !Windows, make sure that the library for ps export 67 /* Under !Windows, make sure that the library for ps export
68 * are already loaded 68 * are already loaded
@@ -87,55 +87,55 @@ public class FileExporter {
87 System.err.println("Could not invoke the Scilab method to load the export dependencies: "+ex); 87 System.err.println("Could not invoke the Scilab method to load the export dependencies: "+ex);
88 } 88 }
89 89
90 String ext = ""; 90 String ext = "";
91 91
92 switch (fileType) { 92 switch (fileType) {
93 case ExportRenderer.PDF_EXPORT: 93 case ExportRenderer.PDF_EXPORT:
94 ext = ".pdf"; 94 ext = ".pdf";
95 break; 95 break;
96 case ExportRenderer.EPS_EXPORT: 96 case ExportRenderer.EPS_EXPORT:
97 ext = ".eps"; 97 ext = ".eps";
98 break; 98 break;
99 case ExportRenderer.PS_EXPORT: 99 case ExportRenderer.PS_EXPORT:
100 ext = ".ps"; 100 ext = ".ps";
101 break; 101 break;
102 default: /* Do not the extension. Probably an error */ 102 default: /* Do not the extension. Probably an error */
103 return ExportRenderer.IOEXCEPTION_ERROR; 103 return ExportRenderer.IOEXCEPTION_ERROR;
104 } 104 }
105 105
106 String name = new File(fileName).getName(); 106 String name = new File(fileName).getName();
107 int dotPosition = name.lastIndexOf("."); 107 int dotPosition = name.lastIndexOf(".");
108 if (dotPosition > 0) { 108 if (dotPosition > 0) {
109 name = name.substring(0, dotPosition); 109 name = name.substring(0, dotPosition);
110 saveFileName = fileName.substring(0, fileName.lastIndexOf(".")) + ext; 110 saveFileName = fileName.substring(0, fileName.lastIndexOf(".")) + ext;
111 } else { 111 } else {
112 saveFileName = fileName + ext; 112 saveFileName = fileName + ext;
113 } 113 }
114 114
115 /* Temporary SVG file which will be used to convert to PDF */ 115 /* Temporary SVG file which will be used to convert to PDF */
116 fileName = System.getenv("TMPDIR") + System.getProperty("file.separator") + name + ".svg"; 116 fileName = File.createTempFile(name,"svg").getAbsolutePath();
117 saveFileType = fileType; 117 saveFileType = fileType;
118 fileType = ExportRenderer.SVG_EXPORT; 118 fileType = ExportRenderer.SVG_EXPORT;
119 } 119 }
120 120
121 ExportRenderer export; 121 ExportRenderer export;
122 export = ExportRenderer.createExporter(figureIndex, fileName, fileType, fileOrientation); 122 export = ExportRenderer.createExporter(figureIndex, fileName, fileType, fileOrientation);
123 123
124 // To be sure that their is a GLContext active for export 124 // To be sure that their is a GLContext active for export
125 exportedFig.openGraphicCanvas(); 125 exportedFig.openGraphicCanvas();
126 126
127 exportedFig.getRenderingTarget().addGLEventListener(export); 127 exportedFig.getRenderingTarget().addGLEventListener(export);
128 exportedFig.drawCanvas(); 128 exportedFig.drawCanvas();
129 exportedFig.getRenderingTarget().removeGLEventListener(export); 129 exportedFig.getRenderingTarget().removeGLEventListener(export);
130 130
131 //Put back the old infoMessage 131 //Put back the old infoMessage
132 exportedFig.setInfoMessage(oldInfoMessage); 132 exportedFig.setInfoMessage(oldInfoMessage);
133 133
134 if (saveFileType != -1) { 134 if (saveFileType != -1) {
135 ConvertSVG.SVGTo(fileName, saveFileName, saveFileType); 135 ConvertSVG.SVGTo(fileName, saveFileName, saveFileType);
136 new File(fileName).delete(); 136 new File(fileName).delete();
137 } 137 }
138 138
139 return ExportRenderer.getErrorNumber(); 139 return ExportRenderer.getErrorNumber();
140 } 140 }
141} 141}
diff --git a/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/CallScilabBridge.java b/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/CallScilabBridge.java
index 4166bd1..de9b833 100644
--- a/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/CallScilabBridge.java
+++ b/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/CallScilabBridge.java
@@ -26,6 +26,7 @@ import java.awt.datatransfer.StringSelection;
26import java.awt.datatransfer.Transferable; 26import java.awt.datatransfer.Transferable;
27import java.awt.datatransfer.UnsupportedFlavorException; 27import java.awt.datatransfer.UnsupportedFlavorException;
28import java.awt.print.PrinterJob; 28import java.awt.print.PrinterJob;
29import java.io.File;
29import java.io.FileInputStream; 30import java.io.FileInputStream;
30import java.io.FileNotFoundException; 31import java.io.FileNotFoundException;
31import java.io.IOException; 32import java.io.IOException;
@@ -156,7 +157,7 @@ public class CallScilabBridge {
156 157
157 158
158 private static PrintRequestAttributeSet scilabPageFormat = new HashPrintRequestAttributeSet(); 159 private static PrintRequestAttributeSet scilabPageFormat = new HashPrintRequestAttributeSet();
159 private static String tmpPrinterFile = System.getenv("TMPDIR") + System.getProperty("file.separator") + "scilabfigure"; 160 private static String tmpPrinterFile = File.createTempFile("scilabfigure","").getAbsolutePath();
160 161
161 private static final String FIGURE_TITLE = "Graphic window number "; 162 private static final String FIGURE_TITLE = "Graphic window number ";
162 163
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/utils/FileUtils.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/utils/FileUtils.java
index 3689100..e1c298d 100644
--- a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/utils/FileUtils.java
+++ b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/utils/FileUtils.java
@@ -110,7 +110,7 @@ public final class FileUtils {
110 */ 110 */
111 public static File createTempFile() throws IOException { 111 public static File createTempFile() throws IOException {
112 return File.createTempFile(XcosFileType.XCOS.getExtension(), 112 return File.createTempFile(XcosFileType.XCOS.getExtension(),
113 XcosFileType.HDF5.getDottedExtension(), ScilabConstants.TMPDIR); 113 XcosFileType.HDF5.getDottedExtension());
114 } 114 }
115 115
116 /** 116 /**