Révision 2753

tmp/org.txm.wordcloud.core/src/org/txm/wordcloud/core/chartsengine/r/RWordCloudChartCreator.java (revision 2753)
12 12
	
13 13
	
14 14
	@Override
15
	public void updateChart(WordCloud result) {
15
	public File createChart(WordCloud result, File file) {
16 16
		
17 17
		try {
18 18
			WordCloud wordCloud = result;
19
			File chart = (File) result.getChart();
20 19
			
21 20
			
22 21
			// parameters
......
67 66
			// System.out.println("ploting...");
68 67
			// rw.plot(svgFile, cmd, device);
69 68
			
70
			this.chartsEngine.plot(chart, cmd);
69
			this.chartsEngine.plot(file, cmd);
71 70
			
72 71
			
73 72
			// System.out.println("cleaning");
......
82 81
			// TODO Auto-generated catch block
83 82
			e.printStackTrace();
84 83
		}
84
		
85
		return file;
85 86
	}
86 87
	
87 88
	@Override
tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/ChartCreator.java (revision 2753)
63 63
	
64 64
	
65 65
	/**
66
	 * Creates a chart file using the current ChartCreator prefix for the file name.
67
	 *
68
	 * @param result
69
	 * @param fileNamePrefix
70
	 * @return
71
	 */
72
	public File createChartFile(R result, File file, int imageWidth, int imageHeight) {
73
		// this.createChartFile(result, this.chartsEngine.createTmpFile(fileNamePrefix));
74
		if (file == null) {
75
			file = this.chartsEngine.createTmpFile(this.fileNamePrefix);
76
		}
77
		// this.createChart(result);
78
		// this.updateChart(result);
79
		this.chartsEngine.exportChart(result.getChart(), file, this.chartsEngine.getOutputFormat(), imageWidth, imageHeight);
80
		// result.setChart(file);
81
		
82
		return file;
83
	}
84
	
85
	// /**
86
	// * Creates a chart file according to the specified result data and parameters.
87
	// * @param result
88
	// * @param file
89
	// * @return
90
	// */
91
	// public File createChartFile(ChartResult result, File file) {
92
	// Object chart = this.createChart(result);
93
	// // FIXME: SJ: became useless?
94
	// // Synchronizes the chart with the shared preferences as show title, show legend, rendering colors mode, etc.
95
	// //this.updateChart(result);
96
	// return this.chartsEngine.createChartFile(chart, file);
97
	// }
98
	//
99
	// /**
100
	// * Creates a chart file according to the specified result data using the specified prefix for the file name.
101
	// * @param result
102
	// * @param fileNamePrefix
103
	// * @return
104
	// */
105
	// public File createChartFile(ChartResult result, String fileNamePrefix) {
106
	// return this.createChartFile(result, this.chartsEngine.createTmpFile(fileNamePrefix));
107
	// }
108
	//
109
	
110
	
111
	
112
	
113
	
114
	/**
115 66
	 * Updates an existing chart.
116 67
	 * By default this method does nothing.
117 68
	 * Subclasses should override this method to update a chart without recreating one.
......
120 71
	 * 
121 72
	 * @param result
122 73
	 * @param preferencesNode
123
	 * @return
124 74
	 */
125 75
	public void updateChart(R result) {
126 76
		Log.severe("ChartCreator.updateChart(): not implemented. This method is intended to be overridden in subclasses."); //$NON-NLS-1$
......
182 132
	}
183 133
	
184 134
	
185
	
135
	//TODO to be cleaned later
186 136
	// /**
187 137
	// * Creates a chart file according to the specified result data and parameters.
188 138
	// *
tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/results/ChartResult.java (revision 2753)
32 32
	
33 33
	/**
34 34
	 * The chart object.
35
	 * TODO: MD: this is problematic, the chart object should allow us to edit the chart. In the case of the R charts, the File has not the same value as the JFC Chart (which can be edited)
36
	 * TODO: replace this with at least a ChartResult parameter such as <O extends Object> but a abstract <C extends org.txm.Chart> would be better even if is only an empty class -> avoid compilation
37
	 * TODO: error and upgrade the readability of the code and avoid unnecessary casts
35 38
	 */
36 39
	protected Object chart;
37 40
	
......
64 67
	
65 68
	/**
66 69
	 * The chart type;
70
	 * TODO MD: finalize the chart type parameter. The chart type is directly linked to the ChartCreator classes and should not be a simple String -> this will allow us to manage this pref correctly
71
	 * in the autosave&load methods
67 72
	 */
68 73
	@Parameter(key = ChartsEnginePreferences.CHART_TYPE, type = Parameter.RENDERING)
69 74
	protected String chartType;
......
308 313
			// The change of the chart type parameter can occur if:
309 314
			// - the chart has never been created
310 315
			// - the chart type has been changed, e.g. to dynamically change the type of chart or the current charts engine
311
			if (this.chart == null || this.getLastParametersFromHistory() == null ||
312
					(this.getLastParametersFromHistory().get(ChartsEnginePreferences.CHART_TYPE) != null &&
313
							this.hasParameterChanged(ChartsEnginePreferences.CHART_TYPE))
316
			if (this.chart == null
317
			// MD: the following tests are no more necessary since chartResult dirty state has been already resolved
318
			// || this.getLastParametersFromHistory() == null ||
319
			// (this.getLastParametersFromHistory().get(ChartsEnginePreferences.CHART_TYPE) != null &&
320
			// this.hasParameterChanged(ChartsEnginePreferences.CHART_TYPE))
314 321
			// )
315 322
			
316 323
			) {
......
475 482
	 * @param chartType the chartType to set
476 483
	 */
477 484
	public void setChartType(String chartType) {
485
		if (!this.chartType.equals(chartType)) {
486
			// TODO find a better way to switch chart creators. this way previous chart is lost.
487
			setChart(null); // the chart must be redrawn from scratch
488
		}
478 489
		this.chartType = chartType;
479 490
		
480
		// FIXME: SJ: need to validate this
491
		// FIXME: SJ: need to validate this MD: this seems no more necessary since the chart object is reset just before
481 492
		HashMap<String, Object> last = this.getLastParametersFromHistory();
482 493
		if (last != null) {
483 494
			this.getLastParametersFromHistory().put(ChartsEnginePreferences.CHART_TYPE, "__undef___"); //$NON-NLS-1$
tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/ChartsEngine.java (revision 2753)
381 381
		return file;
382 382
	}
383 383
	
384
	/**
385
	 * Creates a uniq temporary file in USER_TXM_HOME\results with a specified prefix given by the ChartCreator of the result for writing the chart.
386
	 * The suffix is computed according to the current output format of the charts engine.
387
	 * 
388
	 * @return the uniq file
389
	 */
390
	public File createUniqTmpFile(ChartResult result) {
391
		return createUniqTmpFile(result, result.getChartCreator().getFileNamePrefix());
392
	}
393
	
394
	/**
395
	 * Creates a uniq temporary file in USER_TXM_HOME\results with the specified prefix for writing the chart.
396
	 * 
397
	 * The suffix is computed according to the current output format of the charts engine.
398
	 * 
399
	 * @return the uniq file
400
	 */
401
	public File createUniqTmpFile(ChartResult result, String prefix) {
402
		
403
		File file = null;
404
		File resultsDir = new File(Toolbox.getTxmHomePath(), "results"); //$NON-NLS-1$
405
		resultsDir.mkdirs();
406
		
407
		// right padding to 3 characters long
408
		if (prefix.length() < 3) {
409
			prefix = String.format("%1$-3s", prefix).replace(' ', '_'); //$NON-NLS-1$
410
		}
411
		
412
		file = new File(resultsDir, result.getChartCreator().getFileNamePrefix() + result.getParametersNodePath().replaceAll("/", "_") + "." + this.outputFormat);
413
		
414
		// TODO : old code, useful ? and/or return null instead of the file if canWrite() return false ?
415
		if (!resultsDir.canWrite()) {
416
			Log.severe(NLS.bind(ChartsEngineCoreMessages.error_cantWriteInFileP0, file));
417
		}
418
		return file;
419
	}
420
	
384 421
	// public File createChartFile(ChartResult result);
385 422
	
386 423
	// /**
......
422 459
	// // FIXME: SJ: became useless?
423 460
	// // Synchronizes the chart with the shared preferences as show title, show legend, rendering colors mode, etc.
424 461
	// // this.updateChart(result);
425
	// return this.exportChart(chart, file, this.outputFormat, 0, 0);
462
	// return this.exportChartToFile(chart, file, this.outputFormat, 0, 0);
426 463
	// }
427 464
	
428 465
	
......
452 489
	 * @param drawingAreaHeight
453 490
	 * @return
454 491
	 */
455
	public abstract File exportChart(Object chart, File file, String outputFormat, int imageWidth, int imageHeight, int drawingAreaX, int drawingAreaY, int drawingAreaWidth, int drawingAreaHeight);
492
	public abstract File exportChartToFile(Object chart, File file, String outputFormat, int imageWidth, int imageHeight, int drawingAreaX, int drawingAreaY, int drawingAreaWidth,
493
			int drawingAreaHeight);
456 494
	
457
	
458 495
	/**
459
	 * Export a chart in a file
460
	 * 
461
	 * @param result
462
	 * @param outputFormat
463
	 * @return
464
	 */
465
	public abstract File exportChart(ChartResult result, File file, int imageWidth, int imageHeight, String outputFormat);
466
	
467
	
468
	
469
	/**
470 496
	 * Exports the chart to the specified file.
471 497
	 * 
472 498
	 * @param chart
......
476 502
	 * @param imageHeight
477 503
	 * @return
478 504
	 */
479
	public File exportChart(Object chart, File file, String outputFormat, int imageWidth, int imageHeight) {
480
		return this.exportChart(chart, file, outputFormat, imageWidth, imageHeight, 0, 0, imageWidth, imageHeight);
505
	public File exportChartToFile(Object chart, File file, String outputFormat, int imageWidth, int imageHeight) {
506
		return this.exportChartToFile(chart, file, outputFormat, imageWidth, imageHeight, 0, 0, imageWidth, imageHeight);
481 507
	}
482 508
	
483 509
	/**
484
	 * Export a chart in a file
510
	 * Export a chart in a result file. The file path is generated and uniq for a result
485 511
	 * 
512
	 * image size is set to 1024x576
513
	 * 
486 514
	 * @param result
487 515
	 * @param outputFormatSvg
488 516
	 * @return
489 517
	 */
490
	public File exportChart(ChartResult result, String outputFormat) {
491
		return exportChart(result, 1024, 576, outputFormat);
518
	public File writeResultFile(ChartResult result, String outputFormat) {
519
		return writeChartResultFile(result, 1024, 576, outputFormat);
492 520
	}
493 521
	
494 522
	/**
495
	 * Export a chart in a file
523
	 * Export a chart in a result file. The file path is generated and uniq for a result
496 524
	 * 
497 525
	 * @param result
526
	 * @param imageWidth image width
527
	 * @param imageHeight image height
498 528
	 * @param outputFormatSvg
499 529
	 * @return
500 530
	 */
501
	public File exportChart(ChartResult result, int imageWidth, int imageHeight, String outputFormat) {
502
		return exportChart(result, createTmpFile("export"), imageWidth, imageHeight, outputFormat); // $NON-NLS-1$
531
	public File writeChartResultFile(ChartResult result, int imageWidth, int imageHeight, String outputFormat) {
532
		return exportResultToFile(result, createUniqTmpFile(result), imageWidth, imageHeight, outputFormat);
503 533
	}
504 534
	
505 535
	/**
536
	 * Export a chart in a file
537
	 * 
538
	 * @param result
539
	 * @param outputFormatSvg
540
	 * @return
541
	 */
542
	public abstract File exportResultToFile(ChartResult result, File file, int imageWidth, int imageHeight, String outputFormat);
543
	
544
	/**
506 545
	 * Gets the current output format.
507 546
	 * 
508 547
	 * @return
tmp/org.txm.specificities.core/src/org/txm/specificities/core/chartsengine/r/RSpecificitiesBarChartCreator.java (revision 2753)
24 24
	
25 25
	
26 26
	@Override
27
	public void updateChart(SpecificitiesSelection result) {
27
	public File createChart(SpecificitiesSelection result, File file) {
28 28
		
29 29
		try {
30 30
			
31 31
			SpecificitiesSelection specificitiesSelection = result;
32
			File chart = (File) result.getChart();
33 32
			
34 33
			// parameters
35 34
			boolean transpose = specificitiesSelection.isGroupingByLines();
......
161 160
			}
162 161
			
163 162
			// Plot all
164
			this.getChartsEngine().plot(chart, cmd);
163
			this.getChartsEngine().plot(file, cmd);
165 164
			
166 165
			
167 166
		}
168 167
		catch (Exception e) {
169 168
			Log.severe(SpecificitiesCoreMessages.bind(SpecificitiesCoreMessages.cantCreateSpecificitiesChartFileChartsEngineColonP0, this.getChartsEngine().getName()) + e);
170 169
		}
170
		
171
		return file;
171 172
	}
172 173
	
173 174
	
tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/editors/ProgressionEditor.java (revision 2753)
275 275
				@Override
276 276
				public void widgetSelected(SelectionEvent e) {
277 277
					bandeField.setEnabled(densityButton.getSelection());
278
					// to force the recreation of the chart as file
279
					if (!(getResult().getChart() instanceof File)) {
280
						getResult().setChart(null);
281
					}
278
					// This is kind of a hack to change the chart type. See the evolution of the Chart type parameter management
282 279
					getResult().setChartType(Progression.DENSITY_CHART_TYPE);
283 280
					super.widgetSelected(e);
284 281
				}
tmp/org.txm.ca.core/src/org/txm/ca/core/chartsengine/r/RCAChartCreator.java (revision 2753)
122 122
	
123 123
	
124 124
	@Override
125
	public void updateChart(CA ca) {
125
	public File createChart(CA ca, File file) {
126 126
		
127
		File chart = (File) ca.getChart();
128
		
129 127
		// FactoMineR R package
130 128
		if (ca.useFactoMineR()) {
131
			this.createFactorialMapChart((FactoMineRCA) ca.getCA(), chart, ca.isShowIndividuals(), ca.isShowVariables(), ca.getFirstDimension(), ca.getSecondDimension(), Utils
129
			return this.createFactorialMapChart((FactoMineRCA) ca.getCA(), file, ca.isShowIndividuals(), ca.isShowVariables(), ca.getFirstDimension(), ca.getSecondDimension(), Utils
132 130
					.createCAFactorialMapChartTitle(ca));
133 131
		}
134 132
		// CA R package
135 133
		else {
136
			this.createFactorialMapChart((org.txm.ca.core.statsengine.r.functions.CA) ca.getCA(), chart, ca.isShowIndividuals(), ca.isShowVariables(), ca.getFirstDimension(), ca
134
			return this.createFactorialMapChart((org.txm.ca.core.statsengine.r.functions.CA) ca.getCA(), file, ca.isShowIndividuals(), ca.isShowVariables(), ca.getFirstDimension(), ca
137 135
					.getSecondDimension());
138 136
		}
139 137
	}
tmp/org.txm.ca.core/src/org/txm/ca/core/chartsengine/r/REigenvaluesChartCreator.java (revision 2753)
22 22
public class REigenvaluesChartCreator extends RChartCreator<Eigenvalues> {
23 23
	
24 24
	@Override
25
	public void updateChart(Eigenvalues result) {
25
	public File createChart(Eigenvalues result, File file) {
26 26
		
27 27
		CA ca = result.getCA();
28
		File chart = (File) result.getChart();
29 28
		
30
		
31 29
		// FactoMineR R package
32 30
		if (ca.useFactoMineR()) {
33
			this.createSingularValuesBarPlot((FactoMineRCA) ca.getCA(), chart);
31
			return this.createSingularValuesBarPlot((FactoMineRCA) ca.getCA(), file);
34 32
		}
35 33
		// CA R package
36 34
		else {
37
			this.createSingularValuesBarPlot((org.txm.ca.core.statsengine.r.functions.CA) ca.getCA(), chart);
35
			return this.createSingularValuesBarPlot((org.txm.ca.core.statsengine.r.functions.CA) ca.getCA(), file);
38 36
		}
39 37
	}
40 38
	
tmp/org.txm.chartsengine.raster.rcp/src/org/txm/chartsengine/raster/rcp/swt/RasterComposite.java (revision 2753)
1 1
package org.txm.chartsengine.raster.rcp.swt;
2 2

  
3
import java.awt.Component;
4 3
import java.io.File;
5 4
import java.util.ArrayList;
6 5

  
7 6
import org.eclipse.swt.SWT;
8 7
import org.eclipse.swt.graphics.Image;
9 8
import org.eclipse.swt.graphics.ImageData;
9
import org.eclipse.swt.graphics.Point;
10 10
import org.eclipse.swt.layout.GridData;
11 11
import org.eclipse.swt.layout.GridLayout;
12 12
import org.eclipse.swt.widgets.Composite;
13 13
import org.eclipse.swt.widgets.Display;
14 14
import org.eclipse.swt.widgets.Label;
15
import org.txm.chartsengine.core.ChartsEngine;
16
import org.txm.chartsengine.core.results.ChartResult;
17 15
import org.txm.chartsengine.rcp.IChartComponent;
18 16
import org.txm.chartsengine.rcp.editors.ChartEditor;
19
import org.txm.chartsengine.rcp.editors.ChartEditorInput;
20 17
import org.txm.chartsengine.rcp.events.EventCallBackHandler;
21 18
import org.txm.chartsengine.rcp.swt.ChartComposite;
22 19
import org.txm.core.messages.TXMCoreMessages;
......
64 61
		this.imageLabel = new Label(this, SWT.NONE);
65 62
		
66 63
		// FIXME: SJ: for debugging purpose
67
		this.imageLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
64
		//this.imageLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
68 65
		
69 66
		// this.imageLabel = new Label(this, SWT.NONE);
70 67
		// this.imageLabel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
......
124 121
	
125 122
	@Override
126 123
	public void loadChart(Object chart) {
127
		
128
		// need to be async (the composite needs to be realized before using its size in export)
129
		Display.getDefault().asyncExec(new Runnable() {
130
			
131
			@Override
132
			public void run() {
133
				// create the chart file if not of the right type
134
				if (!(chart instanceof File)) {
135
					ChartResult result = chartEditor.getResult();
136
					// result.setChart(null);
137
					file = chartEditor.getSWTChartsComponentsProvider().getChartsEngine().getChartCreator(result).createChartFile(result, file, getParent().getSize().x, getParent().getSize().y);
138
					// result.setChart(this.file);
139
				}
140
				else {
141
					file = (File) chart;
142
				}
143
				
144
				loadRasterFile(file);
145
				
146
			}
147
		});
148
		
124
		if (chart instanceof File) {
125
			this.loadRasterFile((File) chart);
126
		} else {
127
			Log.warning("RasterComposite can't load a chart which is not a file: "+chart);
128
		}
149 129
	}
150 130
	
151
	
152
	
153 131
	@Override
154 132
	public void loadChart() {
155
		
156
		this.loadChart(this.chartEditor.getChart());
157
		
158
		// // loads the chart from the result
159
		// Object chart = this.chartEditor.getChart();
160
		//
161
		// if (chart != null) {
162
		//
163
		// // creates components if they not exist
164
		// if (this.chartComponent == null) {
165
		//
166
		// // recreates the chart if needed
167
		// if (this.chartEditor.getResult().isChartDirty()) {
168
		// try {
169
		// // this.chartEditor.getResult().clearLastRenderingParameters(); // FIXME: SJ: seems to became useless
170
		// this.chartEditor.getResult().compute();
171
		// }
172
		// catch (Exception e) {
173
		// e.printStackTrace();
174
		// }
175
		// }
176
		//
177
		// this.createChartComponent();
178
		//
179
		// this.loadChart(this.chartEditor.getChart());
180
		// }
181
		// }
182
		
133
		// this.file = (File) this.chartComponent;
134
		Point size = getSize();
135
		int w = size.x;
136
		int h = size.y;
137
		if (size.x != 0 && size.y != 0) { 
138
			// the widget size might not be ready at this moment, see ChartEditor.loadChart() method
139
			// alternative solution is to wrap this in a Display.asyncExec call to be sure the size is ready
140
			w = 800;
141
			h = 600;
142
		}
143
		this.file = this.getChartsEngine().writeChartResultFile(this.getChartResult(), w, h, this.getChartsEngine().getOutputFormat());
144
		this.loadRasterFile(this.file);
183 145
	}
184 146
	
185 147
	
186 148
	
149

  
150
	
151
	
187 152
	/**
188 153
	 * Loads a raster image from the specified file.
189 154
	 * 
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditor.java (revision 2753)
5 5
import java.util.ArrayList;
6 6

  
7 7
import org.eclipse.swt.SWT;
8
import org.eclipse.swt.graphics.Point;
8 9
import org.eclipse.swt.layout.GridData;
9 10
import org.eclipse.swt.widgets.Composite;
10 11
import org.eclipse.swt.widgets.Group;
......
17 18
import org.eclipse.ui.contexts.IContextService;
18 19
import org.eclipse.ui.part.MultiPageEditorPart;
19 20
import org.txm.chartsengine.core.ChartsEngine;
20
import org.txm.chartsengine.core.ChartsEnginesManager;
21 21
import org.txm.chartsengine.core.results.ChartResult;
22 22
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
23 23
import org.txm.chartsengine.rcp.messages.ChartsUIMessages;
......
288 288
		// check that the charts engine used for the result matches the SWT components provider otherwise find a suitable components provider
289 289
		// and recreate new ChartComposite and ChartComponent
290 290
		if (this.getResult().getChartsEngine() != this.swtChartsComponentsProvider.getChartsEngine()) {
291
			// if (this.getResult().getChartsEngine() != ChartsEnginesManager.getInstance().getCurrentEngine()) {
292 291
			
293 292
			Log.finest("ChartEditor.updateEditorFromResult(): result charts engine  = " + this.getResult().getChartsEngine().getName() + " / Editor charts engine = " + this.swtChartsComponentsProvider //$NON-NLS-1$ //$NON-NLS-2$
294 293
					.getChartsEngine().getName() + ".");  //$NON-NLS-1$
......
482 481
	 * @param clearChartItemsSelection
483 482
	 */
484 483
	public void loadChart() {
485
		this.getSite().getShell().getDisplay().syncExec(new Runnable() {
486
			
487
			@Override
488
			public void run() {
489
				chartComposite.loadChart(
490
						getResult().needsToResetView(),
491
						getResult().needsToClearItemsSelection(),
492
						getResult().needsToSquareOff());
493
			}
494
		});
484
		
485
		
486
		Point size = chartComposite.getSize();
487
		if (size.x == 0 || size.y == 0) { // MD: using asyncExec should force the chartComposite to be displayed before loading the chart
488
			this.getSite().getShell().getDisplay().asyncExec(new Runnable() {
489
				
490
				@Override
491
				public void run() {
492
					chartComposite.loadChart(
493
							getResult().needsToResetView(),
494
							getResult().needsToClearItemsSelection(),
495
							getResult().needsToSquareOff());
496
				}
497
			});
498
		}
499
		else { // TODO MD: remove this duplicated code using lambdas
500
			this.getSite().getShell().getDisplay().syncExec(new Runnable() {
501
				
502
				@Override
503
				public void run() {
504
					chartComposite.loadChart(
505
							getResult().needsToResetView(),
506
							getResult().needsToClearItemsSelection(),
507
							getResult().needsToSquareOff());
508
				}
509
			});
510
		}
495 511
	}
496 512
	
497 513
	
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/ChartComposite.java (revision 2753)
82 82
	
83 83
	/**
84 84
	 * Loads or reloads the chart from the chart object stored in the linked editor input.
85
	 * 
86
	 * This method is especially used for file based implementations of charts engine for reloading a file that has been externally modified.
87
	 * 
88
	 * This methods works only if used with a ChartEditor (the ChartEditor allows to retrieve the ChartResult and the chart to display)
85 89
	 */
86 90
	public abstract void loadChart();
87 91
	
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/SwingChartComposite.java (revision 2753)
539 539
			// creates components if they not exist
540 540
			if (this.chartComponent == null) {
541 541
				
542
				// recreates the chart if needed
543
				if (this.chartEditor.getResult().isChartDirty()) {
544
					try {
545
						// this.chartEditor.getResult().clearLastRenderingParameters(); // FIXME: SJ: seems to became useless
546
						this.chartEditor.getResult().compute();
547
					}
548
					catch (Exception e) {
549
						e.printStackTrace();
550
					}
551
				}
542
				// // recreates the chart if needed
543
				// if (this.chartEditor.getResult().isChartDirty()) {
544
				// try {
545
				// // this.chartEditor.getResult().clearLastRenderingParameters(); // FIXME: SJ: seems to became useless
546
				// this.chartEditor.getResult().compute();
547
				// }
548
				// catch (Exception e) {
549
				// e.printStackTrace();
550
				// }
551
				// }
552 552
				
553 553
				this.createChartComponent();
554 554
				
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/AdvancedChartEditorToolBar.java (revision 2753)
243 243
					String[] data = StringUtils.split(chartTypeCombo.getItem(chartTypeCombo.getSelectionIndex()), '/');
244 244
					data[0] = StringUtils.trim(data[0]);
245 245
					data[1] = StringUtils.trim(data[1]);
246
					getEditorPart().getResult().setChart(null);
247
					getEditorPart().getResult().setChartType(data[1]);
246
					getEditorPart().getResult().setChartType(data[1]); // reset the chart
248 247
					getEditorPart().getResult().setChartsEngine((ChartsEngine) Toolbox.getEngineManager(EngineType.CHARTS).getEngine(data[0]));
249 248
					update = false;
250 249
				}
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/handlers/MoveUpChartView.java (revision 2753)
3 3
import org.eclipse.core.commands.AbstractHandler;
4 4
import org.eclipse.core.commands.ExecutionEvent;
5 5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.osgi.util.NLS;
6 7
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
7 8
import org.txm.chartsengine.rcp.editors.ChartEditor;
9
import org.txm.utils.logger.Log;
8 10

  
9 11
/**
10
 * Resets the chart view of the active chart editor part.
12
 * Moves up the chart view of the active chart editor part.
11 13
 * 
12
 * @author sjacquot
14
 * @author mdecorde
13 15
 *
14 16
 */
15 17
public class MoveUpChartView extends AbstractHandler {
......
23 25
			chartEditor.pan(0, 0, 0, 1, 0.1);
24 26
		}
25 27
		catch (Exception e) {
26
			// nothing to do
28
			Log.warning(NLS.bind("Error while moving up in {0}: {1}.", chartEditor, e));
27 29
		}
28 30
		return chartEditor;
29 31
	}
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/handlers/ZoomInChartView.java (revision 2753)
3 3
import org.eclipse.core.commands.AbstractHandler;
4 4
import org.eclipse.core.commands.ExecutionEvent;
5 5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.osgi.util.NLS;
6 7
import org.eclipse.swt.graphics.Point;
7 8
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
8 9
import org.txm.chartsengine.rcp.editors.ChartEditor;
10
import org.txm.utils.logger.Log;
9 11

  
10 12
/**
11 13
 * Resets the chart view of the active chart editor part.
12 14
 * 
13
 * @author sjacquot
15
 * @author mdecorde
14 16
 *
15 17
 */
16 18
public class ZoomInChartView extends AbstractHandler {
......
25 27
			chartEditor.zoom(p.x / 2, p.y / 2, true);
26 28
		}
27 29
		catch (Exception e) {
28
			// nothing to do
30
			Log.warning(NLS.bind("Error while zooming in in {0}: {1}.", chartEditor, e));
29 31
		}
30 32
		return chartEditor;
31 33
	}
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/handlers/ZoomOutChartView.java (revision 2753)
3 3
import org.eclipse.core.commands.AbstractHandler;
4 4
import org.eclipse.core.commands.ExecutionEvent;
5 5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.osgi.util.NLS;
6 7
import org.eclipse.swt.graphics.Point;
7 8
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
8 9
import org.txm.chartsengine.rcp.editors.ChartEditor;
10
import org.txm.utils.logger.Log;
9 11

  
10 12
/**
11
 * Resets the chart view of the active chart editor part.
13
 * Zoom the chart view of the active chart editor part.
12 14
 * 
13
 * @author sjacquot
15
 * @author mdecorde
14 16
 *
15 17
 */
16 18
public class ZoomOutChartView extends AbstractHandler {
......
25 27
			chartEditor.zoom(p.x / 2, p.y / 2, false);
26 28
		}
27 29
		catch (Exception e) {
28
			// nothing to do
30
			Log.warning(NLS.bind("Error while zooming out in {0}: {1}.", chartEditor, e));
29 31
		}
30 32
		return chartEditor;
31 33
	}
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/handlers/MoveDownChartView.java (revision 2753)
3 3
import org.eclipse.core.commands.AbstractHandler;
4 4
import org.eclipse.core.commands.ExecutionEvent;
5 5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.osgi.util.NLS;
6 7
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
7 8
import org.txm.chartsengine.rcp.editors.ChartEditor;
9
import org.txm.utils.logger.Log;
8 10

  
9 11
/**
10
 * Resets the chart view of the active chart editor part.
12
 * Moves down the chart view of the active chart editor part.
11 13
 * 
12 14
 * @author sjacquot
13 15
 *
......
23 25
			chartEditor.pan(0, 0, 0, -1, 0.1);
24 26
		}
25 27
		catch (Exception e) {
26
			// nothing to do
28
			Log.warning(NLS.bind("Error while moving down in {0}: {1}.", chartEditor, e));
27 29
		}
28 30
		return chartEditor;
29 31
	}
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/handlers/MoveLeftChartView.java (revision 2753)
3 3
import org.eclipse.core.commands.AbstractHandler;
4 4
import org.eclipse.core.commands.ExecutionEvent;
5 5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.osgi.util.NLS;
6 7
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
7 8
import org.txm.chartsengine.rcp.editors.ChartEditor;
9
import org.txm.utils.logger.Log;
8 10

  
9 11
/**
10
 * Resets the chart view of the active chart editor part.
12
 * Moves to the left the chart view of the active chart editor part.
11 13
 * 
12
 * @author sjacquot
14
 * @author mdecorde
13 15
 *
14 16
 */
15 17
public class MoveLeftChartView extends AbstractHandler {
......
23 25
			chartEditor.pan(0, 0, -1, 0, 0.1);
24 26
		}
25 27
		catch (Exception e) {
26
			// nothing to do
28
			Log.warning(NLS.bind("Error while moving to the left in {0}: {1}.", chartEditor, e));
27 29
		}
28 30
		return chartEditor;
29 31
	}
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/handlers/ResetChartView.java (revision 2753)
3 3
import org.eclipse.core.commands.AbstractHandler;
4 4
import org.eclipse.core.commands.ExecutionEvent;
5 5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.osgi.util.NLS;
6 7
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
7 8
import org.txm.chartsengine.rcp.editors.ChartEditor;
9
import org.txm.utils.logger.Log;
8 10

  
9 11
/**
10 12
 * Resets the chart view of the active chart editor part.
11 13
 * 
12
 * @author sjacquot
14
 * @author sjacquot, mdecorde
13 15
 *
14 16
 */
15 17
public class ResetChartView extends AbstractHandler {
16

  
17

  
18
	
18 19
	@Override
19 20
	public Object execute(ExecutionEvent event) throws ExecutionException {
20 21
		ChartEditor chartEditor = SWTChartsComponentsProvider.getActiveChartEditor(event);
......
23 24
			chartEditor.resetView();
24 25
		}
25 26
		catch (Exception e) {
26
			// nothing to do
27
			Log.warning(NLS.bind("Error while resetting view in {0}: {1}.", chartEditor, e));
27 28
		}
28 29
		return chartEditor;
29 30
	}
30

  
31
	
31 32
}
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/handlers/MoveRightChartView.java (revision 2753)
3 3
import org.eclipse.core.commands.AbstractHandler;
4 4
import org.eclipse.core.commands.ExecutionEvent;
5 5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.osgi.util.NLS;
6 7
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
7 8
import org.txm.chartsengine.rcp.editors.ChartEditor;
9
import org.txm.utils.logger.Log;
8 10

  
9 11
/**
10
 * Resets the chart view of the active chart editor part.
12
 * Moves right the chart view of the active chart editor part.
11 13
 * 
12
 * @author sjacquot
14
 * @author mdecorde
13 15
 *
14 16
 */
15 17
public class MoveRightChartView extends AbstractHandler {
......
23 25
			chartEditor.pan(0, 0, 1, 0, 0.1);
24 26
		}
25 27
		catch (Exception e) {
26
			// nothing to do
28
			Log.warning(NLS.bind("Error while moving to the right in {0}: {1}.", chartEditor, e));
27 29
		}
28 30
		return chartEditor;
29 31
	}
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/handlers/ExportChart.java (revision 2753)
143 143
						}
144 144
						
145 145
						String outputFormat = SWTChartsComponentsProvider.getCurrent().getChartsEngineSupportedExportFileFormats().get(dialog.getFilterIndex());
146
						ChartsEngine.getCurrent().exportChart(chartResult, file, 1024, 576, outputFormat);
146
						ChartsEngine.getCurrent().exportResultToFile(chartResult, file, 1024, 576, outputFormat);
147 147
						
148 148
						if (file.exists()) {
149 149
							
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/handlers/ExportChartEditorView.java (revision 2753)
49 49
import org.txm.core.messages.TXMCoreMessages;
50 50
import org.txm.core.preferences.TBXPreferences;
51 51
import org.txm.rcp.JobsTimer;
52
import org.txm.rcp.StatusLine;
53 52
import org.txm.rcp.commands.OpenGraph;
54 53
import org.txm.rcp.messages.TXMUIMessages;
55 54
import org.txm.rcp.swt.dialog.LastOpened;
......
65 64
 *
66 65
 */
67 66
public class ExportChartEditorView extends AbstractHandler implements IHandler2 {
68

  
67
	
69 68
	public static final String ID = "org.txm.chartsengine.rcp.handlers.ExportChartEditorView"; //$NON-NLS-1$
70

  
71 69
	
70
	
72 71
	@Override
73 72
	public Object execute(ExecutionEvent event) throws ExecutionException {
74

  
73
		
75 74
		final ChartEditor chartEditor = SWTChartsComponentsProvider.getActiveChartEditor(event);
76 75
		
77 76
		Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
78 77
		final FileDialog dialog = new FileDialog(shell, SWT.SAVE);
79

  
78
		
80 79
		// Create the file extensions from the current chart editor supported file formats
81 80
		String extensions[] = new String[chartEditor.getEditorSupportedExportFileFormats().size()];
82 81
		int defaultChartFormatIndex = 0;
83
		for(int i = 0; i < chartEditor.getEditorSupportedExportFileFormats().size(); i++) {
82
		for (int i = 0; i < chartEditor.getEditorSupportedExportFileFormats().size(); i++) {
84 83
			extensions[i] = "*." + chartEditor.getEditorSupportedExportFileFormats().get(i); //$NON-NLS-1$
85

  
84
			
86 85
			// Store the default chart export file format index
87
			if(ChartsEnginePreferences.getInstance().getString(ChartsEnginePreferences.DEFAULT_EXPORT_FORMAT).equals(chartEditor.getEditorSupportedExportFileFormats().get(i)))	{
86
			if (ChartsEnginePreferences.getInstance().getString(ChartsEnginePreferences.DEFAULT_EXPORT_FORMAT).equals(chartEditor.getEditorSupportedExportFileFormats().get(i))) {
88 87
				defaultChartFormatIndex = i;
89 88
			}
90 89
		}
91

  
90
		
92 91
		dialog.setFilterExtensions(extensions);
93 92
		
94 93
		// Select default chart export file format according to the user preferences
......
97 96
		dialog.setFileName(chartEditor.getResult().getValidFileName());
98 97
		
99 98
		dialog.setOverwrite(true);
100

  
101

  
102
		if(LastOpened.getFile(ID) != null) {
99
		
100
		
101
		if (LastOpened.getFile(ID) != null) {
103 102
			dialog.setFilterPath(LastOpened.getFolder(ID));
104 103
		}
105

  
106
		if(dialog.open() != null) {
104
		
105
		if (dialog.open() != null) {
107 106
			String filepath = dialog.getFilterPath() + "/" + dialog.getFileName(); //$NON-NLS-1$
108 107
			String suffix = extensions[dialog.getFilterIndex()].substring(1); // get selected extension and remove the character '*'
109 108
			if (!filepath.endsWith(suffix)) {
......
112 111
			final File file = new File(filepath);
113 112
			
114 113
			LastOpened.set(ID, file.getParent(), file.getName());
115

  
114
			
116 115
			try {
117 116
				file.createNewFile();
118 117
			}
119
			catch(IOException e1) {
118
			catch (IOException e1) {
120 119
				Log.severe(TXMCoreMessages.bind(TXMUIMessages.exportColonCantCreateFileP0ColonP1, file, e1));
121 120
			}
122
			if(!file.canWrite()) {
121
			if (!file.canWrite()) {
123 122
				Log.severe(TXMCoreMessages.bind(TXMUIMessages.impossibleToReadP0, file));
124 123
			}
125
			if(!file.isFile()) {
124
			if (!file.isFile()) {
126 125
				Log.severe(TXMCoreMessages.bind("Error: {0} is not a file.", file));
127 126
			}
128

  
127
			
129 128
			JobHandler jobhandler = new JobHandler(TXMCoreMessages.bind("Exporting current chart view to file {0}...", file.getAbsolutePath())) {
129
				
130 130
				@Override
131 131
				protected IStatus run(IProgressMonitor monitor) {
132 132
					try {
133 133
						this.runInit(monitor);
134 134
						monitor.beginTask(TXMUIMessages.exporting, 100);
135

  
135
						
136 136
						String outputFormat = (String) chartEditor.getEditorSupportedExportFileFormats().get(dialog.getFilterIndex());
137 137
						chartEditor.exportView(file, outputFormat);
138

  
139
						if(file.exists()) {
140

  
138
						
139
						if (file.exists()) {
140
							
141 141
							Log.info(NLS.bind(TXMUIMessages.p1ExportSavedInFileColonP0, file.getAbsolutePath(), outputFormat.toUpperCase()));
142

  
142
							
143 143
							// Open internal editor in the UI thread
144
							if(TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPORT_SHOW))	{
144
							if (TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPORT_SHOW)) {
145 145
								this.syncExec(new Runnable() {
146
									
146 147
									@Override
147 148
									public void run() {
148 149
										OpenGraph.OpenFile(file.getAbsolutePath());
......
154 155
							Log.severe(NLS.bind(TXMUIMessages.failedToExportInFileP0WithFormatP1, file.getAbsolutePath(), outputFormat));
155 156
						}
156 157
					}
157
					catch(ThreadDeath td) {
158
					catch (ThreadDeath td) {
158 159
						return Status.CANCEL_STATUS;
159 160
					}
160
					catch(Exception e) {
161
					catch (Exception e) {
161 162
						org.txm.utils.logger.Log.printStackTrace(e);
162 163
						return Status.CANCEL_STATUS;
163 164
					}
......
168 169
					return Status.OK_STATUS;
169 170
				}
170 171
			};
171

  
172
			
172 173
			jobhandler.startJob();
173

  
174
			
174 175
		}
175 176
		return null;
176 177
	}
177
}
178
}
tmp/org.txm.ahc.core/src/org/txm/ahc/core/chartsengine/r/RAHCChartCreator.java (revision 2753)
15 15
public class RAHCChartCreator extends RChartCreator<AHC> {
16 16
	
17 17
	@Override
18
	public void updateChart(AHC result) {
18
	public File createChart(AHC result, File file) {
19 19
		
20 20
		AHC ahc = result;
21
		File chart = (File) result.getChart();
22 21
		
23 22
		String cmd = null;
24 23
		// 2D
......
37 36
			cmd = "plot.HCPC(" + ahc.getRSymbol() + ", new.plot=FALSE)";
38 37
		}
39 38
		
40
		this.getChartsEngine().plot(chart, cmd);
39
		return this.getChartsEngine().plot(file, cmd);
41 40
	}
42 41
	
43 42
	
tmp/org.txm.chartsengine.graphstream.core/src/org/txm/chartsengine/graphstream/core/GSChartsEngine.java (revision 2753)
102 102
	 * @see org.txm.chartsengine.core.ChartsEngine#exportChart(java.lang.Object, java.io.File, java.lang.String, int, int, int, int, int, int)
103 103
	 */
104 104
	@Override
105
	public File exportChart(Object chart, File file, String outputFormat, int imageWidth, int imageHeight, int drawingAreaX, int drawingAreaY, int drawingAreaWidth, int drawingAreaHeight) {
105
	public File exportChartToFile(Object chart, File file, String outputFormat, int imageWidth, int imageHeight, int drawingAreaX, int drawingAreaY, int drawingAreaWidth, int drawingAreaHeight) {
106 106
		// TODO Auto-generated method stub
107 107
		return null;
108 108
	}
......
128 128
	}
129 129
	
130 130
	@Override
131
	public File exportChart(ChartResult result, File file, int imageWidth, int imageHeight, String outputFormatSvg) {
131
	public File exportResultToFile(ChartResult result, File file, int imageWidth, int imageHeight, String outputFormatSvg) {
132 132
		// TODO Auto-generated method stub
133 133
		return null;
134 134
	}
135 135
	
136
	
137
	@Override
138
	public File writeChartResultFile(ChartResult result, int imageWidth, int imageHeight, String outputFormat) {
139
		// TODO Auto-generated method stub
140
		return null;
141
	}
142
	
136 143
}
tmp/org.txm.chartsengine.svgbatik.rcp/src/org/txm/chartsengine/svgbatik/rcp/swing/SVGCanvas.java (revision 2753)
33 33
import java.awt.event.MouseWheelEvent;
34 34
import java.awt.event.MouseWheelListener;
35 35
import java.awt.geom.AffineTransform;
36
import java.awt.geom.Dimension2D;
36 37
import java.util.List;
37 38

  
38 39
import org.apache.batik.swing.JSVGCanvas;
......
361 362
	public void pan(double srcX, double srcY, double dstX, double dstY, double panFactor) {
362 363
		
363 364
		AffineTransform trans = this.getRenderingTransform();
364
		trans.translate(-dstX * panFactor, dstY * panFactor);
365
		Dimension2D size = this.getSVGDocumentSize(); // adapt the pan to the SVG size
366
		trans.translate(-dstX * panFactor * size.getWidth(), dstY * panFactor * size.getHeight());
365 367
		this.setRenderingTransform(trans);
366 368
		
367 369
	}
tmp/org.txm.chartsengine.svgbatik.rcp/src/org/txm/chartsengine/svgbatik/rcp/swt/SVGChartComposite.java (revision 2753)
19 19
import org.apache.batik.transcoder.svg2svg.SVGTranscoder;
20 20
import org.eclipse.swt.SWT;
21 21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Display;
23 22
import org.txm.chartsengine.core.ChartsEngine;
24 23
import org.txm.chartsengine.core.results.ChartResult;
25 24
import org.txm.chartsengine.rcp.IChartComponent;
......
66 65
	
67 66
	@Override
68 67
	public void loadChart(Object chart) {
68
		ChartsEngine engine = chartEditor.getChartsEngine();
69
		ChartResult result = chartEditor.getResult();
70
		int w = this.getSize().x;
71
		int h = this.getSize().y;
69 72
		
70
		// need to be async (the composite needs to be realized before using its size in export)
71
		Display.getDefault().asyncExec(new Runnable() {
72
			
73
			@Override
74
			public void run() {
75
				
76
				// create the chart file if not of the right type
77
				if (!(chart instanceof File)) {
78
					ChartResult result = chartEditor.getResult();
79
					// result.setChart(null);
80
					file = chartEditor.getSWTChartsComponentsProvider().getChartsEngine().getChartCreator(result).createChartFile(result, file, getSize().x, getSize().y);
81
					// System.out.println("SVGChartComposite.loadChart() get size: " + chartEditor.getResultArea().getSize());
82
					// result.setChart(this.file);
83
				}
84
				else {
85
					file = (File) chart;
86
				}
87
				
88
				
89
				loadSVGDocument(file);
90
				
91
				// ChartsEngine engine = chartEditor.getChartsEngine();
92
				// ChartResult result = chartEditor.getResult();
93
				// int w = this.getSize().x;
94
				// int h = this.getSize().y;
95
				// if (w == 0 || h == 0) { // if the composite is not drawn (editor is opening), the chart file size is set to 600*400 by default, TODO resetView() should show-zoom the chart
96
				// w = 600;
97
				// h = 400;
98
				// }
99
				// File file = engine.exportChart(result, w, h, ChartsEngine.OUTPUT_FORMAT_SVG);
100
				//
101
				// this.loadSVGDocument(file);
102
				
103
				
104
			}
105
		});
73
		// an alternative way is to always call this in a Display.asyncExec() to ensure the widget size is computed -> slow the display
74
		if (w == 0 || h == 0) { // if the composite is not drawn (editor is opening), the chart file size is set to 600*400 by default, TODO resetView() should show-zoom the chart
75
			w = 600;
76
			h = 400;
77
		}
78
		File file = engine.writeChartResultFile(result, w, h, ChartsEngine.OUTPUT_FORMAT_SVG);
106 79
		
80
		this.loadSVGDocument(file);
107 81
	}
108 82
	
109 83
	
......
134 108
				
135 109
				try {
136 110
					Log.fine(TXMCoreMessages.bind("Loading SVG document from file: {0}...", file.getAbsolutePath()));
137
					Log.finest("SVGChartComposite.loadSVGDocument(...).new Runnable() {...}.run() SVGCanvas size = " + getSVGCanvas().getSize());
138 111
					
139 112
					getSVGCanvas().loadSVGDocument(file.toURL().toExternalForm());
140 113
					
tmp/org.txm.partition.core/src/org/txm/partition/core/chartsengine/r/RPartitionDimensionsPieChartCreator.java (revision 2753)
21 21
	
22 22
	
23 23
	@Override
24
	public void updateChart(PartitionDimensions result) {
24
	public File createChart(PartitionDimensions result, File file) {
25 25
		
26 26
		try {
27 27
			
28 28
			PartitionDimensions partitionDimensions = result;
29
			File chart = (File) result.getChart();
30 29
			
31 30
			
32 31
			// parameters
......
70 69
			String cmd = String.format("pie(%s, col=colors, labels=%s, horiz=F, las=2, ylab=\"%s\");\n", ssizes, snames, ylab); //$NON-NLS-1$
71 70
			
72 71
			// plot the chart
73
			this.getChartsEngine().plot(chart, cmd, result, Utils.createPartitionDimensionsChartTitle(partitionDimensions), Utils.createPartitionDimensionsChartSubtitle(partitionDimensions,
72
			this.getChartsEngine().plot(file, cmd, result, Utils.createPartitionDimensionsChartTitle(partitionDimensions), Utils.createPartitionDimensionsChartSubtitle(partitionDimensions,
74 73
					sortPartsBySize, displayPartsCountInTitle));
75 74
			
76 75
		}
77 76
		catch (Exception e) {
78 77
			Log.severe(PartitionCoreMessages.bind(PartitionCoreMessages.cantCreateDimensionsPartitionChartFileChartsEngineColonP0, RChartsEngine.DESCRIPTION) + e);
79 78
		}
79
		
80
		return file;
80 81
	}
81 82
	
82 83
	
tmp/org.txm.partition.core/src/org/txm/partition/core/chartsengine/r/RPartitionDimensionsBarChartCreator.java (revision 2753)
21 21

  
22 22
	
23 23
	@Override
24
	public void updateChart(PartitionDimensions result) {
24
	public File createChart(PartitionDimensions result, File file) {
25 25

  
26 26
		try {
27 27
			
28 28
			PartitionDimensions partitionDimensions = (PartitionDimensions) result;
29
			File chart = (File) result.getChart();
30 29
			
31 30
			
32 31
			// parameters
......
71 70
			String cmd = String.format("barplot(%s, col=colors, names.arg=%s, horiz=F, las=2, ylab=\"%s\", xlab=\"%s\");\n", ssizes, snames, PartitionCoreMessages.numberOfWords, PartitionCoreMessages.part); //$NON-NLS-1$
72 71
			
73 72
			// plot the chart
74
			this.getChartsEngine().plot(chart, cmd, result, Utils.createPartitionDimensionsChartTitle(partitionDimensions), Utils.createPartitionDimensionsChartSubtitle(partitionDimensions, sortPartsBySize, displayPartsCountInTitle));
73
			this.getChartsEngine().plot(file, cmd, result, Utils.createPartitionDimensionsChartTitle(partitionDimensions), Utils.createPartitionDimensionsChartSubtitle(partitionDimensions, sortPartsBySize, displayPartsCountInTitle));
75 74
			
76 75
		}
77 76
		catch(Exception e) {
......
79 78
			Log.printStackTrace(e);
80 79
		}
81 80

  
81
		return file;
82 82
	}
83 83

  
84 84
	
tmp/org.txm.chartsengine.r.core/src/org/txm/chartsengine/r/core/RChartsEngine.java (revision 2753)
5 5
import java.util.ArrayList;
6 6

  
7 7
import org.eclipse.core.runtime.IProgressMonitor;
8
import org.eclipse.osgi.util.NLS;
8 9
import org.txm.chartsengine.core.ChartsEngine;
9 10
import org.txm.chartsengine.core.results.ChartResult;
10 11
import org.txm.chartsengine.r.core.preferences.RChartsEnginePreferences;
......
68 69
		this(RChartsEnginePreferences.getInstance().getString(RChartsEnginePreferences.OUTPUT_FORMAT));
69 70
	}
70 71
	
71
	
72
	/**
73
	 * Export a chart in a file
74
	 * 
75
	 * @param result
76
	 * @param outputFormatSvg
77
	 * @return
78
	 */
72 79
	@Override
73
	public File exportChart(ChartResult result, File file, int imageWidth, int imageHeight, String outputFormat) {
74
		return this.exportChart(result.getChart(), file, outputFormat, imageWidth, imageHeight, -1, -1, -1, -1);
80
	public File writeChartResultFile(ChartResult result, int imageWidth, int imageHeight, String outputFormat) {
81
		return exportResultToFile(result, null, imageWidth, imageHeight, outputFormat);
75 82
	}
76 83
	
77 84
	
78 85
	@Override
79
	public File exportChart(Object chart, File file, String outputFormat, int imageWidth, int imageHeight, int drawingAreaX, int drawingAreaY, int drawingAreaWidth, int drawingAreaHeight) {
80
		// FIXME: Not yet implemented
86
	public File exportResultToFile(ChartResult result, File file, int imageWidth, int imageHeight, String outputFormat) {
87
		Object chart = result.getChart();
88
		if (chart == null) {
89
			Log.warning("Error: no chart to export (null). The result was never computed?");
90
			return null;
91
		}
92
		
93
		if (!(chart instanceof File)) {
94
			Log.warning("Error: RChartEngine only manage File charts: " + chart);
95
			return null;
96
		}
97
		
98
		if (this.getOutputFormat().equals(outputFormat)) {//
99
			if (!((File) chart).exists()) {
100
				result.getChartCreator().updateChart(result);
101
			}
102
			
103
			return exportChartToFile(chart, file, outputFormat, imageWidth, imageHeight);
104
		}
105
		else {
106
			Log.warning(NLS.bind("Error: RChartEngine export format ({0}) cannot differ from the current display format ({1})", outputFormat, this.getOutputFormat()));
107
		}
108
		return null;
109
	}
110
	
111
	@Override
112
	public File exportChartToFile(Object chart, File file, String outputFormat, int imageWidth, int imageHeight, int drawingAreaX, int drawingAreaY, int drawingAreaWidth, int drawingAreaHeight) {
81 113
		Log.finest(this.getClass() + ".exportChart(): Not fully implemented. Output format, Image dimensions and cropping are not implemented.");
82 114
		
83
		if (file.equals(chart)) {
115
		if (file == null || file.equals(chart)) {
84 116
			return (File) chart; // no need to redraw the chart
85 117
		}
86 118
		else {
......
92 124
				// TODO Auto-generated catch block
93 125
				e.printStackTrace();
94 126
			}
95
			return null;
96 127
		}
128
		return null;
97 129
	}
98 130
	
99
	
100 131
	/**
101 132
	 * Plots the specified expression using R workspace instance and current charts engine output format.
102 133
	 * 
tmp/org.txm.chartsengine.r.core/src/org/txm/chartsengine/r/core/RChartCreator.java (revision 2753)
13 13
/**
14 14
 * R base chart creator.
15 15
 * 
16
 * Currently the R chart creator can't update a chart = a File. It is always recreated in the updateChart method
17
 * 
18
 * An empty file is created in the createChart method
19
 * 
16 20
 * @author sjacquot
17 21
 *
18 22
 */
19 23
public abstract class RChartCreator<R extends ChartResult> extends ChartCreator<RChartsEngine, R> {
20 24
	
21
	
25
	/**
26
	 * creates an empty file. the chart will be written after in the updateChart method
27
	 */
22 28
	@Override
23 29
	public Object createChart(R result) {
24
		// creates a new chart file if not exist
25
		if (result.getChart() == null) {
26
			File chart = this.getChartsEngine().createTmpFile(this.getFileNamePrefix());
27
			result.setChart(chart);
28
			return chart;
30
		if (result.getChart() != null && result.getChart() instanceof File) { // we can re-use the file if already defined
31
			return result.getChart();
29 32
		}
30 33
		else {
31
			return result.getChart();
34
			return this.getChartsEngine().createUniqTmpFile(result, this.getFileNamePrefix());
32 35
		}
33 36
	}
34 37
	
38
	/**
39
	 * Effectively writes the R chart in the given file
40
	 * 
41
	 * @param result
42
	 * @param file the file to write. not null
43
	 * @return
44
	 */
45
	public abstract File createChart(R result, File file);
35 46
	
36 47
	@Override
48
	public void updateChart(R result) {
49
		
50
		Object chart = result.getChart();
51
		
52
		if (chart instanceof File) { // The RChartCreators can't really update a chart -> the chart is always recreated
53
			createChart(result, (File) chart);
54
		}
55
		else {
56
			Log.warning("Error: R chart was null in: " + result);
57
		}
58
	}
59
	
60
	@Override
37 61
	public ArrayList<Color> getSeriesShapesColors(Object chart) {
38 62
		Log.severe(this.getClass() + ".getSeriesShapesColors(): Not yet implemented."); //$NON-NLS-1$
39 63
		return null;
tmp/org.txm.progression.core/src/org/txm/progression/core/chartsengine/r/RProgressionDensityChartCreator.java (revision 2753)
1 1
package org.txm.progression.core.chartsengine.r;
2 2

  
3
import java.io.File;
4

  
3 5
import org.txm.progression.core.functions.Progression;
4 6

  
5 7
/**
......
12 14
	
13 15
	
14 16
	@Override
15
	public void updateChart(Progression result) {
16
		super.updateChart(result, false);
17
	public File createChart(Progression result, File file) {
18
		return super.createChart(result, file, false);
17 19
	}
18 20
	
19 21
	
tmp/org.txm.progression.core/src/org/txm/progression/core/chartsengine/r/RProgressionBaseChartCreator.java (revision 2753)
37 37
	 * @param cumulative
38 38
	 * @return
39 39
	 */
40
	public void updateChart(Progression result, boolean cumulative) {
40
	public File createChart(Progression result, File file, boolean cumulative) {
41 41
		
42 42
		try {
43 43
			
44 44
			Progression progression = result;
45
			File chart = (File) result.getChart();
46 45
			
47 46
			// boolean cumulative = result.getBooleanParameterValue(ProgressionPreferences.CHART_CUMULATIVE);
48 47
			
......
135 134
			String cmd = "progression(positions, names, colors, styles, widths, \"" + name + "\"," + progression.getXminCorpus() + "," + progression.getXmaxCorpus() + ",\"" + cumulative //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
136 135
					+ "\",structurepositions,structurenames, \"\", " + progression.getBande() + ");\n";  //$NON-NLS-1$ //$NON-NLS-2$
137 136
			
138
			this.getChartsEngine().plot(chart, cmd, result, StringEscapeUtils.escapeJava(Utils.createProgressionChartTitle(progression, cumulative)), null);
137
			this.getChartsEngine().plot(file, cmd, result, StringEscapeUtils.escapeJava(Utils.createProgressionChartTitle(progression, cumulative)), null);
139 138
			
140 139
			RWorkspace.getRWorkspaceInstance().eval(Progression.prefixR + Progression.norep + " <- list(positions=positions, names=names, xmin=" + progression.getXminCorpus() + ",xmax=" + progression //$NON-NLS-1$ //$NON-NLS-2$
141 140
					.getXmaxCorpus() + ", structpositions=structurepositions, structnames=structurenames)");  //$NON-NLS-1$
......
145 144
			// TODO Auto-generated catch block
146 145
			org.txm.utils.logger.Log.printStackTrace(e);
147 146
		}
147
		
148
		return file;
148 149
	}
149 150
	
150 151
	
tmp/org.txm.progression.core/src/org/txm/progression/core/chartsengine/r/RProgressionCumulativeChartCreator.java (revision 2753)
1 1
package org.txm.progression.core.chartsengine.r;
2 2

  
3
import java.io.File;
4

  
3 5
import org.txm.progression.core.functions.Progression;
4 6

  
5 7
// FIXME: SJ: this chart creator has been disabled in extension definition to force JFC mode for Cumulative chart and R mode for Density chart since the Density chart is not yet implemented in JFC charts engine  
......
13 15
	
14 16
	
15 17
	@Override
16
	public void updateChart(Progression result) {
17
		super.updateChart(result, true);
18
	public File createChart(Progression result, File file) {
19
		return super.createChart(result, file, true);
18 20
	}
19 21
	
20 22
}
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff