Révision 583

tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/results/ChartResult.java (revision 583)
38 38
	/**
39 39
	 * To keep track of the parameters used for the last computing and to determine if the chart result is dirty. 
40 40
	 */
41
	protected HashMap<String, Object> lastRenderingParameters = new HashMap<String, Object>();
41
	//protected HashMap<String, Object> lastRenderingParameters = new HashMap<String, Object>();
42 42

  
43 43
	
44 44
	/**
......
139 139

  
140 140
	
141 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
	}
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 165

  
166 166

  
167 167

  
......
252 252
	
253 253
	/**
254 254
	 * Updates the parameters used for last rendering.
255
	 * Loop through all inherited fields/parameters except those of the TXMResult class.
255
	 * 
256 256
	 * @throws Exception
257 257
	 */
258 258
	protected void updateLastRenderingParameters() throws Exception {
259

  
260
		List<Field> fields = new ArrayList<Field>();
261
		Class<?> clazz = this.getClass();
262
		while (clazz != TXMResult.class) {
263
			fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
264
			clazz = clazz.getSuperclass();
265
		}
266
		
267
		for (Field f : fields) {
268
			Parameter parameter = f.getAnnotation(Parameter.class);
269
			if (parameter == null || parameter.type() != Parameter.RENDERING) {
270
				continue;
271
			}
272
			
273
			String name;
274
			if(!"".equals(parameter.key()))	{
275
				name = parameter.key();
276
			}
277
			else	{
278
				name = f.getName();
279
			}
280
			
281
			f.setAccessible(true);
282
			this.lastRenderingParameters.put(name, f.get(this));
283
		}
259
		this.updateLastParameters(Parameter.RENDERING);
284 260
	}
285 261
	
286 262
	/**
287
	 * 
263
	 * Checks if a rendering parameter value has changed since last computing. 
288 264
	 * @param key
289 265
	 * @return
290 266
	 */
291
	protected Object getRenderingParameter(String key) {
292
		List<Field> fields = new ArrayList<Field>();
293
		Class<?> clazz = this.getClass();
294
		while (clazz != Object.class) {
295
			fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
296
			clazz = clazz.getSuperclass();
297
		}
298

  
299
		for (Field f : fields) {
300
			Parameter parameter = f.getAnnotation(Parameter.class);
301
			if (parameter == null || parameter.type() != Parameter.RENDERING) {
302
				continue;
303
			}
304
			f.setAccessible(true);
305
			if (parameter.key().equals(key)) {
306
				try {
307
					return f.get(this);
308
				}
309
				catch (Exception e) {
310
					e.printStackTrace();
311
				}
312
			}
313
		}
314
		return null;
267
	public boolean hasRenderingParameterChanged(String key) {
268
		return this.hasParameterChanged(key, Parameter.RENDERING);
315 269
	}
316 270
	
271
	
317 272
	public final boolean isChartDirtyFromHistory() throws Exception {
318 273
		Class clazz = this.getClass();
319 274

  
......
325 280
			}
326 281
			
327 282
			String name;
328
			if(!"".equals(parameter.key()))	{
283
			if(!parameter.key().isEmpty())	{
329 284
				name = parameter.key();
330 285
			}
331 286
			else	{
......
333 288
			}
334 289
			
335 290
			f.setAccessible(true); // not to set accessible to test the field values
336
			Object previousValue = this.lastRenderingParameters.get(name);
291
			Object previousValue = this.lastParameters.get(name);
337 292
			Object newValue = f.get(this);
338 293
			this.updateChartDirty(previousValue, newValue);
339 294
			if (this.chartDirty) {
tmp/org.txm.chartsengine.jfreechart.core/src/org/txm/chartsengine/jfreechart/core/themes/base/JFCTheme.java (revision 583)
19 19
import org.jfree.chart.LegendItemSource;
20 20
import org.jfree.chart.StandardChartTheme;
21 21
import org.jfree.chart.plot.CategoryPlot;
22
import org.jfree.chart.plot.PiePlot;
22 23
import org.jfree.chart.plot.Plot;
23 24
import org.jfree.chart.plot.SpiderWebPlot;
24 25
import org.jfree.chart.plot.XYPlot;
......
34 35
import org.jfree.chart.renderer.xy.XYStepRenderer;
35 36
import org.jfree.chart.title.LegendTitle;
36 37
import org.txm.chartsengine.core.ChartsEngine;
37
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences;
38 38
import org.txm.chartsengine.core.results.ChartResult;
39 39
import org.txm.chartsengine.jfreechart.core.JFCChartsEngine;
40 40
import org.txm.chartsengine.jfreechart.core.renderers.XYCardinalSplineRenderer;
41
import org.txm.core.results.TXMResult;
42 41

  
43 42
public class JFCTheme extends StandardChartTheme {
44 43

  
......
392 391
        		renderer.setSeriesPaint(i, palette.get(i));
393 392
			}
394 393
    	}
394
    	// SpiderPlot
395 395
    	else if(plot instanceof SpiderWebPlot)	{
396 396
    		SpiderWebPlot typedPlot = (SpiderWebPlot)plot;
397 397
    		palette = this.chartsEngine.getTheme().getPaletteFor(itemsColorsRenderingMode, typedPlot.getDataset().getRowCount());
......
399 399
        		typedPlot.setSeriesPaint(i, palette.get(i));
400 400
			}
401 401
    	}
402
    	// PiePlot
403
    	else if(plot instanceof PiePlot)	{
404
    		PiePlot typedPlot = (PiePlot)plot;
405
    		palette = this.chartsEngine.getTheme().getPaletteFor(itemsColorsRenderingMode, typedPlot.getDataset().getItemCount());
406
    		for(int i = 0; i < palette.size(); i++) {
407
    			typedPlot.setSectionPaint(i, palette.get(i));
408
    		}
409
    	}
402 410
    	return palette;
403 411
    }
404 412

  
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/handlers/ComputeSpecifities.java (revision 583)
87 87
			else	{
88 88
				LexicalTable lexicalTable = null;
89 89
				
90
				final Integer maxScore = TXMPreferences.getInt(SpecificitiesPreferences.MAX_SCORE, SpecificitiesPreferences.PREFERENCES_NODE);
91
				int fMin = TXMPreferences.getInt(LexicalTablePreferences.F_MIN, LexicalTablePreferences.PREFERENCES_NODE);
92
				int vMax = TXMPreferences.getInt(LexicalTablePreferences.V_MAX, LexicalTablePreferences.PREFERENCES_NODE);
93
	
94 90
				// creating from Partition
95 91
				if (selection instanceof Partition) {
96 92
					Partition partition = (Partition) selection;
......
113 109
					Log.severe("Cannot compute Specificities with " + selection);
114 110
					return null;
115 111
				}
116
				specificities = new Specificities(lexicalTable, maxScore);
112
				specificities = new Specificities(lexicalTable);
117 113
				
118 114
			}
119 115
			
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java (revision 583)
45 45
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
46 46
import org.txm.searchengine.cqp.corpus.Corpus;
47 47
import org.txm.specificities.core.messages.SpecificitiesCoreMessages;
48
import org.txm.specificities.core.preferences.SpecificitiesPreferences;
48 49
import org.txm.specificities.core.statsengine.r.function.SpecificitiesR;
49 50
import org.txm.statsengine.core.StatException;
50 51
import org.txm.statsengine.core.data.Vector;
......
109 110
	
110 111
	
111 112
	
112
	@Parameter
113
	@Parameter(key=SpecificitiesPreferences.MAX_SCORE)
113 114
	protected int maxScore;
114 115
	
115 116
	
......
123 124
	 * @throws CqiClientException the cqi client exception
124 125
	 * @throws StatException the stat exception
125 126
	 */
126
	public Specificities(LexicalTable lexicalTable, int maxScore)	throws CqiClientException, StatException {
127
	public Specificities(LexicalTable lexicalTable)	throws CqiClientException, StatException {
127 128
		super(lexicalTable);
128 129
		this.lexicalTable = lexicalTable;
129
		this.maxScore = maxScore;
130 130
	}
131 131
	
132 132
	@Override
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 583)
92 92
	/**
93 93
	 * To keep track of the parameters used for the last computing and to determine if the result is dirty. 
94 94
	 */
95
	protected HashMap<String, Object> lastComputingParameters = new HashMap<String, Object>();
95
	protected HashMap<String, Object> lastParameters = new HashMap<String, Object>();
96 96

  
97 97
	
98 98
	
......
131 131
		// loads parameters from local result node, current command preferences or default command preferences
132 132
		try {
133 133
			this.loadGenericParameters();
134
			
135
			// FIXME: debug
136
			System.err.println("TXMResult.TXMResult(): loading parameters into fields.");
137 134
			this.loadParameters();
138 135
		}
139 136
		catch (Exception e) {
......
157 154
		return this.children.size() > 0;
158 155
	}
159 156

  
157
	
160 158
	/**
161
	 * Stores the last parameters used for computing.
159
	 * Returns all the member fields of the class instance.
160
	 * @return
161
	 */
162
	protected List<Field> getAllFields()	{
163

  
164
		List<Field> fields = new ArrayList<Field>();
165
		Class<?> clazz = this.getClass();
166
		while (clazz != Object.class) {
167
			fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
168
			clazz = clazz.getSuperclass();
169
		}
170

  
171
		return fields;
172
		
173
	}
174
	
175
	/**
176
	 * Stores the parameters of the specified type used for last computing.
162 177
	 * @throws Exception
163 178
	 */
164
	protected void updateLastComputingParameters() throws Exception {
165
		Field[] fields = this.getClass().getDeclaredFields();
179
	protected void updateLastParameters(int parameterType) throws Exception {
180
		
181
		List<Field> fields = this.getAllFields();
182
		
166 183
		for (Field f : fields) {
167 184
			Parameter parameter = f.getAnnotation(Parameter.class);
168
			if (parameter == null || parameter.type() != Parameter.COMPUTING) {
185
			if (parameter == null || parameter.type() != parameterType) {
169 186
				continue;
170 187
			}
171 188
			
172 189
			String name;
173
			if(!"".equals(parameter.key()))	{
190
			if(!parameter.key().isEmpty())	{
174 191
				name = parameter.key();
175 192
			}
176 193
			else	{
......
178 195
			}
179 196
			
180 197
			f.setAccessible(true);
181
			this.lastComputingParameters.put(name, f.get(this));
198
			this.lastParameters.put(name, f.get(this));
182 199
		}
183 200
	}
184 201

  
202
	
203
	/**
204
	 * Stores the last parameters used for computing.
205
	 * @throws Exception
206
	 */
207
	protected void updateLastParameters() throws Exception {
208
		this.updateLastParameters(Parameter.COMPUTING);
209
	}
210
	
185 211
	// FIXME: not used?
186
	public HashMap<String, Object> getLastComputingParameters() {
187
		return lastComputingParameters;
212
	public HashMap<String, Object> getLastParameters() {
213
		return lastParameters;
188 214
	}
189 215

  
190 216

  
191 217
	
192 218
	/**
193
	 * Gets a current parameter specified by its annotation "key" attribute.
219
	 * Gets a current parameter specified by its annotation "key" attribute and its annotation "type" attribute.
194 220
	 * @param key
221
	 * @param parameterType
195 222
	 * @return
196 223
	 */
197
	protected Object getParameter(String key) {
198
		Field[] fields = this.getClass().getDeclaredFields();
224
	protected Object getParameter(String key, int parameterType) {
225

  
226
		List<Field> fields = this.getAllFields();
227
		
199 228
		for (Field f : fields) {
200 229
			Parameter parameter = f.getAnnotation(Parameter.class);
201
			if (parameter == null || parameter.type() != Parameter.COMPUTING) {
230
			if (parameter == null || parameter.type() != parameterType) {
202 231
				continue;
203 232
			}
204 233
			f.setAccessible(true);
205 234
			if (parameter.key().equals(key)) {
206 235
				try {
207 236
					return f.get(this);
208
				} catch (Exception e) {
237
				}
238
				catch (Exception e) {
209 239
					e.printStackTrace();
210 240
				}
211 241
			}
......
213 243
		return null;
214 244
	}
215 245

  
246
	
216 247
	/**
217
	 * Checks if a parameter value has changed since last computing. 
248
	 * Gets a current computing parameter specified by its annotation "key" attribute.
218 249
	 * @param key
219 250
	 * @return
220 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
	 */
221 262
	public boolean hasParameterChanged(String key) {
263
		return this.hasParameterChanged(key, Parameter.COMPUTING);
264
	}
265
	
266
	/**
267
	 * Checks if a parameter value has changed since last computing.
268
	 * @param key
269
	 * @param parameterType
270
	 * @return
271
	 */
272
	public boolean hasParameterChanged(String key, int parameterType) {
222 273
		if (key.isEmpty()) {
223 274
			return false;
224 275
		}
225
		Object lastValue = this.lastComputingParameters.get(key);
226
		Object newValue = getParameter(key);
227
		if (lastValue == null && newValue != null) {
228
			return true;
276
		Object lastValue = this.lastParameters.get(key);
277
		Object newValue = this.getParameter(key, parameterType);
278
		if (lastValue == null) {
279
			if(newValue != null)	{
280
				return true;
281
			}
282
			else	{
283
				return false;
284
			}
229 285
		}
230 286
		else {
231 287
			return !lastValue.equals(newValue);
......
233 289
	}
234 290

  
235 291
	
292
//
293
//		
294
//		
295
//		
296
//		if (key.isEmpty()) {
297
//			return false;
298
//		}
299
//		Object lastValue = this.lastComputingParameters.get(key);
300
//		Object newValue = getParameter(key);
301
//		if (lastValue == null && newValue != null) {
302
//			return true;
303
//		}
304
//		else {
305
//			return !lastValue.equals(newValue);
306
//		}
307
//	}
308

  
309
	
236 310
	public String dumpPreferences()	{
237 311
		
238 312
		StringBuilder str = new StringBuilder();
......
344 418
			}
345 419
			
346 420
			f.setAccessible(true); // not to set accessible to test the field values
347
			Object previousValue = this.lastComputingParameters.get(name);
421
			Object previousValue = this.lastParameters.get(name);
348 422
			Object newValue = f.get(this);
349 423
			
350 424
			// FIXME: debug
......
548 622
	protected boolean loadGenericParameters(int parameterType) throws Exception {
549 623
		
550 624
		// FIXME: debug
551
		System.err.println("TXMResult.loadGenericParameters(): loading generic parameters into fields.");
625
		System.err.println("TXMResult.loadGenericParameters(): loading generic parameters into fields for " + this.getClass() + " and parameters type = " + parameterType);
552 626
		
553
		List<Field> fields = new ArrayList<Field>();
554
		Class<?> clazz = this.getClass();
555
		while (clazz != Object.class) {
556
			fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
557
			clazz = clazz.getSuperclass();
558
		}
627
		List<Field> fields = this.getAllFields();
559 628

  
560 629
		for (Field f : fields) {
561 630
		
......
565 634
			}
566 635
			String key = parameter.key();
567 636
			
568
			// FIXME:  debug
569
			if(key.equals("charts_engine_show_title"))	{
570
				System.out.println("TXMResult.loadGenericParameters() " + key);
571
				System.out.println("TXMResult.loadGenericParameters() class = " + f.getType());
572
				System.out.println("TXMResult.loadGenericParameters() test = " + f.getType().isAssignableFrom(boolean.class));
573
			}
574
			
575
			
576 637
			if (key.isEmpty()) {
577
				continue; // no preference key defined
638
				continue; // no preference key defined for the parameter so it can't be filled with default value or result persistence value from preferences nodes
578 639
			}
579 640
			try {
580 641
				f.setAccessible(true); // set accessible to test the field values
......
1227 1288
			return false;
1228 1289
		}
1229 1290

  
1230
		this.updateLastComputingParameters(); // store last used parameters
1291
		this.updateLastParameters(); // store last used parameters
1231 1292

  
1232 1293
		if (!this.saveParameters()) {
1233 1294
			System.out.println("Warning: failed to save parameters for " + this.getName() + ".");

Formats disponibles : Unified diff