Révision 3362

TXM/trunk/org.txm.specificities.core/src/org/txm/specificities/core/functions/SpecificitiesSelection.java (revision 3362)
4 4
package org.txm.specificities.core.functions;
5 5

  
6 6
import java.io.File;
7
import java.io.PrintWriter;
8
import java.util.ArrayList;
7 9
import java.util.Arrays;
8 10
import java.util.List;
9 11

  
10 12
import org.apache.commons.lang.StringUtils;
13
import org.jfree.chart.renderer.category.GroupedStackedBarRenderer;
11 14
import org.txm.chartsengine.core.results.ChartResult;
12 15
import org.txm.core.messages.TXMCoreMessages;
13 16
import org.txm.core.results.Parameter;
......
17 20
import org.txm.specificities.core.preferences.SpecificitiesPreferences;
18 21
import org.txm.statsengine.core.StatException;
19 22
import org.txm.utils.TXMProgressMonitor;
23
import org.txm.utils.io.IOUtils;
20 24

  
21 25
/**
22 26
 * A selection from a Specificities result dedicated to export or chart creation.
......
304 308
	@Override
305 309
	@Deprecated
306 310
	public boolean _toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws Exception {
307
		// TODO Auto-generated method stub
308
		return false;
311
		PrintWriter writer = IOUtils.getWriter(outfile);
312
		
313
		Specificities specificities = this.getParent();
314
		String[] partNames = specificities.getColumnsNames();
315
		
316
		writer.println(txtseparator+"Lines"+txtseparator+colseparator+txtseparator+StringUtils.join(partNames, txtseparator+colseparator+txtseparator)+txtseparator); // all parts
317
		
318
		for (int i = 0 ; i < selectedTypeNames.size() ; i++) {
319
			Double[] values = new Double[selectedSpecificitiesIndex[i].length];
320
			for (int d = 0 ; d < selectedSpecificitiesIndex[i].length ; d++) {
321
				values[d] = selectedSpecificitiesIndex[i][d];
322
			}
323
			
324
			writer.println(txtseparator+selectedTypeNames.get(i)+txtseparator+
325
					colseparator+txtseparator+StringUtils.join(values, txtseparator+colseparator+txtseparator)+txtseparator);
326
		}
327
		
328
		writer.close();
329
		return true;
309 330
	}
310 331
	
311 332
	
TXM/trunk/org.txm.progression.core/src/org/txm/progression/core/functions/Progression.java (revision 3362)
684 684
		}
685 685
	}
686 686
	
687
	@Override
688
	public boolean _toTxt(File outfile, String encoding, String colseparator,
689
			String txtseparator) throws Exception {
690
		return toTxt(outfile, encoding);
691
	}
692
	
693
	
694 687
	/**
695 688
	 * 
696 689
	 * @param outfile
......
698 691
	 * @return
699 692
	 * @throws IOException
700 693
	 */
701
	public boolean toTxt(File outfile, String encoding) throws IOException {
694
	public boolean _toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws IOException {
695
		
702 696
		// NK: writer declared as class attribute to perform a clean if the operation is interrupted
703 697
		tryAcquireSemaphore();
704 698
		this.writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outfile),
TXM/trunk/org.txm.partition.core/src/org/txm/partition/core/functions/PartitionDimensions.java (revision 3362)
4 4
package org.txm.partition.core.functions;
5 5

  
6 6
import java.io.File;
7
import java.io.PrintWriter;
7 8
import java.util.ArrayList;
8 9
import java.util.Collections;
9 10
import java.util.Comparator;
......
20 21
import org.txm.searchengine.cqp.corpus.Part;
21 22
import org.txm.searchengine.cqp.corpus.Partition;
22 23
import org.txm.utils.TXMProgressMonitor;
24
import org.txm.utils.io.IOUtils;
23 25

  
24 26
/**
25 27
 * Partition dimensions.
......
231 233
	
232 234
	
233 235
	@Override
234
	public boolean _toTxt(File arg0, String arg1, String arg2, String arg3) throws Exception {
235
		// TODO Auto-generated method stub
236
	public boolean _toTxt(File file, String encoding, String colseparator, String txtseparator) throws Exception {
237
		PrintWriter writer = IOUtils.getWriter(file, encoding);
238
		
239
		for (Part b : this.parts) {
240
			writer.println(txtseparator+b.getName().replaceAll(txtseparator, txtseparator+txtseparator)+txtseparator+colseparator+txtseparator+b.getSize()+txtseparator);
241
		}
242
		
243
		writer.close();
236 244
		return false;
237 245
	}
238 246
	
TXM/trunk/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java (revision 3362)
269 269
	
270 270
	public Object evaluate(String code) {
271 271
		if (Log.getLevel().intValue() <= Level.FINEST.intValue()) System.out.println(code);
272
		return getBrowser().evaluate(code);
272
		try {
273
			return getBrowser().evaluate(code);
274
		} catch(Exception e) {
275
			String error = e.getMessage();
276
			Log.severe("Browser evaluate error: "+e);
277
			Log.printStackTrace(e);
278
		}
279
		return null;
273 280
	}
274 281
	
275 282
	public boolean execute(String code) {
276 283
		if (Log.getLevel().intValue() <= Level.FINEST.intValue()) System.out.println(code);
277
		return getBrowser().execute(code);
284
		try {
285
			return getBrowser().execute(code);
286
		} catch(Exception e) {
287
			String error = e.getMessage();
288
			Log.severe("Browser execute error: "+e);
289
			Log.printStackTrace(e);
290
		}
291
		return false;
278 292
	}
279 293
	
280 294
	public EditionPanel(SynopticEditionEditor synopticEditionEditor, Composite parent, int style, String editionName) {
......
316 330
					new EditionLink(synopticEditionEditor, getBrowser());
317 331
				}
318 332
				
319
				Log.finest("EditionPanel " + currentEdition.getName() + " reload " + getCurrentPage().getName());
333
				
320 334
				Object rez = evaluate("return typeof sheet;"); //$NON-NLS-1$
321 335
				if ("undefined".equals(rez)) { //$NON-NLS-1$
322 336
					Object loadResult = evaluate(functions);
......
354 368
				
355 369
				
356 370
				buffer = new StringBuilder();
357
				
358
				String firstWord = currentPage.getWordId();
359
				Page nextPage = currentEdition.getNextPage(currentPage);
360
				String lastWord = "w_999999999"; //$NON-NLS-1$
361
				while (nextPage != null && currentPage != nextPage) {
362
					lastWord = nextPage.getWordId();
363
					if (!("w_0".equals(lastWord))) { // this is a word id
364
						break; // ok
365
					}
366
					Page p = currentEdition.getNextPage(nextPage);
367
					if (p == nextPage) { // end of pages
368
						lastWord = "w_999999999";
369
						break;
370
					}
371
					nextPage = p;
372
				}
373
				// System.out.println("firstWord="+firstWord+" lastWord="+lastWord);
374
				// int n = 0;
375
				// long start = System.currentTimeMillis();
376
				
377
				for (String wordid : highlightedColorPerWordIDS.keySet()) {
378
					// Log.finest("words to highlight: "+highlightedColorPerWordIDS);
379
					if (highlightedColorPerWordIDS.get(wordid).size() == 0) continue; // error
371
				Log.finest("EditionPanel " + currentEdition + " reload " + currentPage);
372
				if (currentPage != null && currentEdition != null) { // avoid null pointer
380 373
					
381
					// if (!slowWordHighLight) { //TODO: this code must be replaced with word position instead of word id comparaison
382
					if (Edition.isFirstGTthanSecond(wordid, firstWord) < 0) continue; // skip the word to highlight
383
					if (Edition.isFirstGTthanSecond(lastWord, wordid) < 0) continue; // skip the word to highlight
384
					// }
385
					// n++;
386
					RGBA composite = new RGBA(0, 0, 0, 0f);
387
					int size = highlightedColorPerWordIDS.get(wordid).size();
388 374
					
389
					for (RGBA color : highlightedColorPerWordIDS.get(wordid)) {
390
						composite.r += color.r;
391
						composite.g += color.g;
392
						composite.b += color.b;
393
						composite.a += color.a;
375
					String firstWord = currentPage.getWordId();
376
					Page nextPage = currentEdition.getNextPage(currentPage);
377
					String lastWord = "w_999999999"; //$NON-NLS-1$
378
					while (nextPage != null && currentPage != nextPage) {
379
						lastWord = nextPage.getWordId();
380
						if (!("w_0".equals(lastWord))) { // this is a word id
381
							break; // ok
382
						}
383
						Page p = currentEdition.getNextPage(nextPage);
384
						if (p == nextPage) { // end of pages
385
							lastWord = "w_999999999";
386
							break;
387
						}
388
						nextPage = p;
394 389
					}
390
					// System.out.println("firstWord="+firstWord+" lastWord="+lastWord);
391
					// int n = 0;
392
					// long start = System.currentTimeMillis();
395 393
					
396
					composite.r /= size;
397
					composite.g /= size;
398
					composite.b /= size;
399
					
400
					String s = null;
401
					if (!fastWordHighLight) {
402
						// s = String.format(highlightscriptRule, wordid, composite.r, composite.g, composite.b, composite.a);
403
						s = "try { document.getElementById(\"" + wordid + "\").style.backgroundColor=\"rgba(" + composite.r + "," + composite.g + "," + composite.b + "," + composite.a + ")\";" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
404
								+
405
								// "elt.style.paddingLeft=\"3px\";" + //$NON-NLS-1$
406
								// "elt.style.paddingRight=\"3px\";" + //$NON-NLS-1$
407
								// "elt.style.paddingTop=\"1px\";" + //$NON-NLS-1$
408
								// "elt.style.paddingBottom=\"1px\";" + //$NON-NLS-1$
409
								"} catch (e) { };"; //$NON-NLS-1$
394
					for (String wordid : highlightedColorPerWordIDS.keySet()) {
395
						// Log.finest("words to highlight: "+highlightedColorPerWordIDS);
396
						if (highlightedColorPerWordIDS.get(wordid).size() == 0) continue; // error
397
						
398
						// if (!slowWordHighLight) { //TODO: this code must be replaced with word position instead of word id comparaison
399
						if (Edition.isFirstGTthanSecond(wordid, firstWord) < 0) continue; // skip the word to highlight
400
						if (Edition.isFirstGTthanSecond(lastWord, wordid) < 0) continue; // skip the word to highlight
401
						// }
402
						// n++;
403
						RGBA composite = new RGBA(0, 0, 0, 0f);
404
						int size = highlightedColorPerWordIDS.get(wordid).size();
405
						
406
						for (RGBA color : highlightedColorPerWordIDS.get(wordid)) {
407
							composite.r += color.r;
408
							composite.g += color.g;
409
							composite.b += color.b;
410
							composite.a += color.a;
411
						}
412
						
413
						composite.r /= size;
414
						composite.g /= size;
415
						composite.b /= size;
416
						
417
						String s = null;
418
						if (!fastWordHighLight) {
419
							// s = String.format(highlightscriptRule, wordid, composite.r, composite.g, composite.b, composite.a);
420
							s = "try { document.getElementById(\"" + wordid + "\").style.backgroundColor=\"rgba(" + composite.r + "," + composite.g + "," + composite.b + "," + composite.a + ")\";" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
421
									+
422
									// "elt.style.paddingLeft=\"3px\";" + //$NON-NLS-1$
423
									// "elt.style.paddingRight=\"3px\";" + //$NON-NLS-1$
424
									// "elt.style.paddingTop=\"1px\";" + //$NON-NLS-1$
425
									// "elt.style.paddingBottom=\"1px\";" + //$NON-NLS-1$
426
									"} catch (e) { };"; //$NON-NLS-1$
427
						}
428
						else {
429
							// TODO: replace this line with the next one for TXM 0.7.9
430
							s = String.format(highlightscriptRuleFast, wordid.replace(" ", "\\ "), composite.r, composite.g, composite.b, composite.a); //$NON-NLS-1$ //$NON-NLS-2$
431
							// s = String.format(highlightscriptRuleFast, wordid, composite.r, composite.g, composite.b, composite.a);
432
						}
433
						
434
						buffer.append(s + "\n"); //$NON-NLS-1$
410 435
					}
411
					else {
412
						// TODO: replace this line with the next one for TXM 0.7.9
413
						s = String.format(highlightscriptRuleFast, wordid.replace(" ", "\\ "), composite.r, composite.g, composite.b, composite.a); //$NON-NLS-1$ //$NON-NLS-2$
414
						// s = String.format(highlightscriptRuleFast, wordid, composite.r, composite.g, composite.b, composite.a);
415
					}
416
					
417
					buffer.append(s + "\n"); //$NON-NLS-1$
418 436
				}
419 437
				
420 438
				if (buffer.length() > 0) {
TXM/trunk/org.txm.ahc.core/src/org/txm/ahc/core/functions/AHC.java (revision 3362)
336 336
	 * @return
337 337
	 */
338 338
	// FIXME: SJ: to extract to future exporter extension
339
	@Deprecated
340
	public boolean toTxt(File outfile, String encoding) {
339
	public boolean _toTxt(File outfile, String encoding, String colsep, String txtsep) {
341 340
		boolean ret = true;
342 341
		acquireSemaphore();
343 342
		RWorkspace rw;
......
357 356
		}
358 357
		return true;
359 358
	}
360
	
361
	// FIXME: SJ: to extract to future exporter extension
362
	@Override
363
	@Deprecated
364
	public boolean _toTxt(File outfile, String encoding, String colsep, String txtsep) {
365
		return toTxt(outfile, encoding);
366
	}
367
	
359
		
368 360
	/**
369 361
	 * Gets the default method.
370 362
	 *
TXM/trunk/org.txm.rcp/rcpapplication.product (revision 3362)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<?pde version="3.5"?>
3 3

  
4
<product name="TXM" uid="org.txm.rcp.app" id="org.txm.rcp.product" application="org.txm.rcp.Application" version="0.8.2.qualifier" useFeatures="true" includeLaunchers="true">
4
<product name="TXM 0.8.2" uid="org.txm.rcp.app" id="org.txm.rcp.product" application="org.txm.rcp.Application" version="0.8.2.qualifier" useFeatures="true" includeLaunchers="true">
5 5

  
6 6
   <aboutInfo>
7 7
      <image path="/org.txm.rcp/icons/logo/about TXM.png"/>
......
79 79
      </win>
80 80
   </launcher>
81 81

  
82

  
83 82
   <vm>
84 83
      <linux include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7</linux>
85 84
      <macos include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7</macos>
TXM/trunk/org.txm.utils/src/org/txm/utils/logger/Log.java (revision 3362)
222 222
	 * @param message
223 223
	 */
224 224
	public static void severe(String message) {
225
		
226
		if (message.length() > 1000) { // cut if too long
227
			message = message.substring(0, 1000) + "[...]";
228
		}
225 229

  
226 230
		if (Level.SEVERE.intValue() >= txm.getLevel().intValue()) {
227 231
			System.out.println(message);
......
285 289
	 * @param message
286 290
	 */
287 291
	public static void warning(String message) {
292
		
293
		if (message.length() > 1000) { // cut if too long
294
			message = message.substring(0, 1000) + "[...]";
295
		}
296
		
288 297
		if (Level.WARNING.intValue() >= txm.getLevel().intValue()) {
289 298
			System.out.println(message);
290 299
			// System.out.print("AT: ");
......
330 339
	 *            where to print the message
331 340
	 */
332 341
	public static void info(String message, boolean newline) {
342
		
343
		if (message.length() > 1000) { // cut if too long
344
			message = message.substring(0, 1000) + "[...]";
345
		}
346
		
333 347
		if (Level.INFO.intValue() >= txm.getLevel().intValue()) {
334 348
			if (newline) System.out.println(message);
335 349
			else  System.out.print(message);

Formats disponibles : Unified diff