Revision 584

tmp/org.txm.specificities.core/src/org/txm/specificities/core/chartsengine/jfreechart/JFCSpecificitiesBarChartCreator.java (revision 584)
97 97

  
98 98
		
99 99
		// Transpose or not / group by lines or not
100
        if(result.hasRenderingParameterChanged(SpecificitiesPreferences.CHART_TRANSPOSE))	{
100
        if(result.hasParameterChanged(SpecificitiesPreferences.CHART_TRANSPOSE))	{
101 101
        
102 102
			// Fill the data set
103 103
			XYSeriesCollection dataset = (XYSeriesCollection) chart.getXYPlot().getDataset();
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 584)
221 221
	 * @param parameterType
222 222
	 * @return
223 223
	 */
224
	protected Object getParameter(String key, int parameterType) {
224
	protected Object getParameter(String key) {
225 225

  
226 226
		List<Field> fields = this.getAllFields();
227 227
		
228 228
		for (Field f : fields) {
229 229
			Parameter parameter = f.getAnnotation(Parameter.class);
230
			if (parameter == null || parameter.type() != parameterType) {
230
			if (parameter == null) {
231 231
				continue;
232 232
			}
233 233
			f.setAccessible(true);
......
245 245

  
246 246
	
247 247
	/**
248
	 * Gets a current computing parameter specified by its annotation "key" attribute.
249
	 * @param key
250
	 * @return
251
	 */
252
	protected Object getParameter(String key) {
253
		return this.getParameter(key, Parameter.COMPUTING);
254
	}
255

  
256
	
257
	/**
258
	 * Checks if a computing parameter value has changed since last computing. 
259
	 * @param key
260
	 * @return
261
	 */
262
	public boolean hasParameterChanged(String key) {
263
		return this.hasParameterChanged(key, Parameter.COMPUTING);
264
	}
265
	
266
	/**
267 248
	 * Checks if a parameter value has changed since last computing.
268 249
	 * @param key
269 250
	 * @param parameterType
270 251
	 * @return
271 252
	 */
272
	public boolean hasParameterChanged(String key, int parameterType) {
253
	public boolean hasParameterChanged(String key) {
273 254
		if (key.isEmpty()) {
274 255
			return false;
275 256
		}
276 257
		Object lastValue = this.lastParameters.get(key);
277
		Object newValue = this.getParameter(key, parameterType);
258
		Object newValue = this.getParameter(key);
278 259
		if (lastValue == null) {
279 260
			if(newValue != null)	{
280 261
				return true;
......
606 587
	}
607 588

  
608 589
	
590
	/**
591
	 * 
592
	 * @return
593
	 * @throws Exception
594
	 */
609 595
	protected boolean loadGenericParameters() throws Exception {
610 596
		return this.loadGenericParameters(Parameter.COMPUTING);
611 597
	}
......
1224 1210
		return this.compute(false, null);
1225 1211
	}
1226 1212

  
1213
	
1227 1214
	/**
1215
	 * 
1216
	 * @param update
1217
	 * @param monitor
1218
	 * @return
1219
	 * @throws Exception
1220
	 */
1221
	public boolean compute(boolean update, IProgressMonitor monitor) throws Exception {
1222
		return this.compute(update, monitor, true);
1223
	}
1224
	
1225
	/**
1228 1226
	 * Computes the result if 
1229 1227
	 * it can be computed 
1230 1228
	 * it is dirty 
......
1241 1239
	 * @throws CqiClientException
1242 1240
	 * @throws IOException
1243 1241
	 */
1244
	public boolean compute(boolean update, IProgressMonitor monitor) throws Exception {
1242
	protected boolean compute(boolean update, IProgressMonitor monitor, boolean updateLastParameters) throws Exception {
1245 1243

  
1246 1244
		this.monitor = monitor;
1247 1245

  
......
1288 1286
			return false;
1289 1287
		}
1290 1288

  
1291
		this.updateLastParameters(); // store last used parameters
1289
		// store last used parameters
1290
		if(updateLastParameters)	{
1291
			this.updateLastParameters();
1292
		}
1292 1293

  
1293 1294
		if (!this.saveParameters()) {
1294 1295
			System.out.println("Warning: failed to save parameters for " + this.getName() + ".");
tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/results/ChartResult.java (revision 584)
137 137
				&& super.loadGenericParameters(Parameter.RENDERING));
138 138
	}
139 139

  
140
	
141
	
142
//	/**
143
//	 * Checks if a parameter value has changed since last rendering. 
144
//	 * @param key
145
//	 * @return
146
//	 */
147
//	public boolean hasRenderingParameterChanged(String key) {
148
//		if (key.isEmpty()) {
149
//			return false;
150
//		}
151
//		Object lastValue = this.lastRenderingParameters.get(key);
152
//		Object newValue = this.getRenderingParameter(key);
153
//		if (lastValue == null) {
154
//			if(newValue != null)	{
155
//				return true;
156
//			}
157
//			else	{
158
//				return false;
159
//			}
160
//		}
161
//		else {
162
//			return !lastValue.equals(newValue);
163
//		}
164
//	}
165 140

  
166 141

  
167

  
168 142
	
169 143
	
170 144
	@Override
......
174 148
		System.err.println("************** ChartResult.compute(): computing result of type " + this.getClass() + "...");
175 149
//
176 150
		// compute the result if needed
177
		if(super.compute(update, monitor))	{
151
		if(super.compute(update, monitor, false))	{
178 152
			// compute the chart
179 153
			return renderChart(update);
180 154
		}
......
217 191
			
218 192

  
219 193
			// Creating, if needed
220
			if(this.hasRenderingParameterChanged(ChartsEnginePreferences.CHART_TYPE))	{
194
			if(this.hasParameterChanged(ChartsEnginePreferences.CHART_TYPE))	{
221 195
				// FIXME: debug
222 196
				System.err.println("ChartResult.renderChart(): creating chart.");
223 197
				
......
231 205
			// FIXME: the update must be done here (BEFORE the call of this.updateLastRenderingParameters()) rather than in the SWTChartComponentsProvider => the problem is that for File based Engine, the file may be created twice, need to check this
232 206
			chartCreator.updateChart(this);
233 207
			
208
			this.updateLastParameters();
234 209
			this.updateLastRenderingParameters();
235 210
			
236 211
			
......
259 234
		this.updateLastParameters(Parameter.RENDERING);
260 235
	}
261 236
	
262
	/**
263
	 * Checks if a rendering parameter value has changed since last computing. 
264
	 * @param key
265
	 * @return
266
	 */
267
	public boolean hasRenderingParameterChanged(String key) {
268
		return this.hasParameterChanged(key, Parameter.RENDERING);
269
	}
270 237
	
271 238
	
272 239
	public final boolean isChartDirtyFromHistory() throws Exception {
273
		Class clazz = this.getClass();
240
		
241
		List<Field> fields = this.getAllFields();
274 242

  
275
		Field[] fields = clazz.getDeclaredFields();
276 243
		for (Field f : fields) {
277 244
			Parameter parameter = f.getAnnotation(Parameter.class);
278 245
			if (parameter == null || parameter.type() != Parameter.RENDERING) {
tmp/org.txm.progression.core/src/org/txm/progression/core/functions/Progression.java (revision 584)
245 245
		for (int i = 0 ; i < DefaultTheme.monoWidths.length ; i++) {
246 246
			DefaultTheme.monoWidths[i] = lineWidth;
247 247
		}
248
		if(this.queries != queries)	{
249
			this.setDirty();	
250
		}
251
		else	{
252
			this.setChartDirty();
253
		}
248
//		if(this.queries != queries)	{
249
//			this.setDirty();	
250
//		}
251
//		else	{
252
//			this.setChartDirty();
253
//		}
254 254
		
255 255
	}
256 256
	
......
534 534
	}
535 535

  
536 536
	/**
537
	 * Gets the allpositions.
538
	 *
539
	 * @return the allpositions
537
	 * @return the allPositions
540 538
	 */
541
	public List<int[]> getAllpositions() {
539
	public List<int[]> getAllPositions() {
542 540
		return allPositions;
543 541
	}
544 542

  
543

  
545 544
	/**
546 545
	 * Gets the positions counts.
547 546
	 *
......
549 548
	 */
550 549
	public List<Integer> getPositionsCounts() {
551 550
		ArrayList<Integer> counts = new ArrayList<Integer>();
552
		for (int[] list : allPositions)
551
		for (int[] list : allPositions) {
553 552
			counts.add(list.length);
553
		}
554 554
		return counts;
555 555
	}
556 556

  
......
612 612
	
613 613
	
614 614
	/**
615
	 * @return the allPositions
616
	 */
617
	public List<int[]> getAllPositions() {
618
		return allPositions;
619
	}
620

  
621
	/**
622 615
	 * @return the structurePositions
623 616
	 */
624 617
	public int[] getStructurePositions() {
tmp/org.txm.progression.core/src/org/txm/progression/core/chartsengine/r/RProgressionChartCreator.java (revision 584)
2 2

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

  
6 7
import org.apache.commons.lang.StringEscapeUtils;
7 8
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences;
......
41 42
			RWorkspace rw = RWorkspace.getRWorkspaceInstance();
42 43
			rw.eval("library(textometry)");
43 44
			// System.out.println("create list of positions");
45
			
46
			
47
			List<int[]> allPositions = progression.getAllPositions();
44 48
			String listString = "list("; //$NON-NLS-1$
45
			for(int i = 0; i < progression.getAllpositions().size(); i++) {
46
				int[] positions = progression.getAllpositions().get(i);
49
			for(int i = 0; i < allPositions.size(); i++) {
50
				int[] positions = allPositions.get(i);
47 51
				// System.out.println("add vector "+i);
48 52
				rw.eval("rm(x" + i + ")"); //$NON-NLS-1$ //$NON-NLS-2$
49 53
				rw.addVectorToWorkspace("x" + i, positions); //$NON-NLS-1$
tmp/org.txm.progression.core/src/org/txm/progression/core/chartsengine/jfreechart/JFCProgressionChartCreator.java (revision 584)
50 50
		
51 51
		JFreeChart chart = null;
52 52

  
53
		// Create the dataset
53
		// Creates the empty dataset
54 54
		XYSeriesCollection dataset = new XYSeriesCollection();
55
		List<int[]> positions = progression.getAllpositions();
56
		List<Query> queries = progression.getQueries();
57 55
		// Y axis label
58 56
		String yAxisLabel;
59 57

  
60 58
		
61 59
		// Cumulative
62 60
		if(cumulative)	{
63
			for(int i = 0; i < progression.getAllpositions().size(); i++) {
64
				int[] list = positions.get(i);
65
				Query query = queries.get(i);
66
				XYSeries series = new XYSeries(query.toString() + " " + list.length);
67
				int c = 1;
68
				for(int j = 0; j < list.length; j++) {
69
					// add a first point to draw a vertical line
70
					if(j == 0)	{
71
						series.add(list[j], 0);
72
					}
73
					series.add(list[j], c++);
74
				}
75 61

  
76
				// add a dummy point to draw horizontal line between last point and max X corpus
77
				series.add(progression.getXmaxCorpus(), --c);
78
				dataset.addSeries(series);
79
			}
80

  
81 62
			// Create the chart
82 63
			yAxisLabel = ProgressionCoreMessages.ChartsEngine_PROGRESSION_Y_AXIS_CUMULATIVE_LABEL;
83 64
			chart = this.getChartsEngine().createXYStepChart(dataset, Utils.createProgressionChartTitle(progression, cumulative),
......
89 70

  
90 71
		}
91 72
		// FIXME : Density, to implement when textometry R package will store the result in the Progression class
73
		// FIXME: put that in a new ChartCreator dedicated to the density progression chart
92 74
		else	{
93 75

  
94 76
			// FIXME : density not yet implemented
95 77
			System.err.println("JFCProgressionChartCreator.createChart(): density mode not yet implemented.");
96 78

  
97
			for(int i = 0; i < progression.getAllpositions().size(); i++) {
98
				int[] liste = positions.get(i);
99
				Query query = queries.get(i);
100
				XYSeries series = new XYSeries(query.toString() + " " + liste.length);
101

  
102
				for(int j = 0; j <  liste.length; j++) {
103

  
104
					// FIXME : tests y
105
					// y <- c( c(0), y , c(y[[length(x)]]) ) // R code
106
					// FIXME : random Y value
107
					double y = progression.getAllpositions().get(i)[j] * Math.random();
108
	//				double y = progression.getAllpositions().get(i)[j];
109
					series.add(liste[j], y);
110
				}
111
				dataset.addSeries(series);
112
			}
113

  
114
			// Create the chart
115
			yAxisLabel =  ProgressionCoreMessages.ChartsEngine_PROGRESSION_Y_AXIS_NOT_CUMULATIVE_LABEL;
116
			chart = this.getChartsEngine().createXYLineChart(dataset, Utils.createProgressionChartTitle(progression, cumulative),
117
					ProgressionCoreMessages.bind(ProgressionCoreMessages.ChartsEngine_PROGRESSION_X_AXIS_LABEL, progression.getXmaxCorpus()), yAxisLabel,
118
					true, true, true, false, true, false, true, null);
79
//			for(int i = 0; i < progression.getAllpositions().size(); i++) {
80
//				int[] liste = positions.get(i);
81
//				Query query = queries.get(i);
82
//				XYSeries series = new XYSeries(query.toString() + " " + liste.length);
83
//
84
//				for(int j = 0; j <  liste.length; j++) {
85
//
86
//					// FIXME : tests y
87
//					// y <- c( c(0), y , c(y[[length(x)]]) ) // R code
88
//					// FIXME : random Y value
89
//					double y = progression.getAllpositions().get(i)[j] * Math.random();
90
//	//				double y = progression.getAllpositions().get(i)[j];
91
//					series.add(liste[j], y);
92
//				}
93
//				dataset.addSeries(series);
94
//			}
95
//
96
//			// Create the chart
97
//			yAxisLabel =  ProgressionCoreMessages.ChartsEngine_PROGRESSION_Y_AXIS_NOT_CUMULATIVE_LABEL;
98
//			chart = this.getChartsEngine().createXYLineChart(dataset, Utils.createProgressionChartTitle(progression, cumulative),
99
//					ProgressionCoreMessages.bind(ProgressionCoreMessages.ChartsEngine_PROGRESSION_X_AXIS_LABEL, progression.getXmaxCorpus()), yAxisLabel,
100
//					true, true, true, false, true, false, true, null);
119 101
		}
120 102

  
121 103

  
......
123 105
        ((IRendererWithItemSelection) chart.getXYPlot().getRenderer()).setChartType(ChartsEngine.CHART_TYPE_PROGRESSION);
124 106
        ((IRendererWithItemSelection) chart.getXYPlot().getRenderer()).getItemsSelector().setResultData(progression);
125 107

  
126

  
127
		// Custom domain axis for ticks drawing options
128
		chart.getXYPlot().setDomainAxis(new ExtendedNumberAxis((NumberAxis) chart.getXYPlot().getDomainAxis(), true, true, progression.getXminCorpus(), progression.getXmaxCorpus()));
129

  
130
		// Custom range axis for ticks drawing options
131
		chart.getXYPlot().setRangeAxis(new ExtendedNumberAxis((NumberAxis) chart.getXYPlot().getRangeAxis(), false, true, 0, progression.getMaxY()));
132

  
133
		// Match the X-axis origin value to the min x corpus (for subcorpus case)
134
		chart.getXYPlot().getDomainAxis().setLowerBound(progression.getXminCorpus());
135

  
136
//		this.updateChart(result);
137 108
		
138 109
		return chart;
139 110
		
......
144 115
	public void updateChart(ChartResult result) {
145 116

  
146 117
		Progression progression = (Progression) result;
147
		
148 118
		JFreeChart chart = (JFreeChart) result.getChart();
119

  
120
		// freeze rendering while computing
121
		chart.setNotify(false);
149 122
		
123
		
124
		// Fill the data set from the result
125
		if(result.hasParameterChanged(ProgressionPreferences.QUERIES))	{
126
			XYSeriesCollection dataset = (XYSeriesCollection) chart.getXYPlot().getDataset();
127
			dataset.removeAllSeries();
128
			
129
			List<int[]> positions = progression.getAllPositions();
130
			List<Query> queries = progression.getQueries();
131
			for(int i = 0; i < positions.size(); i++) {
132
				int[] list = positions.get(i);
133
				Query query = queries.get(i);
134
				XYSeries series = new XYSeries(query.toString() + " " + list.length);
135
				int c = 1;
136
				for(int j = 0; j < list.length; j++) {
137
					// add a first point to draw a vertical line
138
					if(j == 0)	{
139
						series.add(list[j], 0);
140
					}
141
					series.add(list[j], c++);
142
				}
143
	
144
				// add a dummy point to draw horizontal line between last point and max X corpus
145
				series.add(progression.getXmaxCorpus(), --c);
146
				dataset.addSeries(series);
147
			}
148
			
149
			// Custom domain axis for ticks drawing options
150
			chart.getXYPlot().setDomainAxis(new ExtendedNumberAxis((NumberAxis) chart.getXYPlot().getDomainAxis(), true, true, progression.getXminCorpus(), progression.getXmaxCorpus()));
151

  
152
			// Custom range axis for ticks drawing options
153
			chart.getXYPlot().setRangeAxis(new ExtendedNumberAxis((NumberAxis) chart.getXYPlot().getRangeAxis(), false, true, 0, progression.getMaxY()));
154

  
155
			// Match the X-axis origin value to the min x corpus (for subcorpus case)
156
			chart.getXYPlot().getDomainAxis().setLowerBound(progression.getXminCorpus());
157

  
158
			
159
		}
160
		
161
		
162
		
150 163
		// removes all existing domain marker
151 164
		chart.getXYPlot().clearDomainMarkers();
152 165
		
tmp/org.txm.chartsengine.jfreechart.core/src/org/txm/chartsengine/jfreechart/core/JFCChartCreator.java (revision 584)
46 46

  
47 47
			
48 48
			// title visibility
49
			if(chart.getTitle() != null && result.hasRenderingParameterChanged(ChartsEnginePreferences.SHOW_TITLE))	{
49
			if(chart.getTitle() != null && result.hasParameterChanged(ChartsEnginePreferences.SHOW_TITLE))	{
50 50
				chart.getTitle().setVisible(result.isTitleVisible());
51 51
			}
52 52
			// legend visibility
53
			if(chart.getLegend() != null && result.hasRenderingParameterChanged(ChartsEnginePreferences.SHOW_LEGEND))	{
53
			if(chart.getLegend() != null && result.hasParameterChanged(ChartsEnginePreferences.SHOW_LEGEND))	{
54 54
				chart.getLegend().setVisible(result.isLegendVisible());
55 55
			}
56 56
			
57 57
			// grid visibility
58
			if(result.hasRenderingParameterChanged(ChartsEnginePreferences.SHOW_GRID))	{
58
			if(result.hasParameterChanged(ChartsEnginePreferences.SHOW_GRID))	{
59 59
				// CategoryPlot
60 60
				if(chart.getPlot() instanceof CategoryPlot)	{
61 61
					CategoryPlot plot = (CategoryPlot) chart.getPlot();
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages.properties (revision 584)
857 857
RVariablesView_2 = Show eval logs
858 858
RVariablesView_9 = "TXM name {0} >> R name {1}
859 859

  
860

  
860
ReferencerEditor_9  = Units
861 861
RefreshingCorporaView = Refreshing corpora...
862 862

  
863 863
RenameFile_0 = Rename file
tmp/org.txm.partition.core/src/org/txm/partition/core/chartsengine/jfreechart/JFCPartitionDimensionsPieChartCreator.java (revision 584)
57 57
		boolean displayPartsCountInTitle = partitionDimensions.isDisplayingPartCountInTitle();
58 58

  
59 59

  
60
		if(result.hasRenderingParameterChanged(ChartsEnginePreferences.CHART_TYPE)
61
				|| result.hasRenderingParameterChanged(PartitionDimensionsPreferences.CHART_DIMENSIONS_SORT_BY_SIZE))	{
60
		if(result.hasParameterChanged(ChartsEnginePreferences.CHART_TYPE)
61
				|| result.hasParameterChanged(PartitionDimensionsPreferences.CHART_DIMENSIONS_SORT_BY_SIZE))	{
62 62
			
63 63
			// Fill the data set from the result
64 64
			DefaultPieDataset dataset = (DefaultPieDataset)((PiePlot) chart.getPlot()).getDataset();
tmp/org.txm.partition.core/src/org/txm/partition/core/chartsengine/jfreechart/JFCPartitionDimensionsBarChartCreator.java (revision 584)
66 66
		boolean displayPartsCountInTitle = partitionDimensions.isDisplayingPartCountInTitle();
67 67
		
68 68
		
69
		if(result.hasRenderingParameterChanged(ChartsEnginePreferences.CHART_TYPE)
70
				|| result.hasRenderingParameterChanged(PartitionDimensionsPreferences.CHART_DIMENSIONS_SORT_BY_SIZE))	{
69
		if(result.hasParameterChanged(ChartsEnginePreferences.CHART_TYPE)
70
				|| result.hasParameterChanged(PartitionDimensionsPreferences.CHART_DIMENSIONS_SORT_BY_SIZE))	{
71 71
			
72 72
			// Fill the data set from the result
73 73
			XYSeriesCollection dataset = (XYSeriesCollection) chart.getXYPlot().getDataset();

Also available in: Unified diff