Révision 4003

TXM/trunk/bundles/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/preferences/TextsBalancePreferencePage.java (revision 4003)
52 52
	@Override
53 53
	public void createFieldEditors() {
54 54

  
55
		
56 55
		// Charts rendering
57 56
		Composite chartsTab = SWTChartsComponentsProvider.createChartsRenderingPreferencesTabFolderComposite(this.getFieldEditorParent());
58 57
		
......
64 63
//		method.getTextControl(getFieldEditorParent()).setToolTipText("Method (1: uses CQL to solve matches, 2 uses corpus struct indexes, 2 is faster!)");
65 64
//		this.addField(method);
66 65
		
67
		String[][] methods = new String[2][2];
68
		for(int i = 0; i < 2; i++) {
69
			methods[i][0] = String.valueOf(i + 1);
70
			methods[i][1] = String.valueOf(i + 1);
71
		}
66
//		String[][] methods = new String[2][2];
67
//		for(int i = 0; i < 2; i++) {
68
//			methods[i][0] = String.valueOf(i + 1);
69
//			methods[i][1] = String.valueOf(i + 1);
70
//		}
72 71

  
73
		this.addField(new ComboFieldEditor(TextsBalancePreferences.METHOD, Messages.Method, methods, chartsTab));
74
		this.addField(new BooleanFieldEditor(TextsBalancePreferences.GROUP_BY_TEXTS, Messages.GroupByWords, chartsTab));
72
		//this.addField(new ComboFieldEditor(TextsBalancePreferences.METHOD, Messages.Method, methods, chartsTab));
73
		this.addField(new BooleanFieldEditor(TextsBalancePreferences.COUNT_TEXTS, Messages.GroupByWords, chartsTab));
75 74
		
76 75
		// other shared preferences
77 76
		SWTChartsComponentsProvider.createChartsRenderingPreferencesFields(this, chartsTab);
TXM/trunk/bundles/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/editors/TextsBalanceEditor.java (revision 4003)
47 47
	/**
48 48
	 * Group by texts or not.
49 49
	 */
50
	@Parameter(key=TextsBalancePreferences.GROUP_BY_TEXTS)
50
	@Parameter(key=TextsBalancePreferences.COUNT_TEXTS)
51 51
	protected Button groupByTexts;
52 52
	
53 53
	
TXM/trunk/bundles/org.txm.textsbalance.core/src/org/txm/textsbalance/core/preferences/TextsBalancePreferences.java (revision 4003)
14 14
public class TextsBalancePreferences extends ChartsEnginePreferences {
15 15

  
16 16
	
17
	public static final String GROUP_BY_TEXTS = "group_by_texts"; //$NON-NLS-1$
18
	public static final String METHOD = "method"; //$NON-NLS-1$
17
	public static final String COUNT_TEXTS = "group_by_texts"; //$NON-NLS-1$
18
	//public static final String METHOD = "method"; //$NON-NLS-1$
19 19
	
20 20
	
21 21
	/**
......
35 35
		super.initializeDefaultPreferences();
36 36
		
37 37
		Preferences preferences = this.getDefaultPreferencesNode();
38
		preferences.putBoolean(GROUP_BY_TEXTS, true);
39
		preferences.putInt(METHOD, 2);
40
		
38
		preferences.putBoolean(COUNT_TEXTS, false);
41 39
		preferences.put(STRUCTURAL_UNIT, "text");
42

  
40
		//preferences.putInt(METHOD, 2);
41
		
43 42
		// to disable the functionality
44 43
		TXMPreferences.setEmpty(this.getPreferencesNodeQualifier(), ChartsEnginePreferences.SHOW_GRID);
45 44
	}
TXM/trunk/bundles/org.txm.textsbalance.core/src/org/txm/textsbalance/core/functions/TextsBalance.java (revision 4003)
8 8
import java.util.Arrays;
9 9
import java.util.Collections;
10 10
import java.util.HashMap;
11
import java.util.LinkedHashMap;
11 12
import java.util.List;
12 13

  
13 14
import org.txm.chartsengine.core.results.ChartResult;
14 15
import org.txm.core.results.Parameter;
15
import org.txm.core.results.TXMParameters;
16 16
import org.txm.searchengine.cqp.AbstractCqiClient;
17 17
import org.txm.searchengine.cqp.CQPSearchEngine;
18 18
import org.txm.searchengine.cqp.NetCqiClient;
......
21 21
import org.txm.searchengine.cqp.corpus.QueryResult;
22 22
import org.txm.searchengine.cqp.corpus.StructuralUnit;
23 23
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
24
import org.txm.searchengine.cqp.corpus.query.Match;
25 24
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
25
import org.txm.searchengine.cqp.corpus.query.Match;
26 26
import org.txm.textsbalance.core.preferences.TextsBalancePreferences;
27 27
import org.txm.utils.TXMProgressMonitor;
28
import org.txm.utils.io.IOUtils;
28 29
import org.txm.utils.logger.Log;
29 30

  
30 31
/**
......
36 37
 */
37 38
public class TextsBalance extends ChartResult {
38 39
	
39
	HashMap<Comparable[], Integer> dataset;
40
	LinkedHashMap<Comparable<?>[], Integer> dataset;
40 41
	
41 42
	protected String propertyName;
42 43
	protected List<String> values;
......
45 46
	
46 47

  
47 48
	protected int method;
48

  
49 49
	
50 50
	/**
51 51
	 * Structural unit to explore.
......
62 62
	/**
63 63
	 * Group by texts or not.
64 64
	 */
65
	@Parameter(key=TextsBalancePreferences.GROUP_BY_TEXTS)
65
	@Parameter(key=TextsBalancePreferences.COUNT_TEXTS)
66 66
	protected boolean countTexts;
67 67
	
68 68

  
......
119 119
		
120 120
		monitor.setTask("Computing balance with metadata propertyName = " + this.structuralUnitProperty + ", structural unit = " + this.structuralUnit.getName() + " and groupByTexts = " + this.countTexts); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
121 121
		try {
122
			this.dataset = new HashMap<Comparable[], Integer>();
122
			this.dataset = new LinkedHashMap<Comparable<?>[], Integer>();
123 123
			
124 124
			StructuralUnitProperty p = this.structuralUnitProperty;
125 125
			this.values = p.getValues();
......
258 258
	/**
259 259
	 * @return the dataset
260 260
	 */
261
	public HashMap<Comparable[], Integer> getDataset() {
261
	public HashMap<Comparable<?>[], Integer> getDataset() {
262 262
		return dataset;
263 263
	}
264 264

  
......
270 270
		return (CQPCorpus) this.parent;
271 271
	}
272 272

  
273

  
274 273
	/**
275 274
	 * @return the propertyName
276 275
	 */
......
278 277
		return propertyName;
279 278
	}
280 279

  
281

  
282 280
	/**
283 281
	 * @return the values
284 282
	 */
......
286 284
		return values;
287 285
	}
288 286

  
289

  
290 287
	/**
291 288
	 * @return the fMin
292 289
	 */
......
294 291
		return fMin;
295 292
	}
296 293

  
297

  
298 294
	/**
299 295
	 * @return the fMax
300 296
	 */
......
302 298
		return fMax;
303 299
	}
304 300

  
305

  
306 301
	@Override
307 302
	public boolean _toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws Exception {
308
		// TODO Auto-generated method stub
309
		return false;
303
		
304
		StringBuffer buffer = new StringBuffer();
305
		for (Comparable<?>[] k : dataset.keySet()) {
306
			buffer.append(txtseparator+k[1]+txtseparator+colseparator+txtseparator+dataset.get(k)+txtseparator+"\n");
307
		}
308
		return IOUtils.write(outfile, buffer.toString());
310 309
	}
311 310

  
312

  
313 311
	@Override
314 312
	public void clean() {
315 313
		// TODO Auto-generated method stub
TXM/trunk/bundles/org.txm.textsbalance.core/src/org/txm/textsbalance/core/chartsengine/jfreechart/JFCTextsBalanceSpiderChartCreator.java (revision 4003)
25 25
		JFreeChart chart = null;
26 26
		
27 27
		// Creates an empty dataset
28
		HashMap<Comparable[], Integer> data = textsBalance.getDataset();
28
		HashMap<Comparable<?>[], Integer> data = textsBalance.getDataset();
29 29
		DefaultCategoryDataset dataset = new DefaultCategoryDataset();
30 30
		
31 31
		plot = new SpiderWebPlot(dataset);
......
63 63
		chart.setNotify(false);
64 64
		
65 65
		// updating data set
66
		HashMap<Comparable[], Integer> data = textsBalance.getDataset();
66
		HashMap<Comparable<?>[], Integer> data = textsBalance.getDataset();
67 67
		DefaultCategoryDataset dataset = (DefaultCategoryDataset) ((SpiderWebPlot) chart.getPlot()).getDataset();
68 68
		dataset.clear();
69 69
		
70
		Set<Comparable[]> keys = data.keySet();
71
		Iterator<Comparable[]> it = keys.iterator();
70
		Set<Comparable<?>[]> keys = data.keySet();
71
		Iterator<Comparable<?>[]> it = keys.iterator();
72 72
		while (it.hasNext()) {
73 73
			Comparable[] key = it.next();
74 74
			Integer value = data.get(key);

Formats disponibles : Unified diff