Révision 566
tmp/org.txm.internalview.rcp/src/org/txm/internal/rcp/editors/InternalViewEditor.java (revision 566) | ||
---|---|---|
261 | 261 |
@Override |
262 | 262 |
public void widgetSelected(SelectionEvent e) { |
263 | 263 |
internalView.setParameters(null, null, null, 0); |
264 |
TXMEditorPart.compute(getResultData(), true, InternalViewEditor.this);
|
|
264 |
compute(true);
|
|
265 | 265 |
} |
266 | 266 |
|
267 | 267 |
@Override |
... | ... | |
424 | 424 |
|
425 | 425 |
createContextMenu(); |
426 | 426 |
|
427 |
TXMEditorPart.compute(getResultData(), true, InternalViewEditor.this); |
|
428 | 427 |
} |
429 | 428 |
|
430 | 429 |
protected boolean goToPage(int next) throws CqiClientException { |
tmp/org.txm.referencer.rcp/src/org/txm/rcp/editors/referencer/ReferencerEditor.java (revision 566) | ||
---|---|---|
457 | 457 |
}); |
458 | 458 |
|
459 | 459 |
initializeFields(); |
460 |
TXMEditorPart.compute(referencer, true, ReferencerEditor.this); |
|
461 | 460 |
} |
462 | 461 |
|
463 | 462 |
/** |
tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/handlers/ComputeCooccurrences.java (revision 566) | ||
---|---|---|
79 | 79 |
} |
80 | 80 |
|
81 | 81 |
Object selection = this.getSelection(event); |
82 |
TXMResultEditorInput editorInput = null; |
|
83 |
|
|
84 | 82 |
Cooccurrence cooc = null; |
85 | 83 |
|
86 | 84 |
if (selection instanceof Concordance) { |
... | ... | |
130 | 128 |
StatusLine.setMessage(RCPMessages.ComputeCooccurrences_0); |
131 | 129 |
|
132 | 130 |
//System.out.println("DEBUG: opening cooc: "+cooc+" corpus="+cooc.getCorpus()); |
133 |
editorInput = new TXMResultEditorInput(cooc);
|
|
131 |
TXMEditorPart.openEditor(cooc, CooccurrencesEditor.ID);
|
|
134 | 132 |
|
135 |
TXMEditorPart editor = TXMEditorPart.openEditor(editorInput, CooccurrencesEditor.ID); |
|
136 |
|
|
137 |
return editor; |
|
133 |
return true; |
|
138 | 134 |
} catch (Exception e) { |
139 | 135 |
Log.printStackTrace(e); |
140 |
return null;
|
|
136 |
return false;
|
|
141 | 137 |
} |
142 | 138 |
} |
143 | 139 |
} |
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesSelectionEditor.java (revision 566) | ||
---|---|---|
4 | 4 |
import org.eclipse.swt.events.SelectionEvent; |
5 | 5 |
import org.eclipse.swt.events.SelectionListener; |
6 | 6 |
import org.eclipse.swt.widgets.Composite; |
7 |
import org.eclipse.swt.widgets.Label; |
|
8 |
import org.eclipse.swt.widgets.Spinner; |
|
7 | 9 |
import org.eclipse.swt.widgets.ToolItem; |
8 | 10 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart; |
9 |
import org.txm.core.preferences.TXMPreferences; |
|
10 | 11 |
import org.txm.rcp.IImageKeys; |
11 |
import org.txm.specificities.core.preferences.SpecificitiesPreferences;
|
|
12 |
import org.txm.specificities.core.functions.SpecificitiesSelection;
|
|
12 | 13 |
import org.txm.specificities.rcp.handlers.ComputeSpecifities; |
13 | 14 |
import org.txm.specificities.rcp.messages.SpecificitiesUIMessages; |
14 | 15 |
|
... | ... | |
30 | 31 |
final ToolItem groupBarsByLines = new ToolItem(this.getToolBar(), SWT.CHECK); |
31 | 32 |
groupBarsByLines.setToolTipText(SpecificitiesUIMessages.SpecificitiesPreferencePage_4); |
32 | 33 |
groupBarsByLines.setImage(IImageKeys.getImage(ComputeSpecifities.class, "icons/silk_group_bars_by_lines.png")); |
33 |
groupBarsByLines.setSelection(getResultData().getBooleanParameterValue(SpecificitiesPreferences.CHART_TRANSPOSE));
|
|
34 |
groupBarsByLines.setSelection(this.getResultData().isGroupingByLines());
|
|
34 | 35 |
groupBarsByLines.addSelectionListener(new SelectionListener() { |
35 | 36 |
|
36 | 37 |
@Override |
37 | 38 |
public void widgetSelected(SelectionEvent e) { |
38 |
getResultData().saveParameter(SpecificitiesPreferences.CHART_TRANSPOSE, groupBarsByLines.getSelection()); |
|
39 |
getResultData().setDirty(); |
|
40 |
getResultData().setNeedsToResetView(true); |
|
39 |
getResultData().setGroupByLines(groupBarsByLines.getSelection()); |
|
41 | 40 |
compute(true); |
42 | 41 |
} |
43 | 42 |
|
... | ... | |
46 | 45 |
// does nothing |
47 | 46 |
} |
48 | 47 |
}); |
48 |
|
|
49 | 49 |
|
50 |
|
|
51 |
// Banality |
|
52 |
Label label = new Label(this.getCommandParametersGroup(), SWT.NONE); |
|
53 |
label.setText("Banality:"); |
|
54 |
|
|
55 |
final Spinner banality = new Spinner(this.getCommandParametersGroup(), SWT.BORDER); |
|
56 |
int nbDigits = 1; |
|
57 |
banality.setToolTipText("Banality threshold"); |
|
58 |
banality.setDigits(nbDigits); |
|
59 |
banality.setIncrement(1); |
|
60 |
banality.setMinimum(0); |
|
61 |
banality.setMaximum(200); |
|
62 |
banality.setSelection(((int) (getResultData().getBanality() * Math.pow(10, nbDigits)))); |
|
63 |
banality.addSelectionListener(new SelectionListener() { |
|
64 |
|
|
65 |
@Override |
|
66 |
public void widgetSelected(SelectionEvent e) { |
|
67 |
getResultData().setBanality(getSpinnerFloatSelection(banality)); |
|
68 |
compute(true); |
|
69 |
} |
|
70 |
|
|
71 |
@Override |
|
72 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
73 |
// does nothing |
|
74 |
} |
|
75 |
}); |
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
50 | 81 |
} |
51 | 82 |
|
83 |
|
|
84 |
@Override |
|
85 |
public SpecificitiesSelection getResultData() { |
|
86 |
return (SpecificitiesSelection) super.getResultData(); |
|
87 |
} |
|
52 | 88 |
} |
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesEditor.java (revision 566) | ||
---|---|---|
50 | 50 |
import org.txm.rcp.editors.TXMEditorPart; |
51 | 51 |
import org.txm.rcp.editors.TableKeyListener; |
52 | 52 |
import org.txm.specificities.core.functions.Specificities; |
53 |
import org.txm.specificities.core.preferences.SpecificitiesPreferences; |
|
54 | 53 |
import org.txm.specificities.rcp.messages.SpecificitiesUIMessages; |
55 | 54 |
import org.txm.statsengine.core.StatException; |
56 | 55 |
import org.txm.utils.logger.Log; |
... | ... | |
59 | 58 |
* Displays a table editor with specificities index. |
60 | 59 |
* |
61 | 60 |
* @author mdecorde |
62 |
* @author sjaquot |
|
61 |
* @author sjacquot
|
|
63 | 62 |
* @author sloiseau |
64 | 63 |
* |
65 | 64 |
*/ |
66 | 65 |
public class SpecificitiesEditor extends TXMEditorPart { |
67 | 66 |
|
68 |
public static String ID = SpecificitiesEditor.class.getName(); |
|
67 |
public final static String ID = SpecificitiesEditor.class.getName();
|
|
69 | 68 |
|
70 | 69 |
/** The specificities table. */ |
71 | 70 |
private Table specificitesTable; |
... | ... | |
77 | 76 |
/** Column for table typeFrequencyColumn. */ |
78 | 77 |
private TableColumn typeFrequencyColumn; |
79 | 78 |
|
79 |
protected Spinner maxScore; |
|
80 |
|
|
80 | 81 |
/** |
81 | 82 |
* Viewer comparator for sorting. |
82 | 83 |
*/ |
83 | 84 |
protected SpecificitiesLinesViewerComparator viewerComparator; |
84 | 85 |
|
85 | 86 |
|
87 |
|
|
88 |
|
|
86 | 89 |
@Override |
87 | 90 |
public void createPartControl(Composite parent) { |
88 | 91 |
super.createPartControl(parent); |
... | ... | |
91 | 94 |
Composite parametersArea = this.getCommandParametersGroup(); |
92 | 95 |
new Label(parametersArea, SWT.NONE).setText("Maximum score"); |
93 | 96 |
|
94 |
final Spinner maxScore = new Spinner(parametersArea, SWT.BORDER);
|
|
95 |
maxScore.setToolTipText("The maximum score to show"); |
|
96 |
maxScore.setMinimum(0); |
|
97 |
maxScore.setSelection(SpecificitiesPreferences.getInt(SpecificitiesPreferences.MAX_SCORE, SpecificitiesPreferences.PREFERENCES_NODE));
|
|
97 |
this.maxScore = new Spinner(parametersArea, SWT.BORDER);
|
|
98 |
this.maxScore.setToolTipText("The maximum score to show");
|
|
99 |
this.maxScore.setMinimum(0);
|
|
100 |
this.maxScore.setSelection(this.getResultData().getMaxScore());
|
|
98 | 101 |
try { |
99 | 102 |
composeDisplayArea(); |
100 | 103 |
this.refresh(false); |
... | ... | |
391 | 394 |
@Override |
392 | 395 |
public void updateEditorFromResult(boolean update) { |
393 | 396 |
this.fillDisplay(); |
394 |
super.refresh(update); |
|
395 | 397 |
} |
396 | 398 |
|
397 | 399 |
|
... | ... | |
461 | 463 |
|
462 | 464 |
@Override |
463 | 465 |
public Specificities getResultData() { |
464 |
return (Specificities) this.getResultData();
|
|
466 |
return (Specificities) super.getResultData();
|
|
465 | 467 |
} |
466 | 468 |
|
467 | 469 |
|
468 | 470 |
@Override |
469 | 471 |
public void updateResultFromEditor() { |
470 |
// TODO Auto-generated method stub |
|
471 |
|
|
472 |
this.getResultData().setMaxScore(this.maxScore.getSelection()); |
|
472 | 473 |
} |
473 | 474 |
|
474 | 475 |
|
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorPart.java (revision 566) | ||
---|---|---|
17 | 17 |
import org.eclipse.swt.widgets.Composite; |
18 | 18 |
import org.eclipse.swt.widgets.Display; |
19 | 19 |
import org.eclipse.swt.widgets.Menu; |
20 |
import org.eclipse.swt.widgets.Spinner; |
|
20 | 21 |
import org.eclipse.swt.widgets.TableColumn; |
21 | 22 |
import org.eclipse.ui.IEditorInput; |
22 | 23 |
import org.eclipse.ui.IEditorPart; |
... | ... | |
310 | 311 |
return this.getEditorInput().getResult().getStringParameterValue(key); |
311 | 312 |
} |
312 | 313 |
|
314 |
|
|
315 |
/** |
|
316 |
* Computes the result stored in the specified editor input and opens an editor specified by its id. |
|
317 |
* @param editorInput |
|
318 |
* @param editorPartId |
|
319 |
* @return |
|
320 |
*/ |
|
321 |
public static void openEditor(TXMResultEditorInput editorInput, String editorPartId) { |
|
322 |
compute(editorInput, editorPartId, false, null); |
|
323 |
} |
|
324 |
|
|
325 |
/** |
|
326 |
* Computes specified result stored, creates an editor input and opens an editor specified by its id. |
|
327 |
* @param result |
|
328 |
* @param editorPartId |
|
329 |
* @return |
|
330 |
*/ |
|
331 |
public static void openEditor(TXMResult result, String editorPartId) { |
|
332 |
openEditor(new TXMResultEditorInput(result), editorPartId); |
|
333 |
} |
|
334 |
|
|
335 |
|
|
336 |
|
|
313 | 337 |
public final void compute(boolean update) { |
314 |
compute(this.getResultData(), update, this);
|
|
338 |
compute(update, this); |
|
315 | 339 |
} |
316 | 340 |
|
317 |
public static void compute(final TXMResult result) { |
|
318 |
compute(result, false, null); |
|
341 |
|
|
342 |
public static void compute(final boolean update, final TXMEditorPart editor) { |
|
343 |
compute(editor.getEditorInput(), null, update, editor); |
|
319 | 344 |
} |
320 | 345 |
|
321 | 346 |
/** |
... | ... | |
327 | 352 |
* @param resetView |
328 | 353 |
* @param clearChartItemsSelection |
329 | 354 |
*/ |
330 |
public static void compute(final TXMResult result, final boolean update, final TXMEditorPart editor) {
|
|
355 |
public static void compute(final TXMResultEditorInput editorInput, final String editorId, final boolean update, final TXMEditorPart editor) {
|
|
331 | 356 |
|
332 |
StatusLine.setMessage("Computing " + result.getName());
|
|
357 |
StatusLine.setMessage("Computing " + editorInput.getResult().getName());
|
|
333 | 358 |
|
334 | 359 |
JobHandler job = new JobHandler("Computing result") { |
335 | 360 |
|
361 |
TXMEditorPart currentEditor = null; |
|
362 |
|
|
336 | 363 |
@Override |
337 | 364 |
protected IStatus run(IProgressMonitor monitor) { |
338 | 365 |
|
... | ... | |
340 | 367 |
|
341 | 368 |
try { |
342 | 369 |
JobsTimer.start(); |
370 |
|
|
343 | 371 |
|
372 |
currentEditor = editor; |
|
373 |
|
|
344 | 374 |
// transfer editor parameters to result |
345 |
// if (editor != null) {
|
|
346 |
// editor.updateResultFromEditor();
|
|
375 |
// if (currentEditor != null) {
|
|
376 |
// currentEditor.updateResultFromEditor();
|
|
347 | 377 |
// } |
348 | 378 |
|
349 | 379 |
|
350 | 380 |
// computing result |
351 | 381 |
monitor.beginTask("Computing", 100); |
352 | 382 |
|
353 |
// FIXME: to restore when implemented |
|
354 |
// if(!update) { |
|
355 |
// result.loadParameters(); |
|
356 |
// } |
|
357 |
|
|
358 |
if (!result.compute(update, monitor)) { |
|
359 |
return Status.CANCEL_STATUS; |
|
360 |
} |
|
383 |
editorInput.getResult().compute(update, monitor); |
|
361 | 384 |
|
362 |
monitor.worked(50); |
|
363 |
|
|
364 |
// cancel |
|
365 |
// if(monitor.isCanceled()) { |
|
385 |
// if (!editorInput.getResult().compute(update, monitor)) { |
|
366 | 386 |
// return Status.CANCEL_STATUS; |
367 | 387 |
// } |
368 | 388 |
|
389 |
monitor.worked(50); |
|
390 |
|
|
391 |
// opening an editor if not exists |
|
392 |
if (currentEditor == null) { |
|
393 |
this.syncExec(new Runnable() { |
|
394 |
@Override |
|
395 |
public void run() { |
|
396 |
try { |
|
397 |
|
|
398 |
Log.info("TXMEditorPart.compute(): opening editor with id " + editorId); |
|
399 |
|
|
400 |
IWorkbenchWindow window =TXMWindows.getActiveWindow(); |
|
401 |
IWorkbenchPage page = window.getActivePage(); |
|
402 |
currentEditor = (TXMEditorPart) page.openEditor(editorInput, editorId, true, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID); |
|
403 |
} catch (Exception e) { |
|
404 |
System.err.println("TXMEditorPart.compute(): could not open editor: " + e.getLocalizedMessage()); |
|
405 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
406 |
} |
|
407 |
} |
|
408 |
}); |
|
409 |
} |
|
410 |
|
|
411 |
|
|
369 | 412 |
// refreshing the UI |
370 |
if (editor != null) {
|
|
413 |
if (currentEditor != null) {
|
|
371 | 414 |
this.syncExec(new Runnable() { |
372 | 415 |
@Override |
373 | 416 |
public void run() { |
374 |
editor.refresh(update);
|
|
417 |
currentEditor.refresh(update);
|
|
375 | 418 |
} |
376 | 419 |
}); |
377 | 420 |
} |
... | ... | |
396 | 439 |
job.setPriority(Job.DECORATE); |
397 | 440 |
job.setUser(false); |
398 | 441 |
job.schedule(); |
399 |
// try { |
|
400 |
// job.join(); |
|
401 |
// } |
|
402 |
// catch (InterruptedException e) { |
|
403 |
// // TODO Auto-generated catch block |
|
404 |
// e.printStackTrace(); |
|
405 |
// } |
|
406 | 442 |
} |
407 | 443 |
|
408 | 444 |
// FIXME: old code |
... | ... | |
496 | 532 |
|
497 | 533 |
/** |
498 | 534 |
* Synchronizes the result with editor parameters. |
499 |
* This should be called or called itself in the UI thread when accessing Widget parameters.
|
|
535 |
* It should be called or called itself in the UI thread when accessing Widget parameters.
|
|
500 | 536 |
*/ |
501 | 537 |
public abstract void updateResultFromEditor(); |
502 | 538 |
|
503 | 539 |
/** |
504 | 540 |
* Synchronizes the editor with the result. |
505 |
* Dedicated to dynamically change the editor informations (as the part name) from the stored result.
|
|
541 |
* Dedicated to dynamically change the editor components from the stored result.
|
|
506 | 542 |
*/ |
507 | 543 |
public abstract void updateEditorFromResult(boolean update); |
508 | 544 |
|
... | ... | |
578 | 614 |
menuManager.update(true); |
579 | 615 |
return menu; |
580 | 616 |
} |
581 |
|
|
582 |
/** |
|
583 |
* Computes the result stored in the specified editor input and opens an editor specified by its id. |
|
584 |
* @param editorInput |
|
585 |
* @param editorPartId |
|
586 |
* @param activate |
|
587 |
* @param matchFlags |
|
588 |
* @return |
|
589 |
*/ |
|
590 |
public static TXMEditorPart openEditor(final TXMResultEditorInput editorInput, String editorPartId, boolean activate, int matchFlags) { |
|
591 |
|
|
592 |
// Display.getDefault().syncExec(new Runnable() { |
|
593 |
// |
|
594 |
// @Override |
|
595 |
// public void run() { |
|
596 |
// TODO Auto-generated method stub |
|
597 |
compute(editorInput.getResult()); |
|
598 |
// } |
|
599 |
// }); |
|
600 |
|
|
601 |
|
|
602 |
|
|
603 |
TXMEditorPart editor = null; |
|
604 |
try { |
|
605 |
|
|
606 |
Log.info("TXMEditorPart.openEditor(): opening editor with id " + editorPartId); |
|
607 |
|
|
608 |
IWorkbenchWindow window =TXMWindows.getActiveWindow(); |
|
609 |
IWorkbenchPage page = window.getActivePage(); |
|
610 |
editor = (TXMEditorPart) page.openEditor(editorInput, editorPartId, activate, matchFlags); |
|
611 |
} catch (Exception e) { |
|
612 |
System.err.println("TXMEditorPart.openEditor(): could not open editor: " + e.getLocalizedMessage()); |
|
613 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
614 |
} |
|
615 |
return editor; |
|
616 |
} |
|
617 |
|
|
618 |
/** |
|
619 |
* Computes the result stored in the specified editor input and opens an editor specified by its id. |
|
620 |
* @param editorInput |
|
621 |
* @param editorPartId |
|
622 |
* @return |
|
623 |
*/ |
|
624 |
public static TXMEditorPart openEditor(TXMResultEditorInput editorInput, String editorPartId) { |
|
625 |
return openEditor(editorInput, editorPartId, true, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID); |
|
626 |
} |
|
627 |
|
|
628 |
/** |
|
629 |
* Computes specified result stored, creates an editor input and opens an editor specified by its id. |
|
630 |
* @param result |
|
631 |
* @param editorPartId |
|
632 |
* @return |
|
633 |
*/ |
|
634 |
public static TXMEditorPart openEditor(TXMResult result, String editorPartId) { |
|
635 |
return openEditor(new TXMResultEditorInput(result), editorPartId); |
|
636 |
} |
|
637 |
|
|
638 | 617 |
|
639 | 618 |
/** |
640 | 619 |
* Gets the parameters composite. |
... | ... | |
658 | 637 |
viewer.getControl().setRedraw(true); |
659 | 638 |
} |
660 | 639 |
|
640 |
/** |
|
641 |
* Returns the spinner value as float. |
|
642 |
* @param spinner |
|
643 |
* @return |
|
644 |
*/ |
|
645 |
public static float getSpinnerFloatSelection(Spinner spinner) { |
|
646 |
return (float) (spinner.getSelection() / Math.pow(10, spinner.getDigits())); |
|
647 |
} |
|
648 |
|
|
649 |
|
|
650 |
|
|
651 |
|
|
661 | 652 |
public Composite getToolBarContainer(String toolbarLocalId) { |
662 | 653 |
if ("top".equals(toolbarLocalId)) { |
663 | 654 |
return this.getTopToolBarContainer(); |
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 566) | ||
---|---|---|
91 | 91 |
/** |
92 | 92 |
* To keep track of the parameters used for the last computing and to determine if the result is dirty. |
93 | 93 |
*/ |
94 |
protected HashMap<String, Object> lastComputeParameters = new HashMap<String, Object>();
|
|
94 |
protected HashMap<String, Object> lastComputingParameters = new HashMap<String, Object>();
|
|
95 | 95 |
|
96 | 96 |
|
97 | 97 |
/** |
... | ... | |
152 | 152 |
* Updates the last parameters used for computing. |
153 | 153 |
* @throws Exception |
154 | 154 |
*/ |
155 |
protected void updateLastComputeParameters() throws Exception {
|
|
155 |
protected void updateLastComputingParameters() throws Exception {
|
|
156 | 156 |
Field[] fields = this.getClass().getDeclaredFields(); |
157 | 157 |
for (Field f : fields) { |
158 | 158 |
String name = f.getName(); |
159 |
Parameter annotations = f.getAnnotation(Parameter.class);
|
|
160 |
if (annotations == null){
|
|
159 |
Parameter parameter = f.getAnnotation(Parameter.class);
|
|
160 |
if (parameter == null || parameter.type() != Parameter.COMPUTING) {
|
|
161 | 161 |
continue; |
162 | 162 |
} |
163 | 163 |
f.setAccessible(true); |
164 |
lastComputeParameters.put(name, f.get(this));
|
|
164 |
lastComputingParameters.put(name, f.get(this));
|
|
165 | 165 |
} |
166 | 166 |
} |
167 | 167 |
|
... | ... | |
184 | 184 |
Field[] fields = clazz.getDeclaredFields(); |
185 | 185 |
for (Field f : fields) { |
186 | 186 |
String name = f.getName(); |
187 |
Parameter annotation = f.getAnnotation(Parameter.class);
|
|
188 |
if (annotation == null) {
|
|
187 |
Parameter parameter = f.getAnnotation(Parameter.class);
|
|
188 |
if (parameter == null || parameter.type() != Parameter.COMPUTING) {
|
|
189 | 189 |
continue; |
190 | 190 |
} |
191 | 191 |
f.setAccessible(true); // not to set accessible to test the field values |
192 |
Object previousValue = lastComputeParameters.get(name);
|
|
192 |
Object previousValue = lastComputingParameters.get(name);
|
|
193 | 193 |
Object newValue = f.get(this); |
194 | 194 |
updateDirty(previousValue, newValue); |
195 | 195 |
if (dirty) { |
... | ... | |
919 | 919 |
if (!this.isDirtyFromHistory()) { |
920 | 920 |
|
921 | 921 |
// FIXME: Debug |
922 |
System.err.println("TXMResult.compute(): parameters have not changed since last computing, computing skipped."); |
|
922 |
System.err.println("TXMResult.compute(): result parameters have not changed since last computing, computing skipped.");
|
|
923 | 923 |
|
924 | 924 |
return true; |
925 | 925 |
} |
... | ... | |
942 | 942 |
// // TODO THIS IS FUCKING LAZY LINE CODES OH YEAH YOU MAD BRO |
943 | 943 |
// TODO where do we put this parent compute ? :o |
944 | 944 |
// if (parent != null && !parent.getHasBeenComputedOnce()) { // parent must be computed at least one time |
945 |
// SJ: other way, test the object itself |
|
946 |
// if (parent != null && !this.getHasBeenComputedOnce()) { |
|
945 | 947 |
// this.parent.compute(update, monitor); |
946 | 948 |
// } |
947 |
|
|
948 | 949 |
|
950 |
|
|
949 | 951 |
if (!this._compute(update)) { |
950 | 952 |
|
951 | 953 |
// FIXME: Debug |
... | ... | |
954 | 956 |
return false; |
955 | 957 |
} |
956 | 958 |
|
957 |
this.updateLastComputeParameters(); // store last used parameters
|
|
959 |
this.updateLastComputingParameters(); // store last used parameters
|
|
958 | 960 |
|
959 | 961 |
if (!this.saveParameters()) { |
960 | 962 |
System.out.println("Warning: " + this.getName() + " parameters are not saved."); |
tmp/org.txm.core/src/java/org/txm/core/results/Parameter.java (revision 566) | ||
---|---|---|
18 | 18 |
@Target({FIELD,METHOD,PARAMETER}) |
19 | 19 |
public @interface Parameter { |
20 | 20 |
|
21 |
public final int COMPUTING = 0, RENDERING = 1; |
|
22 |
|
|
21 | 23 |
// FIXME: could be used to automate saveParameters(), loadParameters(), etc. for accessing the preferences node value of a key in TXMResult class |
22 | 24 |
//public String preferenceName() default ""; |
25 |
|
|
26 |
|
|
27 |
public int type() default Parameter.COMPUTING; |
|
23 | 28 |
} |
tmp/org.txm.partition.rcp/src/org/txm/partition/rcp/handlers/ComputePartitionDimensionsBarChart.java (revision 566) | ||
---|---|---|
31 | 31 |
import org.eclipse.core.commands.ExecutionException; |
32 | 32 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart; |
33 | 33 |
import org.txm.partition.core.functions.PartitionDimensions; |
34 |
import org.txm.rcp.editors.TXMEditorPart; |
|
34 | 35 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
35 | 36 |
import org.txm.rcp.views.corpora.CorporaView; |
36 | 37 |
import org.txm.searchengine.cqp.corpus.Partition; |
... | ... | |
90 | 91 |
// FIXME: Pie chart tests |
91 | 92 |
// partitionDimensions.setChartType("Partition Dimensions Pie Chart"); //$NON-NLS-1$ |
92 | 93 |
|
93 |
ChartEditorPart.openEditor(partitionDimensions); |
|
94 |
ChartEditorPart.openEditor(partitionDimensions, partitionDimensions.getClass().getName());
|
|
94 | 95 |
|
95 | 96 |
return null; |
96 | 97 |
} |
tmp/org.txm.partition.rcp/src/org/txm/partition/rcp/preferences/PartitionPreferencePage.java (revision 566) | ||
---|---|---|
56 | 56 |
// Charts rendering |
57 | 57 |
Composite chartsTab = SWTChartsComponentsProvider.createChartsRenderingPreferencesTabFolderComposite(this.getFieldEditorParent(), "Dimensions chart rendering"); |
58 | 58 |
|
59 |
this.addField(new BooleanFieldEditor(PartitionDimensionsPreferences.SORTED_BY_SIZE, PartitionUIMessages.PreferencesPage_DIMENSIONS_SORT_BY_PARTS_SIZE, chartsTab));
|
|
60 |
this.addField(new BooleanFieldEditor(PartitionDimensionsPreferences.DISPLAY_PARTS_COUNT_IN_TITLE, PartitionUIMessages.PreferencesPage_DIMENSIONS_DISPLAY_PARTS_COUNT_IN_TITLE, chartsTab)); |
|
59 |
this.addField(new BooleanFieldEditor(PartitionDimensionsPreferences.CHART_DIMENSIONS_SORT_BY_SIZE, PartitionUIMessages.PreferencesPage_DIMENSIONS_SORT_BY_PARTS_SIZE, chartsTab));
|
|
60 |
this.addField(new BooleanFieldEditor(PartitionDimensionsPreferences.CHART_DIMENSIONS_DISPLAY_PARTS_COUNT_IN_TITLE, PartitionUIMessages.PreferencesPage_DIMENSIONS_DISPLAY_PARTS_COUNT_IN_TITLE, chartsTab));
|
|
61 | 61 |
|
62 | 62 |
// other shared preferences |
63 | 63 |
SWTChartsComponentsProvider.createChartsRenderingPreferencesFields(this, chartsTab); |
tmp/org.txm.partition.rcp/src/org/txm/partition/rcp/editors/PartitionDimensionsEditor.java (revision 566) | ||
---|---|---|
10 | 10 |
import org.eclipse.swt.widgets.ToolItem; |
11 | 11 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart; |
12 | 12 |
import org.txm.partition.core.functions.PartitionDimensions; |
13 |
import org.txm.partition.core.preferences.PartitionDimensionsPreferences; |
|
14 | 13 |
import org.txm.partition.rcp.messages.PartitionUIMessages; |
15 | 14 |
import org.txm.rcp.IImageKeys; |
16 | 15 |
|
... | ... | |
34 | 33 |
final ToolItem sortByPartSize = new ToolItem(this.getToolBar(), SWT.CHECK); |
35 | 34 |
sortByPartSize.setImage(IImageKeys.getImage(this.getClass(), "icons/silk_sort_by_size.png")); |
36 | 35 |
sortByPartSize.setToolTipText(PartitionUIMessages.PreferencesPage_DIMENSIONS_SORT_BY_PARTS_SIZE); |
37 |
sortByPartSize.setSelection(this.getBooleanParameterValue(PartitionDimensionsPreferences.SORTED_BY_SIZE));
|
|
36 |
sortByPartSize.setSelection(this.getResultData().isSortingBySize());
|
|
38 | 37 |
|
39 | 38 |
sortByPartSize.addSelectionListener(new SelectionListener() { |
40 | 39 |
|
41 | 40 |
@Override |
42 | 41 |
public void widgetSelected(SelectionEvent e) { |
43 |
((PartitionDimensions)getResultData()).setParameters(sortByPartSize.getSelection());
|
|
42 |
getResultData().setSortBySize(sortByPartSize.getSelection());
|
|
44 | 43 |
compute(true); |
45 | 44 |
} |
46 | 45 |
|
... | ... | |
50 | 49 |
|
51 | 50 |
} |
52 | 51 |
}); |
53 |
|
|
54 | 52 |
} |
53 |
|
|
54 |
|
|
55 |
@Override |
|
56 |
public PartitionDimensions getResultData() { |
|
57 |
// TODO Auto-generated method stub |
|
58 |
return (PartitionDimensions) super.getResultData(); |
|
59 |
} |
|
60 |
|
|
55 | 61 |
} |
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/SWTChartsComponentsProvider.java (revision 566) | ||
---|---|---|
588 | 588 |
* @return |
589 | 589 |
*/ |
590 | 590 |
// FIXME: this method have some trouble when calling through a progress dialog |
591 |
// FIXME: this method is not in use anymore since the editor opening is now down in TXMEditorPart so the code for ChartEngine downgrading is not |
|
592 |
// active anymore. Try to use again this code |
|
591 | 593 |
public ChartEditorPart openEditor(ChartEditorInput chartEditorInput, String editorPartId) { |
592 | 594 |
|
593 | 595 |
ChartEditorPart openedChartEditorPart = null; |
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditorPart.java (revision 566) | ||
---|---|---|
26 | 26 |
import org.txm.chartsengine.rcp.swt.AdvancedChartEditorToolBar; |
27 | 27 |
import org.txm.chartsengine.rcp.swt.ChartComposite; |
28 | 28 |
import org.txm.chartsengine.rcp.swt.ChartEditorToolBar; |
29 |
import org.txm.core.results.TXMResult; |
|
29 | 30 |
import org.txm.rcp.editors.TXMEditorPart; |
30 | 31 |
import org.txm.rcp.editors.TXMEditorToolBar; |
32 |
import org.txm.rcp.editors.TXMResultEditorInput; |
|
31 | 33 |
import org.txm.utils.logger.Log; |
32 | 34 |
|
33 | 35 |
/** |
... | ... | |
174 | 176 |
* @param result |
175 | 177 |
* @return |
176 | 178 |
*/ |
177 |
public static ChartEditorPart openEditor(ChartResult result) { |
|
178 |
return openEditor(result, SWTChartsComponentsProvider.getCurrent()); |
|
179 |
// public static ChartEditorPart openEditor(ChartResult result) { |
|
180 |
// return openEditor(result, SWTChartsComponentsProvider.getCurrent()); |
|
181 |
// } |
|
182 |
|
|
183 |
public static void openEditor(ChartResult result) { |
|
184 |
openEditor(result, result.getClass().getName()); |
|
179 | 185 |
} |
186 |
|
|
180 | 187 |
|
188 |
public static void openEditor(ChartResult result, String editorPartId) { |
|
189 |
compute(new ChartEditorInput(result), editorPartId, false, null); |
|
190 |
} |
|
191 |
|
|
192 |
|
|
181 | 193 |
/** |
182 | 194 |
* |
183 | 195 |
* @param result |
184 | 196 |
* @param chartsComponentsProvider |
185 | 197 |
* @return |
186 | 198 |
*/ |
187 |
public static ChartEditorPart openEditor(ChartResult result, SWTChartsComponentsProvider chartsComponentsProvider) {
|
|
188 |
compute(result);
|
|
189 |
return chartsComponentsProvider.openEditor(result); |
|
199 |
public static void openEditor(ChartResult result, SWTChartsComponentsProvider chartsComponentsProvider) {
|
|
200 |
compute(new ChartEditorInput(result), result.getClass().getName(), false, null);
|
|
201 |
//return chartsComponentsProvider.openEditor(result);
|
|
190 | 202 |
} |
191 | 203 |
|
192 | 204 |
|
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/ChartComposite.java (revision 566) | ||
---|---|---|
4 | 4 |
import java.util.ArrayList; |
5 | 5 |
import java.util.EventListener; |
6 | 6 |
|
7 |
import org.eclipse.jface.action.MenuManager; |
|
8 | 7 |
import org.eclipse.swt.SWT; |
9 | 8 |
import org.eclipse.swt.widgets.Composite; |
10 | 9 |
import org.eclipse.swt.widgets.Menu; |
11 | 10 |
import org.eclipse.swt.widgets.MenuItem; |
12 |
import org.eclipse.ui.PlatformUI; |
|
13 |
import org.eclipse.ui.menus.IMenuService; |
|
14 | 11 |
import org.txm.chartsengine.rcp.IChartComponent; |
15 | 12 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart; |
16 | 13 |
import org.txm.chartsengine.rcp.events.EventCallBack; |
tmp/org.txm.partition.core/src/org/txm/partition/core/preferences/PartitionDimensionsPreferences.java (revision 566) | ||
---|---|---|
19 | 19 |
|
20 | 20 |
public static final String PREFERENCES_PREFIX = "partition_"; //$NON-NLS-1$ |
21 | 21 |
|
22 |
public static final String DISPLAY_PARTS_COUNT_IN_TITLE = PREFERENCES_PREFIX + "chart_dimensions_display_parts_count_in_title"; //$NON-NLS-1$ |
|
23 |
public static final String SORTED_BY_SIZE = PREFERENCES_PREFIX + "chart_dimensions_sort_by_parts_size"; //$NON-NLS-1$
|
|
22 |
public static final String CHART_DIMENSIONS_DISPLAY_PARTS_COUNT_IN_TITLE = PREFERENCES_PREFIX + "chart_dimensions_display_parts_count_in_title"; //$NON-NLS-1$
|
|
23 |
public static final String CHART_DIMENSIONS_SORT_BY_SIZE = PREFERENCES_PREFIX + "chart_dimensions_sort_by_parts_size"; //$NON-NLS-1$
|
|
24 | 24 |
|
25 | 25 |
@Override |
26 | 26 |
public void initializeDefaultPreferences() { |
27 | 27 |
Preferences preferences = DefaultScope.INSTANCE.getNode(PREFERENCES_NODE); |
28 |
preferences.putBoolean(DISPLAY_PARTS_COUNT_IN_TITLE, true); |
|
29 |
preferences.putBoolean(SORTED_BY_SIZE, false);
|
|
28 |
preferences.putBoolean(CHART_DIMENSIONS_DISPLAY_PARTS_COUNT_IN_TITLE, true);
|
|
29 |
preferences.putBoolean(CHART_DIMENSIONS_SORT_BY_SIZE, false);
|
|
30 | 30 |
|
31 | 31 |
// shared charts rendering preferences |
32 | 32 |
ChartsEnginePreferences.initializeChartsEngineSharedPreferences(preferences); |
tmp/org.txm.partition.core/src/org/txm/partition/core/functions/PartitionDimensions.java (revision 566) | ||
---|---|---|
28 | 28 |
*/ |
29 | 29 |
public class PartitionDimensions extends ChartResult { |
30 | 30 |
|
31 |
/** if true the part bars are sorted by size. */ |
|
32 |
@Parameter |
|
33 |
protected Boolean pSortBySize; |
|
31 |
/** |
|
32 |
* Parent partition parts caching. |
|
33 |
*/ |
|
34 |
protected List<Part> parts = null; |
|
34 | 35 |
|
35 | 36 |
/** |
37 |
* Parent partition parts sorted by size caching. |
|
38 |
*/ |
|
39 |
protected List<Part> partsSortedBySize = null; |
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
@Parameter(type=Parameter.RENDERING) |
|
44 |
protected boolean displayPartCountInTitle; |
|
45 |
|
|
46 |
@Parameter(type=Parameter.RENDERING) |
|
47 |
protected boolean sortBySize; |
|
48 |
|
|
49 |
|
|
50 |
/** |
|
36 | 51 |
* Creates a partition dimensions result from the specified <link>Partition</link>. |
37 | 52 |
*/ |
38 | 53 |
public PartitionDimensions(Partition partition) { |
39 | 54 |
super(partition); |
55 |
this.loadParameters(); |
|
40 | 56 |
} |
41 | 57 |
|
42 | 58 |
|
43 | 59 |
|
44 | 60 |
@Override |
61 |
public boolean loadParameters() { |
|
62 |
this.displayPartCountInTitle = this.getBooleanParameterValue(PartitionDimensionsPreferences.CHART_DIMENSIONS_DISPLAY_PARTS_COUNT_IN_TITLE); |
|
63 |
this.sortBySize = this.getBooleanParameterValue(PartitionDimensionsPreferences.CHART_DIMENSIONS_SORT_BY_SIZE); |
|
64 |
return true; |
|
65 |
} |
|
66 |
|
|
67 |
|
|
68 |
@Override |
|
45 | 69 |
protected boolean _compute(boolean update) throws Exception { |
46 |
// does nothing |
|
70 |
// parts |
|
71 |
this.parts = this.getPartition().getParts(); |
|
72 |
|
|
73 |
// parts sorted by size |
|
74 |
List<Part> sortedParts = new ArrayList<Part>(this.parts); |
|
75 |
Collections.sort(sortedParts, new Comparator<Part>() { |
|
76 |
@Override |
|
77 |
public int compare(Part arg0, Part arg1) { |
|
78 |
try { |
|
79 |
return arg1.getSize() - arg0.getSize(); |
|
80 |
} catch (CqiClientException e) { |
|
81 |
return 0; |
|
82 |
} |
|
83 |
} |
|
84 |
}); |
|
85 |
this.partsSortedBySize = sortedParts; |
|
86 |
|
|
47 | 87 |
return true; |
48 | 88 |
} |
49 | 89 |
|
... | ... | |
62 | 102 |
@Override |
63 | 103 |
public boolean setParameters(TXMParameters parameters) { |
64 | 104 |
try { |
65 |
this.setParameters((boolean)parameters.get(PartitionDimensionsPreferences.SORTED_BY_SIZE));
|
|
105 |
this.setSortBySize((boolean)parameters.get(PartitionDimensionsPreferences.CHART_DIMENSIONS_SORT_BY_SIZE));
|
|
66 | 106 |
return true; |
67 | 107 |
} |
68 | 108 |
catch(Exception e) { |
... | ... | |
72 | 112 |
return false; |
73 | 113 |
} |
74 | 114 |
|
75 |
/** |
|
76 |
* |
|
77 |
* @param sortByPartSize |
|
78 |
*/ |
|
79 |
public void setParameters(boolean sortByPartSize) { |
|
80 |
pSortBySize = sortByPartSize; |
|
81 |
this.setDirty(); |
|
82 |
this.setChartDirty(); |
|
83 |
} |
|
84 | 115 |
|
85 |
@Override |
|
86 |
public boolean loadParameters() { |
|
87 |
pSortBySize = getBooleanParameterValue(PartitionDimensionsPreferences.SORTED_BY_SIZE); |
|
88 |
return true; |
|
89 |
} |
|
90 | 116 |
|
91 |
@Override |
|
92 |
public boolean saveParameters() { |
|
93 |
if (pSortBySize != null) setParameterValue(PartitionDimensionsPreferences.SORTED_BY_SIZE, pSortBySize); |
|
94 |
return true; |
|
95 |
} |
|
96 |
|
|
97 |
|
|
98 | 117 |
/** |
99 | 118 |
* Convenience method. |
100 | 119 |
*/ |
... | ... | |
108 | 127 |
} |
109 | 128 |
} |
110 | 129 |
|
111 |
/** |
|
112 |
* Gets a copy of the parts sorted by descendant size order. |
|
113 |
* @return |
|
114 |
*/ |
|
115 |
public List<Part> getPartsSortedBySize() { |
|
116 |
|
|
117 |
List<Part> sortedParts = new ArrayList<Part>(this.getPartition().getParts()); |
|
118 |
|
|
119 |
Collections.sort(sortedParts, new Comparator<Part>() { |
|
120 |
@Override |
|
121 |
public int compare(Part arg0, Part arg1) { |
|
122 |
try { |
|
123 |
return arg1.getSize() - arg0.getSize(); |
|
124 |
} catch (CqiClientException e) { |
|
125 |
return 0; |
|
126 |
} |
|
127 |
} |
|
128 |
}); |
|
129 |
|
|
130 |
return sortedParts; |
|
131 |
} |
|
132 | 130 |
|
133 | 131 |
|
134 | 132 |
/** |
... | ... | |
136 | 134 |
* @return |
137 | 135 |
*/ |
138 | 136 |
public int getPartsCount() { |
139 |
return this.getPartition().getNPart();
|
|
137 |
return this.parts.size();
|
|
140 | 138 |
} |
141 | 139 |
|
142 | 140 |
/** |
... | ... | |
146 | 144 |
*/ |
147 | 145 |
public List<Part> getParts(boolean sortedBySize) { |
148 | 146 |
if(sortedBySize) { |
149 |
return this.getPartsSortedBySize();
|
|
147 |
return this.partsSortedBySize;
|
|
150 | 148 |
} |
151 | 149 |
else { |
152 |
return this.getPartition().getParts();
|
|
150 |
return this.parts;
|
|
153 | 151 |
} |
154 | 152 |
} |
155 | 153 |
|
... | ... | |
193 | 191 |
return false; |
194 | 192 |
} |
195 | 193 |
|
194 |
|
|
195 |
|
|
196 |
/** |
|
197 |
* @return the sortBySize |
|
198 |
*/ |
|
199 |
public boolean isSortingBySize() { |
|
200 |
return sortBySize; |
|
201 |
} |
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
/** |
|
206 |
* @param sortBySize the sortBySize to set |
|
207 |
*/ |
|
208 |
public void setSortBySize(boolean sortBySize) { |
|
209 |
this.sortBySize = sortBySize; |
|
210 |
} |
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
/** |
|
215 |
* @return the displayPartCountInTitle |
|
216 |
*/ |
|
217 |
public boolean isDisplayingPartCountInTitle() { |
|
218 |
return displayPartCountInTitle; |
|
219 |
} |
|
220 |
|
|
196 | 221 |
} |
tmp/org.txm.partition.core/src/org/txm/partition/core/chartsengine/r/RPartitionDimensionsBarChartCreator.java (revision 566) | ||
---|---|---|
10 | 10 |
import org.txm.partition.core.chartsengine.base.Utils; |
11 | 11 |
import org.txm.partition.core.functions.PartitionDimensions; |
12 | 12 |
import org.txm.partition.core.messages.PartitionCoreMessages; |
13 |
import org.txm.partition.core.preferences.PartitionDimensionsPreferences; |
|
14 | 13 |
import org.txm.searchengine.cqp.corpus.Part; |
15 | 14 |
import org.txm.utils.logger.Log; |
16 | 15 |
|
... | ... | |
30 | 29 |
PartitionDimensions partitionDimensions = (PartitionDimensions) result; |
31 | 30 |
|
32 | 31 |
// parameters |
33 |
boolean sortPartsBySize = result.getBooleanParameterValue(PartitionDimensionsPreferences.SORTED_BY_SIZE);
|
|
34 |
boolean displayPartsCountInTitle = result.getBooleanParameterValue(PartitionDimensionsPreferences.DISPLAY_PARTS_COUNT_IN_TITLE);
|
|
32 |
boolean sortPartsBySize = partitionDimensions.isSortingBySize();
|
|
33 |
boolean displayPartsCountInTitle = partitionDimensions.isDisplayingPartCountInTitle();
|
|
35 | 34 |
|
36 | 35 |
List<Part> parts = partitionDimensions.getParts(sortPartsBySize); |
37 | 36 |
|
tmp/org.txm.partition.core/src/org/txm/partition/core/chartsengine/r/RPartitionDimensionsPieChartCreator.java (revision 566) | ||
---|---|---|
4 | 4 |
import java.util.List; |
5 | 5 |
|
6 | 6 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
7 |
import org.txm.core.preferences.TXMPreferences; |
|
8 |
import org.txm.core.results.TXMResult; |
|
9 | 7 |
import org.txm.chartsengine.r.core.RChartCreator; |
10 | 8 |
import org.txm.chartsengine.r.core.RChartsEngine; |
9 |
import org.txm.core.results.TXMResult; |
|
11 | 10 |
import org.txm.partition.core.chartsengine.base.Utils; |
12 | 11 |
import org.txm.partition.core.functions.PartitionDimensions; |
13 | 12 |
import org.txm.partition.core.messages.PartitionCoreMessages; |
14 |
import org.txm.partition.core.preferences.PartitionDimensionsPreferences; |
|
15 | 13 |
import org.txm.searchengine.cqp.corpus.Part; |
16 | 14 |
import org.txm.utils.logger.Log; |
17 | 15 |
|
... | ... | |
31 | 29 |
PartitionDimensions partitionDimensions = (PartitionDimensions) result; |
32 | 30 |
|
33 | 31 |
// parameters |
34 |
boolean sortPartsBySize = result.getBooleanParameterValue(PartitionDimensionsPreferences.SORTED_BY_SIZE);
|
|
35 |
boolean displayPartsCountInTitle = result.getBooleanParameterValue(PartitionDimensionsPreferences.DISPLAY_PARTS_COUNT_IN_TITLE);
|
|
32 |
boolean sortPartsBySize = partitionDimensions.isSortingBySize();
|
|
33 |
boolean displayPartsCountInTitle = partitionDimensions.isDisplayingPartCountInTitle();
|
|
36 | 34 |
|
37 | 35 |
List<Part> parts = partitionDimensions.getParts(sortPartsBySize); |
38 | 36 |
|
tmp/org.txm.partition.core/src/org/txm/partition/core/chartsengine/jfreechart/JFCPartitionDimensionsPieChartCreator.java (revision 566) | ||
---|---|---|
3 | 3 |
|
4 | 4 |
import org.jfree.chart.JFreeChart; |
5 | 5 |
import org.jfree.data.general.DefaultPieDataset; |
6 |
import org.txm.core.preferences.TXMPreferences; |
|
7 |
import org.txm.core.results.TXMResult; |
|
8 | 6 |
import org.txm.chartsengine.jfreechart.core.JFCChartCreator; |
7 |
import org.txm.core.results.TXMResult; |
|
9 | 8 |
import org.txm.partition.core.chartsengine.base.Utils; |
10 | 9 |
import org.txm.partition.core.functions.PartitionDimensions; |
11 |
import org.txm.partition.core.preferences.PartitionDimensionsPreferences; |
|
12 | 10 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
13 | 11 |
import org.txm.searchengine.cqp.corpus.Part; |
14 | 12 |
|
... | ... | |
20 | 18 |
|
21 | 19 |
public class JFCPartitionDimensionsPieChartCreator extends JFCChartCreator { |
22 | 20 |
|
23 |
public JFCPartitionDimensionsPieChartCreator() { |
|
24 |
} |
|
25 | 21 |
|
26 | 22 |
@Override |
27 | 23 |
public Object createChart(TXMResult result) { |
... | ... | |
29 | 25 |
PartitionDimensions partitionDimensions = (PartitionDimensions) result; |
30 | 26 |
|
31 | 27 |
// parameters |
32 |
boolean sortPartsBySize = result.getBooleanParameterValue(PartitionDimensionsPreferences.SORTED_BY_SIZE);
|
|
33 |
boolean displayPartsCountInTitle = result.getBooleanParameterValue(PartitionDimensionsPreferences.DISPLAY_PARTS_COUNT_IN_TITLE);
|
|
28 |
boolean sortPartsBySize = partitionDimensions.isSortingBySize();
|
|
29 |
boolean displayPartsCountInTitle = partitionDimensions.isDisplayingPartCountInTitle();
|
|
34 | 30 |
|
35 | 31 |
|
36 | 32 |
JFreeChart chart = null; |
tmp/org.txm.partition.core/src/org/txm/partition/core/chartsengine/jfreechart/JFCPartitionDimensionsBarChartCreator.java (revision 566) | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import org.jfree.chart.JFreeChart; |
7 | 7 |
import org.jfree.chart.axis.NumberAxis; |
8 |
import org.jfree.chart.axis.SymbolAxis; |
|
8 | 9 |
import org.jfree.chart.title.TextTitle; |
9 | 10 |
import org.jfree.chart.title.Title; |
10 | 11 |
import org.jfree.data.general.DatasetUtilities; |
... | ... | |
19 | 20 |
import org.txm.partition.core.chartsengine.base.Utils; |
20 | 21 |
import org.txm.partition.core.functions.PartitionDimensions; |
21 | 22 |
import org.txm.partition.core.messages.PartitionCoreMessages; |
22 |
import org.txm.partition.core.preferences.PartitionDimensionsPreferences; |
|
23 | 23 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
24 | 24 |
import org.txm.searchengine.cqp.corpus.Part; |
25 | 25 |
|
... | ... | |
30 | 30 |
*/ |
31 | 31 |
public class JFCPartitionDimensionsBarChartCreator extends JFCChartCreator { |
32 | 32 |
|
33 |
public JFCPartitionDimensionsBarChartCreator() { |
|
34 |
} |
|
35 | 33 |
|
36 | 34 |
@Override |
37 | 35 |
public JFreeChart createChart(TXMResult result) { |
... | ... | |
63 | 61 |
|
64 | 62 |
|
65 | 63 |
// parameters |
66 |
boolean sortPartsBySize = result.getBooleanParameterValue(PartitionDimensionsPreferences.SORTED_BY_SIZE);
|
|
67 |
boolean displayPartsCountInTitle = result.getBooleanParameterValue(PartitionDimensionsPreferences.DISPLAY_PARTS_COUNT_IN_TITLE);
|
|
64 |
boolean sortPartsBySize = partitionDimensions.isSortingBySize();
|
|
65 |
boolean displayPartsCountInTitle = partitionDimensions.isDisplayingPartCountInTitle();
|
|
68 | 66 |
|
69 | 67 |
// Fill the data set |
70 | 68 |
XYSeriesCollection dataset = (XYSeriesCollection) jfcChart.getXYPlot().getDataset(); |
... | ... | |
91 | 89 |
} |
92 | 90 |
|
93 | 91 |
jfcChart.getXYPlot().setDomainAxis(new SymbolAxisBetweenTicks(jfcChart.getXYPlot().getDomainAxis().getLabel(), xAxisSymbols)); |
94 |
|
|
92 |
|
|
95 | 93 |
// Create chart title |
96 | 94 |
jfcChart.setTitle(Utils.createPartitionDimensionsChartTitle(partitionDimensions, sortPartsBySize, displayPartsCountInTitle)); |
97 | 95 |
|
tmp/org.txm.chartsengine.jfreechart.core/src/org/txm/chartsengine/jfreechart/core/themes/base/SymbolAxisBetweenTicks.java (revision 566) | ||
---|---|---|
167 | 167 |
double used = 0.0; |
168 | 168 |
if (isTickLabelsVisible()) { |
169 | 169 |
if (edge == RectangleEdge.LEFT) { |
170 |
used += findMaximumTickLabelWidth(ticks, g2, plotArea, |
|
171 |
isVerticalTickLabels()); |
|
170 |
used += findMaximumTickLabelWidth(ticks, g2, plotArea, isVerticalTickLabels()); |
|
172 | 171 |
state.cursorLeft(used); |
173 | 172 |
} |
174 | 173 |
else if (edge == RectangleEdge.RIGHT) { |
175 |
used = findMaximumTickLabelWidth(ticks, g2, plotArea, |
|
176 |
isVerticalTickLabels()); |
|
174 |
used = findMaximumTickLabelWidth(ticks, g2, plotArea, isVerticalTickLabels()); |
|
177 | 175 |
state.cursorRight(used); |
178 | 176 |
} |
179 | 177 |
else if (edge == RectangleEdge.TOP) { |
180 |
used = findMaximumTickLabelHeight(ticks, g2, plotArea, |
|
181 |
isVerticalTickLabels()); |
|
178 |
used = findMaximumTickLabelHeight(ticks, g2, plotArea, isVerticalTickLabels()); |
|
182 | 179 |
state.cursorUp(used); |
183 | 180 |
} |
184 | 181 |
else if (edge == RectangleEdge.BOTTOM) { |
185 |
used = findMaximumTickLabelHeight(ticks, g2, plotArea, |
|
186 |
isVerticalTickLabels()); |
|
182 |
used = findMaximumTickLabelHeight(ticks, g2, plotArea, isVerticalTickLabels()); |
|
187 | 183 |
state.cursorDown(used); |
188 | 184 |
} |
189 | 185 |
} |
... | ... | |
195 | 191 |
|
196 | 192 |
|
197 | 193 |
@Override |
198 |
protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, |
|
199 |
RectangleEdge edge) { |
|
194 |
protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { |
|
200 | 195 |
|
201 | 196 |
List ticks = new java.util.ArrayList(); |
202 | 197 |
|
tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/results/ChartResult.java (revision 566) | ||
---|---|---|
3 | 3 |
*/ |
4 | 4 |
package org.txm.chartsengine.core.results; |
5 | 5 |
|
6 |
import java.lang.reflect.Field; |
|
7 |
import java.util.HashMap; |
|
8 |
|
|
6 | 9 |
import org.eclipse.core.runtime.IProgressMonitor; |
7 | 10 |
import org.txm.chartsengine.core.ChartCreator; |
8 | 11 |
import org.txm.chartsengine.core.ChartsEngine; |
12 |
import org.txm.core.results.Parameter; |
|
9 | 13 |
import org.txm.core.results.TXMResult; |
14 |
import org.txm.utils.logger.Log; |
|
10 | 15 |
|
11 | 16 |
/** |
12 | 17 |
* Chart result. |
... | ... | |
30 | 35 |
*/ |
31 | 36 |
protected boolean chartDirty; |
32 | 37 |
|
38 |
/** |
|
39 |
* To keep track of the parameters used for the last computing and to determine if the chart result is dirty. |
|
40 |
*/ |
|
41 |
protected HashMap<String, Object> lastRenderingParameters = new HashMap<String, Object>(); |
|
42 |
|
|
33 | 43 |
|
44 |
/** |
|
45 |
* If true, the view will be reset when the chart will be updated. |
|
46 |
*/ |
|
34 | 47 |
protected boolean needsToResetView; |
35 | 48 |
|
49 |
/** |
|
50 |
* If true, the items selection will cleared when the chart will be updated. |
|
51 |
*/ |
|
36 | 52 |
protected boolean needsToClearItemsSelection; |
37 | 53 |
|
38 | 54 |
|
55 |
|
|
56 |
|
|
39 | 57 |
/** |
40 | 58 |
* |
41 | 59 |
* @param parent |
... | ... | |
56 | 74 |
@Override |
57 | 75 |
public boolean compute(boolean update, IProgressMonitor monitor) throws Exception { |
58 | 76 |
|
59 |
this.monitor = monitor; |
|
60 |
|
|
61 | 77 |
// FIXME: Debug |
62 |
System.err.println("ChartResult.compute(): computing result of type " + this.getClass() + "..."); |
|
63 |
|
|
64 |
// TODO uncomment this |
|
65 |
if (!this.isDirtyFromHistory()) { |
|
66 |
|
|
67 |
// FIXME: Debug |
|
68 |
System.err.println("ChartResult.compute(): result parameters have not changed computing skipped."); |
|
69 |
|
|
70 |
// return true; |
|
78 |
// System.err.println("ChartResult.compute(): computing result of type " + this.getClass() + "..."); |
|
79 |
// |
|
80 |
// compute the result if needed |
|
81 |
if(super.compute(update, monitor)) { |
|
82 |
// compute the chart |
|
83 |
return renderChart(update); |
|
71 | 84 |
} |
72 |
|
|
73 |
else if(!this.isDirty()) { |
|
74 |
|
|
75 |
// FIXME: Debug |
|
76 |
System.err.println("ChartResult.compute(): result is not dirty, computing skipped."); |
|
77 |
|
|
78 |
// return true; |
|
79 |
} |
|
80 | 85 |
else { |
81 |
|
|
82 |
if (!canCompute()) { |
|
83 |
// FIXME: Debug |
|
84 |
System.err.println("ChartResult.compute(): missing or wrong parameters, computing aborted."); |
|
85 |
|
|
86 |
return false; |
|
87 |
} |
|
88 |
|
|
89 |
// // TODO THIS IS FUCKING LAZY LINE CODES OH YEAH YOU MAD BRO |
|
90 |
// TODO where do we put this parent compute ? :o |
|
91 |
// if (parent != null && !parent.getHasBeenComputedOnce()) { // parent must be computed at least one time |
|
92 |
// this.parent.compute(update, monitor); |
|
93 |
// } |
|
94 |
|
|
95 |
if (!_compute(update)) { |
|
96 |
|
|
97 |
// FIXME: Debug |
|
98 |
System.err.println("ChartResult.compute(): computing failed."); |
|
99 |
|
|
100 |
return false; |
|
101 |
} |
|
102 |
|
|
103 |
this.updateLastComputeParameters(); // store last used parameters |
|
104 |
|
|
105 |
if (!saveParameters()) { |
|
106 |
System.out.println("ChartResult.compute(): saving parameters failed."); |
|
107 |
} |
|
108 |
|
|
109 |
this.dirty = false; // the _compute was successful the result is no more dirty |
|
110 |
|
|
111 |
// FIXME: Debug |
|
112 |
System.err.println("ChartResult.compute(): computing done."); |
|
86 |
return false; |
|
113 | 87 |
} |
114 |
|
|
115 |
return computeChart(update); |
|
116 |
|
|
117 |
//return true; |
|
118 | 88 |
} |
119 | 89 |
|
120 |
protected boolean computeChart(boolean update) throws Exception {
|
|
90 |
protected boolean renderChart(boolean update) throws Exception {
|
|
121 | 91 |
|
122 |
this.subTask("computing chart");
|
|
92 |
this.subTask("rendering chart");
|
|
123 | 93 |
|
124 | 94 |
// FIXME: Debug |
125 |
System.err.println("ChartResult.computeChart(): computing chart of type " + this.getClass() + "...");
|
|
95 |
System.err.println("ChartResult.renderChart(): rendering chart of type " + this.getClass() + "...");
|
|
126 | 96 |
|
127 |
if(!this.chartDirty) { |
|
97 |
|
|
98 |
if (!this.isChartDirtyFromHistory()) { |
|
99 |
|
|
100 |
// FIXME: Debug |
|
101 |
System.err.println("ChartResult.renderChart(): chart rendering parameters have not changed since last rendering, rendering skipped."); |
|
102 |
return true; |
|
103 |
} |
|
104 |
else if(!this.chartDirty) { |
|
128 | 105 |
|
129 | 106 |
// FIXME: Debug |
130 |
System.err.println("ChartResult.computeChart(): chart is not dirty, computing aborted.");
|
|
107 |
System.err.println("ChartResult.renderChart(): chart is not dirty, rendering skipped.");
|
|
131 | 108 |
|
132 |
return false;
|
|
109 |
return true;
|
|
133 | 110 |
} |
134 | 111 |
|
135 | 112 |
|
... | ... | |
138 | 115 |
|
139 | 116 |
if(update) { |
140 | 117 |
// FIXME: debug |
141 |
System.err.println("ChartResult.computeChart(): updating chart.");
|
|
118 |
System.err.println("ChartResult.renderChart(): updating chart.");
|
|
142 | 119 |
|
143 | 120 |
chartCreator.updateChart(this.chart, this); |
144 | 121 |
} |
145 | 122 |
else { |
146 | 123 |
|
147 | 124 |
// FIXME: debug |
148 |
System.err.println("ChartResult.computeChart(): creating chart.");
|
|
125 |
System.err.println("ChartResult.renderChart(): creating chart.");
|
|
149 | 126 |
|
150 | 127 |
this.chart = chartCreator.createChart(this); |
151 | 128 |
} |
152 | 129 |
|
130 |
this.updateLastRenderingParameters(); |
|
131 |
|
|
132 |
|
|
133 |
this.needsToClearItemsSelection = false; |
|
134 |
this.needsToResetView = false; |
|
135 |
|
|
153 | 136 |
this.chartDirty = false; |
154 | 137 |
return true; |
155 | 138 |
|
... | ... | |
157 | 140 |
return false; |
158 | 141 |
} |
159 | 142 |
|
143 |
|
|
144 |
/** |
|
145 |
* Updates the parameters used for last rendering. |
|
146 |
* @throws Exception |
|
147 |
*/ |
|
148 |
protected void updateLastRenderingParameters() throws Exception { |
|
149 |
Field[] fields = this.getClass().getDeclaredFields(); |
|
150 |
for (Field f : fields) { |
|
151 |
String name = f.getName(); |
|
152 |
Parameter parameter = f.getAnnotation(Parameter.class); |
|
153 |
if (parameter == null || parameter.type() != Parameter.RENDERING) { |
|
154 |
continue; |
|
155 |
} |
|
156 |
f.setAccessible(true); |
|
157 |
this.lastRenderingParameters.put(name, f.get(this)); |
|
158 |
} |
|
159 |
} |
|
160 |
|
|
161 |
|
|
162 |
public final boolean isChartDirtyFromHistory() throws Exception { |
|
163 |
Class clazz = this.getClass(); |
|
164 |
|
|
165 |
Field[] fields = clazz.getDeclaredFields(); |
|
166 |
for (Field f : fields) { |
|
167 |
String name = f.getName(); |
|
168 |
Parameter annotation = f.getAnnotation(Parameter.class); |
|
169 |
if (annotation == null || annotation.type() != Parameter.RENDERING) { |
|
170 |
continue; |
|
171 |
} |
|
172 |
f.setAccessible(true); // not to set accessible to test the field values |
|
173 |
Object previousValue = this.lastRenderingParameters.get(name); |
|
174 |
Object newValue = f.get(this); |
|
175 |
this.updateChartDirty(previousValue, newValue); |
|
176 |
if (this.chartDirty) { |
|
177 |
return this.chartDirty; // no need to go further |
|
178 |
} |
|
179 |
} |
|
180 |
return this.chartDirty; |
|
181 |
} |
|
182 |
|
|
183 |
|
|
184 |
/** |
|
185 |
* Updates the chart dirty state by comparing an old parameter with a new one. |
|
186 |
* |
|
187 |
* @param previousValue may be null |
|
188 |
* @param newValue may be null |
|
189 |
*/ |
|
190 |
protected void updateChartDirty(Object previousValue, Object newValue) { |
|
191 |
if (previousValue == null || !previousValue.equals(newValue)) { |
|
192 |
Log.info("Setting chart dirty to true: old = "+ previousValue + " / new = " + newValue); |
|
193 |
this.chartDirty = true; |
|
194 |
} |
|
195 |
} |
|
196 |
|
|
160 | 197 |
@Override |
161 | 198 |
public Object clone() { |
162 | 199 |
ChartResult clone = null; |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Subcorpus.java (revision 566) | ||
---|---|---|
144 | 144 |
*/ |
145 | 145 |
@Override |
146 | 146 |
public int getSize() throws CqiClientException { |
147 |
Log.finest(TXMCoreMessages.bind(TXMCoreMessages.SUBCORPUS_SIZE, new Object[]{this.name, "N/A"})); |
|
148 |
long start = System.currentTimeMillis(); |
|
149 | 147 |
if (this.size == -1) { |
148 |
Log.finest(TXMCoreMessages.bind(TXMCoreMessages.SUBCORPUS_SIZE, new Object[]{this.name, "N/A"})); |
|
149 |
long start = System.currentTimeMillis(); |
|
150 |
|
|
150 | 151 |
try { |
151 | 152 |
AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient(); |
152 | 153 |
int nMatch = cqiClient.subCorpusSize(getQualifiedCqpId()); |
153 | 154 |
//System.out.println("n matchs: "+nMatch); |
154 | 155 |
if (nMatch == 0) { |
155 | 156 |
this.size = 0; |
156 |
} else { |
|
157 |
int[] match = cqiClient.dumpSubCorpus(getQualifiedCqpId(), |
|
158 |
NetCqiClient.CQI_CONST_FIELD_MATCH, 0, nMatch - 1); |
|
159 |
int[] matchend = cqiClient.dumpSubCorpus(getQualifiedCqpId(), |
|
160 |
NetCqiClient.CQI_CONST_FIELD_MATCHEND, 0, nMatch - 1); |
|
161 |
if (match.length != matchend.length) |
|
157 |
} |
|
158 |
else { |
|
159 |
int[] match = cqiClient.dumpSubCorpus(getQualifiedCqpId(), NetCqiClient.CQI_CONST_FIELD_MATCH, 0, nMatch - 1); |
|
160 |
int[] matchend = cqiClient.dumpSubCorpus(getQualifiedCqpId(), NetCqiClient.CQI_CONST_FIELD_MATCHEND, 0, nMatch - 1); |
|
161 |
if (match.length != matchend.length) { |
|
162 | 162 |
throw new UnexpectedAnswerException(); |
163 |
} |
|
163 | 164 |
this.size = 0; |
164 | 165 |
|
165 |
for (int i = 0; i < match.length; i++) |
|
166 |
for (int i = 0; i < match.length; i++) {
|
|
166 | 167 |
size += matchend[i] - match[i] + 1; |
168 |
} |
|
167 | 169 |
} |
168 | 170 |
} catch (Exception e) { |
169 | 171 |
throw new CqiClientException(e); |
170 | 172 |
} |
173 |
long end = System.currentTimeMillis(); |
|
174 |
Log.finest(NLS.bind(TXMCoreMessages.END_SUBCORPUS_SIZE, new Object[]{this.name, this.size, (end - start)})); //$NON-NLS-1$ |
|
171 | 175 |
} |
172 |
long end = System.currentTimeMillis(); |
|
173 |
Log.finest(NLS.bind(TXMCoreMessages.END_SUBCORPUS_SIZE, new Object[]{this.name, this.size, (end - start)})); //$NON-NLS-1$ |
|
174 | 176 |
return this.size; |
175 | 177 |
} |
176 | 178 |
|
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/handlers/ComputeCA.java (revision 566) | ||
---|---|---|
149 | 149 |
return null; |
150 | 150 |
} |
151 | 151 |
|
152 |
ChartEditorPart.compute(ca); |
|
152 |
// FIXME: old code |
|
153 |
//ChartEditorPart.compute(ca); |
|
154 |
// FIXME: new code |
|
155 |
ca.compute(false); |
|
153 | 156 |
|
154 | 157 |
try { |
155 | 158 |
|
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java (revision 566) | ||
---|---|---|
110 | 110 |
|
111 | 111 |
|
112 | 112 |
@Parameter |
113 |
protected int pMaxScore;
|
|
113 |
protected int maxScore;
|
|
114 | 114 |
|
115 |
|
|
116 |
|
|
117 |
|
|
115 | 118 |
/** |
116 | 119 |
* Specificities. |
117 | 120 |
* |
... | ... | |
123 | 126 |
public Specificities(LexicalTable lexicalTable, int maxScore) throws CqiClientException, StatException { |
124 | 127 |
super(lexicalTable); |
125 | 128 |
this.lexicalTable = lexicalTable; |
126 |
this.pMaxScore = maxScore;
|
|
129 |
this.maxScore = maxScore;
|
|
127 | 130 |
} |
128 | 131 |
|
129 | 132 |
@Override |
... | ... | |
147 | 150 |
// System.out.println("cols="+table.getColNames()); |
148 | 151 |
// System.out.println("prop="+table.getProperty()); |
149 | 152 |
init(symbol, specIndex, lexicalTable, Arrays |
150 |
.asList(lexicalTable.getRowNames().asStringsArray()), Arrays.asList(lexicalTable.getColNames().asStringsArray()), lexicalTable.getProperty().getName(), this.pMaxScore);
|
|
153 |
.asList(lexicalTable.getRowNames().asStringsArray()), Arrays.asList(lexicalTable.getColNames().asStringsArray()), lexicalTable.getProperty().getName(), this.maxScore);
|
|
151 | 154 |
} |
152 | 155 |
else { |
153 | 156 |
init(si.getSymbol(), specIndex, lexicalTable, Arrays |
154 | 157 |
.asList(lexicalTable.getRowNames().asStringsArray()), Arrays.asList(lexicalTable.getColNames().asStringsArray()), |
155 |
"TLNONAME: " + lexicalTable.getProperty().getName(), this.pMaxScore); //$NON-NLS-1$
|
|
158 |
"TLNONAME: " + lexicalTable.getProperty().getName(), this.maxScore); //$NON-NLS-1$
|
|
156 | 159 |
} |
157 | 160 |
return true; |
158 | 161 |
} |
... | ... | |
597 | 600 |
* @param maxScore the pMaxScore to set |
598 | 601 |
*/ |
599 | 602 |
public void setMaxScore(int maxScore) { |
600 |
this.pMaxScore = maxScore;
|
|
603 |
this.maxScore = maxScore;
|
|
601 | 604 |
} |
602 | 605 |
|
603 | 606 |
@Override |
... | ... | |
614 | 617 |
return true; |
615 | 618 |
} |
616 | 619 |
|
620 |
/** |
|
621 |
* @return the maxScore |
|
622 |
*/ |
|
623 |
public int getMaxScore() { |
|
624 |
return maxScore; |
Formats disponibles : Unified diff