Révision 1769

tmp/org.txm.chartsengine.svgbatik.rcp/src/org/txm/chartsengine/svgbatik/rcp/swt/SVGComposite.java (revision 1769)
39 39

  
40 40

  
41 41

  
42
	
43
	@Override
44
	public void loadChart(Object data) {
45
		this.loadSVGDocument((File) data);
46
	}
42 47

  
48
	
49

  
43 50
	/**
44 51
	 * Loads a SVG document from the specified file.
45 52
	 * @param file the file to load
......
86 93

  
87 94
	
88 95

  
89
	
90
	@Override
91
	public void loadChart(Object data) {
92
		this.loadSVGDocument((File) data);
93
	}
94 96

  
95
	
96 97

  
97 98

  
98 99

  
tmp/org.txm.chartsengine.r.core/src/org/txm/stat/engine/r/RWorkspaceRenderer.java (revision 1769)
85 85
	 * @throws REXPMismatchException the rEXP mismatch exception
86 86
	 * @throws StatException the stat exception
87 87
	 */
88
	public File plot(File file, String expr) throws REXPMismatchException,	StatException {
88
	public File plot(File file, String expr) {
89 89
		return plot(file, expr, defaultDevice );
90 90
	}
91 91

  
......
98 98
	 * @throws REXPMismatchException the rEXP mismatch exception
99 99
	 * @throws StatException the stat exception
100 100
	 */
101
	public File plot(File file, String expr, RDevice device) throws REXPMismatchException, StatException
102
	{
101
	public File plot(File file, String expr, RDevice device) {
103 102
		try {
104 103
			file.createNewFile();
105 104
		}
......
119 118
				name = StringEscapeUtils.escapeJava(file.getCanonicalPath());
120 119
			}
121 120
			catch (IOException e) {
122
				throw new StatException(e);
121
				e.printStackTrace();
122
				return null;
123 123
			}
124 124
		}
125 125
		else {
126 126
			name = file.getAbsolutePath();
127 127
		}
128 128

  
129
		if (devicename.equals("devSVG"))	{
130
			workspace.voidEval("library(RSvgDevice);");
131
		}
129
		try {
130
			if (devicename.equals("devSVG"))	{
131
				workspace.voidEval("library(RSvgDevice);");
132
			}
132 133

  
133 134

  
134 135

  
135
		// FIXME : test for window dimensions so the large plots can be entirely displayed. Need to pass width and height to RWorkspace.plot() so
136
		// RChartsEngine will be able to dynamically compute the width from the number of bars in a barplot for example.
137
		//REXP xp = workspace.eval("try("+devicename+"(\"" + name + "\", width=20, height=10))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
136
			// FIXME : test for window dimensions so the large plots can be entirely displayed. Need to pass width and height to RWorkspace.plot() so
137
			// RChartsEngine will be able to dynamically compute the width from the number of bars in a barplot for example.
138
			//REXP xp = workspace.eval("try("+devicename+"(\"" + name + "\", width=20, height=10))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
138 139

  
139
		
140
		//workspace.voidEval("par(family = \"mono\")");
141
				
142
		//REXP xp = workspace.eval("try("+devicename+"(\"" + name + "\"))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
140
			
141
			//workspace.voidEval("par(family = \"mono\")");
142
					
143
			//REXP xp = workspace.eval("try("+devicename+"(\"" + name + "\"))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
143 144

  
144
		// FIXME: tests: Unicode and charts engine font preference
145
		//REXP xp = workspace.eval("try("+devicename+"(\"" + name + "\", family = \"Lucida Sans Unicode\"))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
146
		Font font = ChartsEngine.createFont();
147
		REXP xp = workspace.eval("try("+devicename+"(\"" + name + "\", family = \"" + font.getFontName() + "\"))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
148
		//REXP xp = workspace.eval("try("+devicename+"(\"" + name + "\", family = \"" + font.getFamily() + "\"))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
149
		
150
		
151
		if (xp.isString() && xp.asString() != null) { // if there's a string
152
			// then we have a
153
			// problem, R sent an
154
			// error
155
			// System.out.println("Can't open svg graphics device:\n"+xp.asString());
156
			// this is analogous to 'warnings', but for us it's sufficient to
157
			// get just the 1st warning
158
			REXP w = workspace.eval("if (exists(\"last.warning\") && length(last.warning)>0) names(last.warning)[1] else 0"); //$NON-NLS-1$
159
			// if (w.asString()!=null) System.out.println(w.asString());
160
			throw new StatException(w.asString());
145
			// FIXME: tests: Unicode and charts engine font preference
146
			//REXP xp = workspace.eval("try("+devicename+"(\"" + name + "\", family = \"Lucida Sans Unicode\"))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
147
			Font font = ChartsEngine.createFont();
148
			REXP xp = workspace.eval("try("+devicename+"(\"" + name + "\", family = \"" + font.getFontName() + "\"))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
149
			//REXP xp = workspace.eval("try("+devicename+"(\"" + name + "\", family = \"" + font.getFamily() + "\"))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
150
			
151
			
152
			if (xp.isString() && xp.asString() != null) { // if there's a string
153
				// then we have a
154
				// problem, R sent an
155
				// error
156
				// System.out.println("Can't open svg graphics device:\n"+xp.asString());
157
				// this is analogous to 'warnings', but for us it's sufficient to
158
				// get just the 1st warning
159
				REXP w = workspace.eval("if (exists(\"last.warning\") && length(last.warning)>0) names(last.warning)[1] else 0"); //$NON-NLS-1$
160
				// if (w.asString()!=null) System.out.println(w.asString());
161
				throw new StatException(w.asString());
162
			}
163

  
164
			// ok, so the device should be fine - let's plot
165
			workspace.voidEval(expr);
166
			workspace.voidEval("dev.off()"); //$NON-NLS-1$
161 167
		}
162

  
163
		// ok, so the device should be fine - let's plot
164
		workspace.voidEval(expr);
165
		workspace.voidEval("dev.off()"); //$NON-NLS-1$
168
		catch (Exception e) {
169
			e.printStackTrace();
170
			return null;
171
		}
166 172
		
167 173
		return file;
168 174
	}

Formats disponibles : Unified diff