Révision 634
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesSelectionEditor.java (revision 634) | ||
---|---|---|
1 | 1 |
package org.txm.specificities.rcp.editors; |
2 | 2 |
|
3 | 3 |
import org.eclipse.swt.SWT; |
4 |
import org.eclipse.swt.events.SelectionEvent; |
|
5 |
import org.eclipse.swt.events.SelectionListener; |
|
6 | 4 |
import org.eclipse.swt.widgets.Composite; |
7 | 5 |
import org.eclipse.swt.widgets.Label; |
8 |
import org.eclipse.swt.widgets.Spinner; |
|
9 | 6 |
import org.eclipse.swt.widgets.ToolItem; |
10 | 7 |
import org.txm.chartsengine.rcp.editors.ChartEditor; |
8 |
import org.txm.core.results.Parameter; |
|
11 | 9 |
import org.txm.rcp.IImageKeys; |
10 |
import org.txm.rcp.editors.listeners.ComputeSelectionListener; |
|
11 |
import org.txm.rcp.swt.widget.FloatSpinner; |
|
12 | 12 |
import org.txm.specificities.core.functions.SpecificitiesSelection; |
13 |
import org.txm.specificities.core.preferences.SpecificitiesPreferences; |
|
13 | 14 |
import org.txm.specificities.rcp.handlers.ComputeSpecifities; |
14 | 15 |
import org.txm.specificities.rcp.messages.SpecificitiesUIMessages; |
15 | 16 |
|
... | ... | |
22 | 23 |
*/ |
23 | 24 |
public class SpecificitiesSelectionEditor extends ChartEditor<SpecificitiesSelection> { |
24 | 25 |
|
26 |
/** |
|
27 |
* Group by lines / transpose matrix. |
|
28 |
*/ |
|
29 |
@Parameter(key=SpecificitiesPreferences.CHART_GROUP_BY_LINES, type=Parameter.RENDERING) |
|
30 |
protected ToolItem groupBarsByLines; |
|
31 |
|
|
32 |
/** |
|
33 |
* Banality threshold. |
|
34 |
*/ |
|
35 |
@Parameter(key=SpecificitiesPreferences.CHART_BANALITY, type=Parameter.RENDERING) |
|
36 |
protected FloatSpinner banality; |
|
25 | 37 |
|
38 |
|
|
26 | 39 |
@Override |
27 | 40 |
public void _createPartControl(Composite parent) { |
28 | 41 |
|
29 | 42 |
// Group bars by lines |
30 |
final ToolItem groupBarsByLines = new ToolItem(this.getToolBar(), SWT.CHECK);
|
|
43 |
groupBarsByLines = new ToolItem(this.getToolBar(), SWT.CHECK); |
|
31 | 44 |
groupBarsByLines.setToolTipText(SpecificitiesUIMessages.SpecificitiesPreferencePage_4); |
32 | 45 |
groupBarsByLines.setImage(IImageKeys.getImage(ComputeSpecifities.class, "icons/silk_group_bars_by_lines.png")); |
33 |
groupBarsByLines.setSelection(this.getResult().isGroupingByLines()); |
|
34 |
groupBarsByLines.addSelectionListener(new SelectionListener() { |
|
35 |
|
|
36 |
@Override |
|
37 |
public void widgetSelected(SelectionEvent e) { |
|
38 |
getResult().setGroupByLines(groupBarsByLines.getSelection()); |
|
39 |
compute(true); |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
44 |
// does nothing |
|
45 |
} |
|
46 |
}); |
|
46 |
groupBarsByLines.addSelectionListener(new ComputeSelectionListener(this)); |
|
47 | 47 |
|
48 | 48 |
|
49 | 49 |
|
... | ... | |
51 | 51 |
Label label = new Label(this.getCommandParametersGroup(), SWT.NONE); |
52 | 52 |
label.setText("Banality:"); |
53 | 53 |
|
54 |
final Spinner banality = new Spinner(this.getCommandParametersGroup(), SWT.BORDER); |
|
55 |
int nbDigits = 1; |
|
54 |
banality = new FloatSpinner(this.getCommandParametersGroup(), SWT.BORDER); |
|
56 | 55 |
banality.setToolTipText("Banality threshold"); |
57 |
banality.setDigits(nbDigits);
|
|
56 |
banality.setDigits(1);
|
|
58 | 57 |
banality.setIncrement(1); |
59 | 58 |
banality.setMinimum(0); |
60 | 59 |
banality.setMaximum(200); |
61 |
banality.setSelection(((int) (this.getResult().getBanality() * Math.pow(10, nbDigits)))); |
|
62 |
banality.addSelectionListener(new SelectionListener() { |
|
63 |
|
|
64 |
@Override |
|
65 |
public void widgetSelected(SelectionEvent e) { |
|
66 |
getResult().setBanality(getSpinnerFloatSelection(banality)); |
|
67 |
compute(true); |
|
68 |
} |
|
69 |
|
|
70 |
@Override |
|
71 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
72 |
// does nothing |
|
73 |
} |
|
74 |
}); |
|
60 |
banality.addSelectionListener(new ComputeSelectionListener(this)); |
|
75 | 61 |
|
76 |
|
|
77 | 62 |
} |
78 | 63 |
|
79 | 64 |
} |
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesEditor.java (revision 634) | ||
---|---|---|
70 | 70 |
private Table specificitesTable; |
71 | 71 |
private TableViewer viewer; |
72 | 72 |
|
73 |
/** Column for table typeNameTable. */ |
|
74 |
private TableColumn typeNameColumn; |
|
75 |
|
|
76 |
/** Column for table typeFrequencyColumn. */ |
|
77 |
private TableColumn typeFrequencyColumn; |
|
78 |
|
|
79 |
|
|
80 | 73 |
/** |
81 | 74 |
* Viewer comparator for sorting. |
82 | 75 |
*/ |
... | ... | |
91 | 84 |
|
92 | 85 |
|
93 | 86 |
|
94 |
|
|
95 | 87 |
@Override |
96 | 88 |
public void _createPartControl(Composite parent) { |
97 | 89 |
|
... | ... | |
140 | 132 |
specificitesTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2)); |
141 | 133 |
|
142 | 134 |
// create 1st column |
143 |
typeNameColumn = new TableColumn(specificitesTable, SWT.NONE); |
|
135 |
TableColumn typeNameColumn = new TableColumn(specificitesTable, SWT.NONE);
|
|
144 | 136 |
typeNameColumn.setText(RCPMessages.ReferencerEditor_9); |
145 | 137 |
typeNameColumn.setToolTipText(RCPMessages.ReferencerEditor_9); |
146 | 138 |
typeNameColumn.setAlignment(SWT.RIGHT); |
... | ... | |
150 | 142 |
|
151 | 143 |
|
152 | 144 |
// create 2nd column |
153 |
typeFrequencyColumn = new TableColumn(viewer.getTable(), SWT.NONE); |
|
145 |
TableColumn typeFrequencyColumn = new TableColumn(viewer.getTable(), SWT.NONE);
|
|
154 | 146 |
typeFrequencyColumn.setText(RCPMessages.FrequencyListEditorInput_4 + " " + SpecificitiesUIMessages.SpecificitiesTableEditor_11 + " " + this.getResult().getCorpusSize()); //$NON-NLS-1$ //$NON-NLS-2$ |
155 | 147 |
typeFrequencyColumn.setToolTipText(RCPMessages.FrequencyListEditorInput_4 + SpecificitiesUIMessages.SpecificitiesTableEditor_11 + this.getResult().getCorpusSize()); |
156 | 148 |
typeFrequencyColumn.setAlignment(SWT.RIGHT); |
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/preferences/SpecificitiesPreferencePage.java (revision 634) | ||
---|---|---|
78 | 78 |
gridData.horizontalSpan = 2; |
79 | 79 |
booleansGroup.setLayoutData(gridData); |
80 | 80 |
|
81 |
this.addField(new BooleanFieldEditor(SpecificitiesPreferences.CHART_TRANSPOSE, SpecificitiesUIMessages.SpecificitiesPreferencePage_4, booleansGroup));
|
|
81 |
this.addField(new BooleanFieldEditor(SpecificitiesPreferences.CHART_GROUP_BY_LINES, SpecificitiesUIMessages.SpecificitiesPreferencePage_4, booleansGroup));
|
|
82 | 82 |
this.addField(new BooleanFieldEditor(SpecificitiesPreferences.CHART_DRAW_LINES, SpecificitiesUIMessages.SpecificitiesPreferencePage_5, booleansGroup)); |
83 | 83 |
this.addField(new BooleanFieldEditor(SpecificitiesPreferences.CHART_DRAW_BARS, SpecificitiesUIMessages.SpecificitiesPreferencePage_6, booleansGroup)); |
84 | 84 |
|
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/SpecificitiesSelection.java (revision 634) | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import java.io.File; |
7 | 7 |
|
8 |
import org.apache.commons.lang.StringUtils; |
|
8 | 9 |
import org.txm.chartsengine.core.results.ChartResult; |
9 | 10 |
import org.txm.core.results.Parameter; |
10 | 11 |
import org.txm.core.results.TXMParameters; |
... | ... | |
35 | 36 |
|
36 | 37 |
|
37 | 38 |
|
38 |
@Parameter(key=SpecificitiesPreferences.CHART_TRANSPOSE, type=Parameter.RENDERING) |
|
39 |
|
|
40 |
/** |
|
41 |
* Group by lines / transpose matrix. |
|
42 |
*/ |
|
43 |
@Parameter(key=SpecificitiesPreferences.CHART_GROUP_BY_LINES, type=Parameter.RENDERING) |
|
39 | 44 |
protected boolean groupByLines; |
40 | 45 |
|
46 |
/** |
|
47 |
* Banality threshold. |
|
48 |
*/ |
|
41 | 49 |
@Parameter(key=SpecificitiesPreferences.CHART_BANALITY, type=Parameter.RENDERING) |
42 | 50 |
protected float banality; |
43 | 51 |
|
52 |
/** |
|
53 |
* To draw bars or not. |
|
54 |
*/ |
|
44 | 55 |
@Parameter(key=SpecificitiesPreferences.CHART_DRAW_BARS, type=Parameter.RENDERING) |
45 | 56 |
protected boolean drawBars; |
46 | 57 |
|
58 |
/** |
|
59 |
* To draw lines or not. |
|
60 |
*/ |
|
47 | 61 |
@Parameter(key=SpecificitiesPreferences.CHART_DRAW_LINES, type=Parameter.RENDERING) |
48 | 62 |
protected boolean drawLines; |
49 | 63 |
|
64 |
|
|
65 |
|
|
66 |
|
|
50 | 67 |
/** |
51 | 68 |
* Creates an empty SpecificitiesSelection. |
52 | 69 |
* @param parent |
... | ... | |
115 | 132 |
|
116 | 133 |
@Override |
117 | 134 |
public String getName() { |
118 |
String name = "";
|
|
119 |
for (int i = 0; i < selectedTypeNames.length; i++) {
|
|
120 |
name += selectedTypeNames[i] + " ";
|
|
135 |
String name = "[" + StringUtils.join(this.selectedTypeNames, ", ") + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
136 |
if (name.length() > 80) {
|
|
137 |
name = name.substring(0, 79) + "...";
|
|
121 | 138 |
} |
122 |
if (name.length() > 50) name = name.substring(0, 49) + "..."; |
|
123 | 139 |
return name; |
124 | 140 |
} |
125 | 141 |
|
tmp/org.txm.specificities.core/src/org/txm/specificities/core/chartsengine/jfreechart/JFCSpecificitiesBarChartCreator.java (revision 634) | ||
---|---|---|
56 | 56 |
((IRendererWithItemSelection) chart.getXYPlot().getRenderer()).setChartType(ChartsEngine.CHART_TYPE_SPECIFICITIES); |
57 | 57 |
|
58 | 58 |
|
59 |
|
|
60 |
|
|
61 | 59 |
return chart; |
62 | 60 |
|
63 | 61 |
} |
... | ... | |
96 | 94 |
chart.getXYPlot().addRangeMarker(marker); |
97 | 95 |
|
98 | 96 |
|
99 |
// Transpose or not / group by lines or not
|
|
100 |
if(result.hasParameterChanged(SpecificitiesPreferences.CHART_TRANSPOSE)) {
|
|
97 |
// Transpose or not (group by lines or not)
|
|
98 |
if(result.hasParameterChanged(SpecificitiesPreferences.CHART_GROUP_BY_LINES)) {
|
|
101 | 99 |
|
102 | 100 |
// Fill the data set |
103 | 101 |
XYSeriesCollection dataset = (XYSeriesCollection) chart.getXYPlot().getDataset(); |
tmp/org.txm.specificities.core/src/org/txm/specificities/core/preferences/SpecificitiesPreferences.java (revision 634) | ||
---|---|---|
24 | 24 |
public static final String FORMAT = PREFERENCES_PREFIX + "format"; //$NON-NLS-1$ |
25 | 25 |
|
26 | 26 |
// charts |
27 |
public static final String CHART_TRANSPOSE = PREFERENCES_PREFIX + "chart_transpose"; //$NON-NLS-1$
|
|
27 |
public static final String CHART_GROUP_BY_LINES = PREFERENCES_PREFIX + "chart_group_by_lines"; //$NON-NLS-1$
|
|
28 | 28 |
public static final String CHART_DRAW_BARS = PREFERENCES_PREFIX + "chart_draw_bars"; //$NON-NLS-1$ |
29 | 29 |
public static final String CHART_DRAW_LINES = PREFERENCES_PREFIX + "chart_draw_lines"; //$NON-NLS-1$ |
30 | 30 |
public static final String CHART_BANALITY = PREFERENCES_PREFIX + "chart_banality"; //$NON-NLS-1$ |
... | ... | |
40 | 40 |
preferences.put(FORMAT, "%,.1f"); |
41 | 41 |
preferences.putInt(MAX_SCORE, 10000); |
42 | 42 |
|
43 |
preferences.putBoolean(CHART_TRANSPOSE, false);
|
|
43 |
preferences.putBoolean(CHART_GROUP_BY_LINES, false);
|
|
44 | 44 |
preferences.putBoolean(CHART_DRAW_BARS, true); |
45 | 45 |
preferences.putBoolean(CHART_DRAW_LINES, false); |
46 | 46 |
preferences.putFloat(CHART_BANALITY, 2); |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 634) | ||
---|---|---|
44 | 44 |
import org.txm.rcp.JobsTimer; |
45 | 45 |
import org.txm.rcp.StatusLine; |
46 | 46 |
import org.txm.rcp.TXMWindows; |
47 |
import org.txm.rcp.swt.widget.FloatSpinner; |
|
47 | 48 |
import org.txm.rcp.swt.widget.NewNavigationWidget; |
48 | 49 |
import org.txm.rcp.swt.widget.PropertiesSelector; |
49 | 50 |
import org.txm.rcp.utils.JobHandler; |
... | ... | |
63 | 64 |
*/ |
64 | 65 |
public abstract class TXMEditor<T extends TXMResult> extends EditorPart { |
65 | 66 |
|
67 |
|
|
66 | 68 |
/** |
69 |
* ID to use in plugin.xml to contribute to the top toolbar. |
|
70 |
*/ |
|
71 |
public final static String TOP_TOOLBAR_ID = "TXMEditorTopToolBar"; //$NON-NLS-1$ |
|
72 |
|
|
73 |
|
|
74 |
/** |
|
67 | 75 |
* The editor main tool bar, positioned at the top of the editor. |
68 | 76 |
*/ |
69 | 77 |
protected TXMEditorToolBar topToolBar; |
... | ... | |
104 | 112 |
protected HashMap<String, Object> lastComputingParameters = new HashMap<String, Object>(); |
105 | 113 |
|
106 | 114 |
|
115 |
|
|
116 |
|
|
107 | 117 |
@Override |
108 | 118 |
public void init(IEditorSite site, IEditorInput input) throws PartInitException { |
109 | 119 |
this.setSite(site); |
... | ... | |
134 | 144 |
rl.marginTop = rl.marginHeight = rl.marginWidth = rl.marginBottom = 0; |
135 | 145 |
this.topToolBarContainer.setLayout(rl); |
136 | 146 |
|
137 |
this.topToolBar = new TXMEditorToolBar(this, SWT.FLAT | SWT.RIGHT, "TXMEditorTopToolBar");
|
|
147 |
this.topToolBar = new TXMEditorToolBar(this, SWT.FLAT | SWT.RIGHT, TOP_TOOLBAR_ID);
|
|
138 | 148 |
|
139 | 149 |
|
140 | 150 |
this.parametersGroupsComposite = new Composite(parent, SWT.NONE); |
... | ... | |
620 | 630 |
|
621 | 631 |
/** |
622 | 632 |
* Updates the editor fields from result and declared parameters annotations. |
623 |
* Manages these widgets at this moment: ToolItem, Spinner, Text, Button, ComboViewer.
|
|
633 |
* Manages these widgets at this moment: ToolItem, FloatSpinner, Spinner, Text, Button, Viewer, PropertiesSelector, NewNavigationWidget.
|
|
624 | 634 |
*/ |
625 | 635 |
public void autoUpdateEditorFieldsFromResult() { |
626 | 636 |
|
... | ... | |
639 | 649 |
if(object instanceof ToolItem) { |
640 | 650 |
((ToolItem)object).setSelection((Boolean) value); |
641 | 651 |
} |
652 |
else if(object instanceof FloatSpinner) { |
|
653 |
((FloatSpinner)object).setSelection((Float) value); |
|
654 |
} |
|
642 | 655 |
else if(object instanceof Spinner) { |
643 | 656 |
((Spinner)object).setSelection((Integer) value); |
644 | 657 |
} |
... | ... | |
681 | 694 |
|
682 | 695 |
/** |
683 | 696 |
* Updates the result parameters from the editor declared parameters annotations. |
684 |
* Manages these widgets at this moment: ToolItem, Spinner, Text, Button, ComboViewer.
|
|
697 |
* Manages these widgets at this moment: ToolItem, FloatSpinner, Spinner, Text, Button, Viewer, PropertiesSelector, NewNavigationWidget.
|
|
685 | 698 |
*/ |
686 | 699 |
public void autoUpdateResultFromEditorParameters() { |
687 | 700 |
|
... | ... | |
700 | 713 |
if(object instanceof ToolItem) { |
701 | 714 |
value = ((ToolItem)object).getSelection(); |
702 | 715 |
} |
716 |
else if(object instanceof FloatSpinner) { |
|
717 |
value = ((FloatSpinner)object).getSelectionAsFloat(); |
|
718 |
} |
|
703 | 719 |
else if(object instanceof Spinner) { |
704 | 720 |
value = ((Spinner)object).getSelection(); |
705 | 721 |
} |
... | ... | |
865 | 881 |
viewer.getControl().setRedraw(true); |
866 | 882 |
} |
867 | 883 |
|
868 |
/** |
|
869 |
* Returns the spinner value as float. |
|
870 |
* @param spinner |
|
871 |
* @return |
|
872 |
*/ |
|
873 |
public static float getSpinnerFloatSelection(Spinner spinner) { |
|
874 |
return (float) (spinner.getSelection() / Math.pow(10, spinner.getDigits())); |
|
875 |
} |
|
876 | 884 |
|
877 | 885 |
|
878 |
|
|
879 |
|
|
880 | 886 |
public Composite getToolBarContainer(String toolbarLocalId) { |
881 |
if ("top".equals(toolbarLocalId)) {
|
|
887 |
if (TOP_TOOLBAR_ID.equals(toolbarLocalId)) {
|
|
882 | 888 |
return this.getTopToolBarContainer(); |
883 | 889 |
} else if ("bottom".equals(toolbarLocalId)) { |
884 | 890 |
return this.getBottomToolBarContainer(); |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/FloatSpinner.java (revision 634) | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package org.txm.rcp.swt.widget; |
|
5 |
|
|
6 |
import org.eclipse.swt.widgets.Composite; |
|
7 |
import org.eclipse.swt.widgets.Spinner; |
|
8 |
|
|
9 |
/** |
|
10 |
* A spinner that supports float numbers. |
|
11 |
* |
|
12 |
* @author sjacquot |
|
13 |
* |
|
14 |
*/ |
|
15 |
public class FloatSpinner extends Spinner { |
|
16 |
|
|
17 |
/** |
|
18 |
* Creates a FloatSpinner. |
|
19 |
* @param parent |
|
20 |
* @param style |
|
21 |
*/ |
|
22 |
public FloatSpinner(Composite parent, int style) { |
|
23 |
super(parent, style); |
|
24 |
} |
|
25 |
|
|
26 |
/** |
|
27 |
* Sets the selection as float. |
|
28 |
* @param value |
|
29 |
*/ |
|
30 |
public void setSelection(float value) { |
|
31 |
super.setSelection((int) (value * Math.pow(10, this.getDigits()))); |
|
32 |
} |
|
33 |
|
|
34 |
/** |
|
35 |
* Gets the selection as a float number. |
|
36 |
* @return |
|
37 |
*/ |
|
38 |
public float getSelectionAsFloat() { |
|
39 |
return (float) (super.getSelection() / Math.pow(10, this.getDigits())); |
|
40 |
} |
|
41 |
|
|
42 |
|
|
43 |
@Override |
|
44 |
protected void checkSubclass() { |
|
45 |
|
|
46 |
} |
|
47 |
} |
|
0 | 48 |
Formats disponibles : Unified diff