Révision 402
tmp/org.txm.wordcloud.rcp/src/org/txm/wordcloud/rcp/handlers/ComputeWordCloud.java (revision 402) | ||
---|---|---|
27 | 27 |
// |
28 | 28 |
package org.txm.wordcloud.rcp.handlers; |
29 | 29 |
|
30 |
import java.io.IOException; |
|
31 |
|
|
32 | 30 |
import org.eclipse.core.commands.ExecutionEvent; |
33 | 31 |
import org.eclipse.core.commands.ExecutionException; |
34 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
35 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
36 | 32 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
33 |
import org.txm.chartsengine.rcp.editors.ChartEditorInput; |
|
34 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart; |
|
35 |
import org.txm.core.results.TXMResult; |
|
37 | 36 |
import org.txm.index.core.functions.Index; |
38 | 37 |
import org.txm.lexicon.core.corpusengine.cqp.Lexicon; |
39 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
|
40 | 38 |
import org.txm.rcp.StatusLine; |
41 | 39 |
import org.txm.rcp.commands.OpenBrowser; |
40 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
|
42 | 41 |
import org.txm.rcp.views.corpora.CorporaView; |
43 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
44 | 42 |
import org.txm.searchengine.cqp.corpus.Corpus; |
45 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
|
46 |
import org.txm.utils.logger.Log; |
|
47 | 43 |
import org.txm.wordcloud.core.functions.WordCloud; |
48 | 44 |
import org.txm.wordcloud.core.messages.WordCloudCoreMessages; |
49 |
import org.txm.wordcloud.core.preferences.WordCloudPreferences; |
|
50 | 45 |
|
51 | 46 |
/** |
52 | 47 |
* Open the WordCloud Editor. |
... | ... | |
77 | 72 |
} |
78 | 73 |
|
79 | 74 |
|
80 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
|
|
81 |
Object s = selection.getFirstElement();
|
|
75 |
Object selection = this.getSelection();
|
|
76 |
ChartEditorInput editorInput = null;
|
|
82 | 77 |
|
83 |
// boolean newResult = true; |
|
84 |
// Corpus corpus = null; |
|
85 |
WordCloud wordCloud = null; |
|
86 | 78 |
|
87 |
// opens existing result |
|
88 |
if (s instanceof WordCloud) { |
|
89 |
wordCloud = (WordCloud) s; |
|
90 |
// corpus = wordCloud.getCorpus(); |
|
91 |
// newResult = false; |
|
79 |
// reopening an existing result |
|
80 |
if (selection instanceof WordCloud) { |
|
81 |
editorInput = new ChartEditorInput((TXMResult) selection); |
|
92 | 82 |
} |
93 | 83 |
else { |
94 |
// Inits R packages |
|
95 |
if(!WordCloud.initPackages()) { |
|
96 |
OpenBrowser.openfile("https://groupes.renater.fr/wiki/txm-users/public/extensions#wordcloud"); //$NON-NLS-1$ |
|
97 |
//return Status.CANCEL_STATUS; |
|
98 |
} |
|
84 |
// Inits R packages |
|
85 |
if(!WordCloud.initPackages()) { |
|
86 |
OpenBrowser.openfile("https://groupes.renater.fr/wiki/txm-users/public/extensions#wordcloud"); //$NON-NLS-1$ |
|
87 |
} |
|
99 | 88 |
|
100 |
// creates new result |
|
101 |
if (s instanceof Corpus) { |
|
102 |
try { |
|
103 |
// corpus = (Corpus)s; |
|
104 |
wordCloud = new WordCloud((Corpus)s); |
|
105 |
} |
|
106 |
catch (CqiClientException e) { |
|
107 |
Log.printStackTrace(e); |
|
108 |
//return null; |
|
109 |
} |
|
110 |
catch(IOException e) { |
|
111 |
// TODO Auto-generated catch block |
|
112 |
e.printStackTrace(); |
|
113 |
} |
|
114 |
catch(CqiServerError e) { |
|
115 |
// TODO Auto-generated catch block |
|
116 |
e.printStackTrace(); |
|
117 |
} |
|
118 |
} |
|
119 |
// creates new result |
|
120 |
else if (s instanceof Index) { |
|
121 |
wordCloud = new WordCloud((Index)s); |
|
122 |
// corpus = ((Index)s).getCorpus(); |
|
123 |
} |
|
124 |
// creates new result |
|
125 |
else if (s instanceof Lexicon) { |
|
126 |
wordCloud = new WordCloud((Lexicon)s); |
|
127 |
// corpus = ((Lexicon)s).getCorpus(); |
|
128 |
} |
|
89 |
// creates new result from Corpus |
|
90 |
if (selection instanceof Corpus) { |
|
91 |
editorInput = new ChartEditorInput(new WordCloud((Corpus)selection)); |
|
129 | 92 |
} |
93 |
// creates new result from Index |
|
94 |
else if (selection instanceof Index) { |
|
95 |
editorInput = new ChartEditorInput(new WordCloud((Index)selection)); |
|
96 |
} |
|
97 |
// FIXME: creates new result from Lexicon, not used? |
|
98 |
else if (selection instanceof Lexicon) { |
|
99 |
editorInput = new ChartEditorInput(new WordCloud((Lexicon)selection)); |
|
100 |
} |
|
101 |
} |
|
130 | 102 |
|
131 |
if(wordCloud != null) { |
|
132 |
StatusLine.setMessage(WordCloudCoreMessages.StatusBar_Opening_result); |
|
103 |
StatusLine.setMessage(WordCloudCoreMessages.StatusBar_Opening_result); |
|
133 | 104 |
|
134 |
//FIXME: |
|
135 |
// WordCloudEditorInput editorInput = new WordCloudEditorInput(wordCloud); |
|
136 |
// SWTChartsComponentsProvider.getCurrent().openEditor(editorInput); |
|
137 |
SWTChartsComponentsProvider.getCurrent().openEditor(wordCloud, WordCloudPreferences.PREFERENCES_NODE); |
|
138 |
|
|
139 |
|
|
140 |
// if(newResult && corpus != null) { |
|
141 |
// CorporaView.storeResult(corpus, wordCloud); |
|
142 |
// } |
|
143 |
} |
|
105 |
ChartEditorPart editor = SWTChartsComponentsProvider.getCurrent().openEditor(editorInput); |
|
106 |
// new result |
|
107 |
if(!(selection instanceof WordCloud)) { |
|
108 |
editor.computeResult(false); |
|
109 |
} |
|
144 | 110 |
|
145 | 111 |
return null; |
146 | 112 |
} |
tmp/org.txm.wordcloud.rcp/src/org/txm/wordcloud/rcp/editors/WordCloudEditorInput.java (revision 402) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.wordcloud.rcp.editors; |
|
29 |
|
|
30 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
31 |
import org.eclipse.ui.IPersistableElement; |
|
32 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
|
33 |
import org.txm.chartsengine.rcp.editors.ChartEditorInput; |
|
34 |
import org.txm.rcp.Application; |
|
35 |
import org.txm.rcp.IImageKeys; |
|
36 |
import org.txm.wordcloud.core.functions.WordCloud; |
|
37 |
import org.txm.wordcloud.core.preferences.WordCloudPreferences; |
|
38 |
|
|
39 |
|
|
40 |
/** |
|
41 |
* |
|
42 |
* |
|
43 |
* @author sloiseau |
|
44 |
*/ |
|
45 |
@Deprecated |
|
46 |
//FIXME: useless |
|
47 |
public class WordCloudEditorInput extends ChartEditorInput { |
|
48 |
|
|
49 |
|
|
50 |
/** |
|
51 |
* |
|
52 |
* @param src |
|
53 |
* @param wc |
|
54 |
*/ |
|
55 |
public WordCloudEditorInput(WordCloud wc) { |
|
56 |
super(wc, WordCloudPreferences.PREFERENCES_NODE); |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* Exists. |
|
61 |
* |
|
62 |
* @return true, if successful |
|
63 |
* @see org.eclipse.ui.IEditorInput#exists() |
|
64 |
*/ |
|
65 |
@Override |
|
66 |
public boolean exists() { |
|
67 |
return false; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Gets the image descriptor. |
|
72 |
* |
|
73 |
* @return the image descriptor |
|
74 |
* @see org.eclipse.ui.IEditorInput#getImageDescriptor() |
|
75 |
*/ |
|
76 |
@Override |
|
77 |
public ImageDescriptor getImageDescriptor() { |
|
78 |
return AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, IImageKeys.ACTION_WORDCLOUD); |
|
79 |
} |
|
80 |
|
|
81 |
|
|
82 |
/** |
|
83 |
* Gets the persistable. |
|
84 |
* |
|
85 |
* @return the persistable |
|
86 |
* @see org.eclipse.ui.IEditorInput#getPersistable() |
|
87 |
*/ |
|
88 |
@Override |
|
89 |
public IPersistableElement getPersistable() { |
|
90 |
return null; |
|
91 |
} |
|
92 |
|
|
93 |
|
|
94 |
/** |
|
95 |
* Gets the adapter. |
|
96 |
* |
|
97 |
* @param arg0 the arg0 |
|
98 |
* @return the adapter |
|
99 |
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) |
|
100 |
*/ |
|
101 |
@Override |
|
102 |
@SuppressWarnings("unchecked") //$NON-NLS-1$ |
|
103 |
public Object getAdapter(Class arg0) { |
|
104 |
return null; |
|
105 |
} |
|
106 |
|
|
107 |
|
|
108 |
} |
|
109 |
|
tmp/org.txm.wordcloud.rcp/src/org/txm/wordcloud/rcp/editors/___WordCloudEditorInput.java (revision 402) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.wordcloud.rcp.editors; |
|
29 |
|
|
30 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
31 |
import org.eclipse.ui.IPersistableElement; |
|
32 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
|
33 |
import org.txm.chartsengine.rcp.editors.ChartEditorInput; |
|
34 |
import org.txm.rcp.Application; |
|
35 |
import org.txm.rcp.IImageKeys; |
|
36 |
import org.txm.wordcloud.core.functions.WordCloud; |
|
37 |
|
|
38 |
|
|
39 |
/** |
|
40 |
* |
|
41 |
* |
|
42 |
* @author sloiseau |
|
43 |
*/ |
|
44 |
@Deprecated |
|
45 |
//FIXME: useless |
|
46 |
public class ___WordCloudEditorInput extends ChartEditorInput { |
|
47 |
|
|
48 |
|
|
49 |
/** |
|
50 |
* |
|
51 |
* @param src |
|
52 |
* @param wc |
|
53 |
*/ |
|
54 |
public ___WordCloudEditorInput(WordCloud wc) { |
|
55 |
super(wc); |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* Exists. |
|
60 |
* |
|
61 |
* @return true, if successful |
|
62 |
* @see org.eclipse.ui.IEditorInput#exists() |
|
63 |
*/ |
|
64 |
@Override |
|
65 |
public boolean exists() { |
|
66 |
return false; |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* Gets the image descriptor. |
|
71 |
* |
|
72 |
* @return the image descriptor |
|
73 |
* @see org.eclipse.ui.IEditorInput#getImageDescriptor() |
|
74 |
*/ |
|
75 |
@Override |
|
76 |
public ImageDescriptor getImageDescriptor() { |
|
77 |
return AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, IImageKeys.ACTION_WORDCLOUD); |
|
78 |
} |
|
79 |
|
|
80 |
|
|
81 |
/** |
|
82 |
* Gets the persistable. |
|
83 |
* |
|
84 |
* @return the persistable |
|
85 |
* @see org.eclipse.ui.IEditorInput#getPersistable() |
|
86 |
*/ |
|
87 |
@Override |
|
88 |
public IPersistableElement getPersistable() { |
|
89 |
return null; |
|
90 |
} |
|
91 |
|
|
92 |
|
|
93 |
/** |
|
94 |
* Gets the adapter. |
|
95 |
* |
|
96 |
* @param arg0 the arg0 |
|
97 |
* @return the adapter |
|
98 |
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) |
|
99 |
*/ |
|
100 |
@Override |
|
101 |
@SuppressWarnings("unchecked") //$NON-NLS-1$ |
|
102 |
public Object getAdapter(Class arg0) { |
|
103 |
return null; |
|
104 |
} |
|
105 |
|
|
106 |
|
|
107 |
} |
|
108 |
|
|
0 | 109 |
tmp/org.txm.wordcloud.rcp/src/org/txm/wordcloud/rcp/editors/WordCloudEditor.java (revision 402) | ||
---|---|---|
1 | 1 |
package org.txm.wordcloud.rcp.editors; |
2 | 2 |
|
3 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
4 | 3 |
import org.eclipse.swt.SWT; |
5 | 4 |
import org.eclipse.swt.events.SelectionEvent; |
6 | 5 |
import org.eclipse.swt.events.SelectionListener; |
... | ... | |
10 | 9 |
import org.eclipse.swt.widgets.Spinner; |
11 | 10 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart; |
12 | 11 |
import org.txm.core.preferences.TXMPreferences; |
12 |
import org.txm.functions.TXMCommand; |
|
13 | 13 |
import org.txm.utils.logger.Log; |
14 | 14 |
import org.txm.wordcloud.core.preferences.WordCloudPreferences; |
15 | 15 |
import org.txm.wordcloud.rcp.messages.WordCloudUIMessages; |
... | ... | |
53 | 53 |
Composite p = this.getCommandParametersGroup(); |
54 | 54 |
// for tab folder tests |
55 | 55 |
//Composite p = this.getCommandParametersComposite(); |
56 |
|
|
57 |
// max words |
|
58 |
new Label(p, SWT.NONE).setText(WordCloudUIMessages.EditorToolBar_vmax); |
|
59 |
final Spinner maxWordsSpinner = new Spinner(p, SWT.BORDER); |
|
60 |
maxWordsSpinner.setMinimum(10); |
|
61 |
maxWordsSpinner.setIncrement(1); |
|
62 |
maxWordsSpinner.setMaximum(100000); |
|
63 |
maxWordsSpinner.setSelection(TXMPreferences.getInt(WordCloudPreferences.PREFERENCES_NODE, this.getResultData(), WordCloudPreferences.MAX_WORDS)); |
|
64 |
|
|
56 |
|
|
65 | 57 |
// fmin |
66 | 58 |
new Label(p, SWT.NONE).setText(WordCloudUIMessages.EditorToolBar_fmin); |
67 | 59 |
final Spinner minFreqSpinner = new Spinner(p, SWT.BORDER); |
68 | 60 |
minFreqSpinner.setMinimum(1); |
69 | 61 |
minFreqSpinner.setIncrement(1); |
70 | 62 |
minFreqSpinner.setMaximum(100000000); |
71 |
minFreqSpinner.setSelection(TXMPreferences.getInt(WordCloudPreferences.PREFERENCES_NODE, this.getResultData(), WordCloudPreferences.FMIN));
|
|
63 |
minFreqSpinner.setSelection(this.getIntParameterValue(WordCloudPreferences.FMIN));
|
|
72 | 64 |
|
65 |
// max words / vmax |
|
66 |
new Label(p, SWT.NONE).setText(WordCloudUIMessages.EditorToolBar_vmax); |
|
67 |
final Spinner maxWordsSpinner = new Spinner(p, SWT.BORDER); |
|
68 |
maxWordsSpinner.setMinimum(10); |
|
69 |
maxWordsSpinner.setIncrement(1); |
|
70 |
maxWordsSpinner.setMaximum(100000); |
|
71 |
maxWordsSpinner.setSelection(this.getIntParameterValue(WordCloudPreferences.MAX_WORDS)); |
|
72 |
|
|
73 | 73 |
// rotation percent |
74 | 74 |
new Label(p, SWT.NONE).setText(WordCloudUIMessages.EditorToolBar_Percent_of_rotated_labels); |
75 | 75 |
final Spinner rotPerSpinner = new Spinner(p, SWT.BORDER); |
76 | 76 |
rotPerSpinner.setMinimum(0); |
77 | 77 |
rotPerSpinner.setIncrement(1); |
78 | 78 |
rotPerSpinner.setMaximum(100); |
79 |
rotPerSpinner.setSelection(TXMPreferences.getInt(WordCloudPreferences.PREFERENCES_NODE, this.getResultData(), WordCloudPreferences.ROT));
|
|
79 |
rotPerSpinner.setSelection(this.getIntParameterValue(WordCloudPreferences.ROT));
|
|
80 | 80 |
|
81 | 81 |
// random positions |
82 | 82 |
final Button randomOrderButton = new Button(p, SWT.CHECK); |
83 | 83 |
randomOrderButton.setText(WordCloudUIMessages.EditorToolBar_Randomize_positions); |
84 |
randomOrderButton.setSelection(TXMPreferences.getBoolean(WordCloudPreferences.PREFERENCES_NODE, this.getResultData(), WordCloudPreferences.RANDOM_POSITION));
|
|
84 |
randomOrderButton.setSelection(this.getBooleanParameterValue(WordCloudPreferences.RANDOM_POSITION));
|
|
85 | 85 |
|
86 | 86 |
|
87 | 87 |
// compute button |
... | ... | |
109 | 109 |
|
110 | 110 |
p.pack(); |
111 | 111 |
|
112 |
this.computeResult(false); |
|
112 | 113 |
this.computeChart("Compute Wordcloud", false); |
114 |
|
|
113 | 115 |
Log.info(WordCloudUIMessages.Log_WordCloud_ready + this.getResultData()); |
114 | 116 |
|
115 | 117 |
} |
116 | 118 |
|
117 |
/* (non-Javadoc) |
|
118 |
* @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor) |
|
119 |
*/ |
|
119 |
|
|
120 | 120 |
@Override |
121 |
public void doSave(IProgressMonitor monitor) { } |
|
122 |
|
|
123 |
/* (non-Javadoc) |
|
124 |
* @see org.eclipse.ui.part.EditorPart#doSaveAs() |
|
125 |
*/ |
|
126 |
@Override |
|
127 |
public void doSaveAs() { } |
|
128 |
|
|
129 |
/* (non-Javadoc) |
|
130 |
* @see org.eclipse.ui.part.EditorPart#isDirty() |
|
131 |
*/ |
|
132 |
@Override |
|
133 |
public boolean isDirty() { |
|
134 |
// TODO Auto-generated method stub |
|
135 |
return false; |
|
121 |
public void computeResult(boolean update) { |
|
122 |
if(!update) { |
|
123 |
((TXMCommand) this.getResultData()).compute(); |
|
124 |
} |
|
136 | 125 |
} |
137 |
|
|
138 |
/* (non-Javadoc) |
|
139 |
* @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed() |
|
140 |
*/ |
|
141 |
@Override |
|
142 |
public boolean isSaveAsAllowed() { |
|
143 |
// TODO Auto-generated method stub |
|
144 |
return false; |
|
145 |
} |
|
146 |
|
|
147 | 126 |
|
148 | 127 |
|
149 | 128 |
} |
tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/handlers/ComputeBalance.java (revision 402) | ||
---|---|---|
27 | 27 |
// |
28 | 28 |
package org.txm.textsbalance.rcp.handlers; |
29 | 29 |
|
30 |
import org.eclipse.core.commands.AbstractHandler; |
|
31 | 30 |
import org.eclipse.core.commands.ExecutionEvent; |
32 | 31 |
import org.eclipse.core.commands.ExecutionException; |
33 |
import org.eclipse.jface.viewers.ISelection; |
|
34 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
35 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
36 | 32 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
33 |
import org.txm.chartsengine.rcp.editors.ChartEditorInput; |
|
34 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart; |
|
35 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
|
37 | 36 |
import org.txm.rcp.views.corpora.CorporaView; |
38 | 37 |
import org.txm.searchengine.cqp.corpus.Corpus; |
39 | 38 |
import org.txm.textsbalance.core.functions.TextsBalance; |
40 |
import org.txm.textsbalance.rcp.editors.BalanceEditorInput; |
|
41 | 39 |
|
42 | 40 |
/** |
43 | 41 |
* Computes and opens a texts balance editor. |
... | ... | |
46 | 44 |
* @author sjacquot |
47 | 45 |
* |
48 | 46 |
*/ |
49 |
public class ComputeBalance extends AbstractHandler { |
|
47 |
public class ComputeBalance extends BaseAbstractHandler {
|
|
50 | 48 |
|
51 | 49 |
|
52 | 50 |
|
... | ... | |
61 | 59 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
62 | 60 |
|
63 | 61 |
|
64 |
ISelection sel = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
65 |
if(!(sel instanceof IStructuredSelection)) { |
|
66 |
return null; |
|
67 |
} |
|
68 |
IStructuredSelection selection = (IStructuredSelection) sel; |
|
62 |
Object selection = this.getSelection(); |
|
69 | 63 |
|
70 |
Object selectedObject = selection.getFirstElement(); |
|
71 |
|
|
72 |
TextsBalance balance = null; |
|
73 | 64 |
|
65 |
ChartEditorInput editorInput = null; |
|
66 |
|
|
74 | 67 |
// creates new result |
75 |
if(selectedObject instanceof Corpus) {
|
|
76 |
balance = new TextsBalance((Corpus) selectedObject);
|
|
68 |
if(selection instanceof Corpus) {
|
|
69 |
editorInput = new ChartEditorInput(new TextsBalance((Corpus) selection));
|
|
77 | 70 |
} |
78 |
// opens existing result |
|
79 |
else if(selectedObject instanceof TextsBalance) {
|
|
80 |
balance = (TextsBalance) selectedObject;
|
|
71 |
// reopens existing result
|
|
72 |
else if(selection instanceof TextsBalance) {
|
|
73 |
editorInput = new ChartEditorInput((TextsBalance) selection);
|
|
81 | 74 |
} |
82 | 75 |
|
83 |
if(balance != null) { |
|
84 |
BalanceEditorInput editorInput = new BalanceEditorInput(balance); |
|
85 |
SWTChartsComponentsProvider.getCurrent().openEditor(editorInput); |
|
76 |
ChartEditorPart editor = SWTChartsComponentsProvider.getCurrent().openEditor(editorInput); |
|
77 |
|
|
78 |
// new result |
|
79 |
if(!(selection instanceof TextsBalance)) { |
|
80 |
editor.computeResult(false); |
|
86 | 81 |
} |
87 |
else { |
|
88 |
System.err.println("Cannot open Balance editor with " + selectedObject); |
|
89 |
} |
|
90 | 82 |
|
91 | 83 |
|
92 |
|
|
93 | 84 |
// FIXME: test d'utilisation de la même commande pour la création d'un nouvel éditeur et pour la mise à jour d'un graphique, avec une commande paramétrée (voir plugin.xml) |
94 | 85 |
// if(event.getParameter("TextsBalance.createNewEditor") == null) { |
95 | 86 |
// ISelection sel = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/editors/BalanceEditorInput.java (revision 402) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.textsbalance.rcp.editors; |
|
29 |
|
|
30 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
31 |
import org.eclipse.ui.IPersistableElement; |
|
32 |
import org.txm.chartsengine.rcp.editors.ChartEditorInput; |
|
33 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
34 |
import org.txm.textsbalance.core.functions.TextsBalance; |
|
35 |
import org.txm.textsbalance.core.preferences.TextsBalancePreferences; |
|
36 |
/** |
|
37 |
* Editor input for TextBalance. |
|
38 |
* |
|
39 |
* @author mdecorde |
|
40 |
* @author sjacquot |
|
41 |
*/ |
|
42 |
public class BalanceEditorInput extends ChartEditorInput { |
|
43 |
|
|
44 |
/** The corpus. */ |
|
45 |
private Corpus corpus; |
|
46 |
|
|
47 |
/** |
|
48 |
* Instantiates a new index editor input. |
|
49 |
* |
|
50 |
* @param corpus the corpus |
|
51 |
*/ |
|
52 |
public BalanceEditorInput(TextsBalance textBalance) { |
|
53 |
super(textBalance, TextsBalancePreferences.PREFERENCES_NODE); |
|
54 |
this.corpus = textBalance.getCorpus(); |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* Exists. |
|
59 |
* |
|
60 |
* @return true, if successful |
|
61 |
* @see org.eclipse.ui.IEditorInput#exists() |
|
62 |
*/ |
|
63 |
@Override |
|
64 |
public boolean exists() { |
|
65 |
return false; |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* Gets the image descriptor. |
|
70 |
* |
|
71 |
* @return the image descriptor |
|
72 |
* @see org.eclipse.ui.IEditorInput#getImageDescriptor() |
|
73 |
*/ |
|
74 |
@Override |
|
75 |
public ImageDescriptor getImageDescriptor() { |
|
76 |
return null; |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Gets the persistable. |
|
81 |
* |
|
82 |
* @return the persistable |
|
83 |
* @see org.eclipse.ui.IEditorInput#getPersistable() |
|
84 |
*/ |
|
85 |
@Override |
|
86 |
public IPersistableElement getPersistable() { |
|
87 |
return null; |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* Gets the tool tip text. |
|
92 |
* |
|
93 |
* @return the tool tip text |
|
94 |
* @see org.eclipse.ui.IEditorInput#getToolTipText() |
|
95 |
*/ |
|
96 |
@Override |
|
97 |
public String getToolTipText() { |
|
98 |
return getName(); |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* Gets the adapter. |
|
103 |
* |
|
104 |
* @param arg0 the arg0 |
|
105 |
* @return the adapter |
|
106 |
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) |
|
107 |
*/ |
|
108 |
@Override |
|
109 |
@SuppressWarnings("unchecked") //$NON-NLS-1$ |
|
110 |
public Object getAdapter(Class arg0) { |
|
111 |
return null; |
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* Gets the corpus. |
|
116 |
* |
|
117 |
* @return the corpus |
|
118 |
*/ |
|
119 |
public Corpus getCorpus() { |
|
120 |
return corpus; |
|
121 |
} |
|
122 |
|
|
123 |
|
|
124 |
} |
tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/editors/___BalanceEditorInput.java (revision 402) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.textsbalance.rcp.editors; |
|
29 |
|
|
30 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
31 |
import org.eclipse.ui.IPersistableElement; |
|
32 |
import org.txm.chartsengine.rcp.editors.ChartEditorInput; |
|
33 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
34 |
import org.txm.textsbalance.core.functions.TextsBalance; |
|
35 |
/** |
|
36 |
* Editor input for TextBalance. |
|
37 |
* |
|
38 |
* @author mdecorde |
|
39 |
* @author sjacquot |
|
40 |
*/ |
|
41 |
@Deprecated |
|
42 |
public class ___BalanceEditorInput extends ChartEditorInput { |
|
43 |
|
|
44 |
/** The corpus. */ |
|
45 |
private Corpus corpus; |
|
46 |
|
|
47 |
/** |
|
48 |
* Instantiates a new index editor input. |
|
49 |
* |
|
50 |
* @param corpus the corpus |
|
51 |
*/ |
|
52 |
public ___BalanceEditorInput(TextsBalance textBalance) { |
|
53 |
super(textBalance); |
|
54 |
this.corpus = textBalance.getCorpus(); |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* Exists. |
|
59 |
* |
|
60 |
* @return true, if successful |
|
61 |
* @see org.eclipse.ui.IEditorInput#exists() |
|
62 |
*/ |
|
63 |
@Override |
|
64 |
public boolean exists() { |
|
65 |
return false; |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* Gets the image descriptor. |
|
70 |
* |
|
71 |
* @return the image descriptor |
|
72 |
* @see org.eclipse.ui.IEditorInput#getImageDescriptor() |
|
73 |
*/ |
|
74 |
@Override |
|
75 |
public ImageDescriptor getImageDescriptor() { |
|
76 |
return null; |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Gets the persistable. |
|
81 |
* |
|
82 |
* @return the persistable |
|
83 |
* @see org.eclipse.ui.IEditorInput#getPersistable() |
|
84 |
*/ |
|
85 |
@Override |
|
86 |
public IPersistableElement getPersistable() { |
|
87 |
return null; |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* Gets the tool tip text. |
|
92 |
* |
|
93 |
* @return the tool tip text |
|
94 |
* @see org.eclipse.ui.IEditorInput#getToolTipText() |
|
95 |
*/ |
|
96 |
@Override |
|
97 |
public String getToolTipText() { |
|
98 |
return getName(); |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* Gets the adapter. |
|
103 |
* |
|
104 |
* @param arg0 the arg0 |
|
105 |
* @return the adapter |
|
106 |
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) |
|
107 |
*/ |
|
108 |
@Override |
|
109 |
@SuppressWarnings("unchecked") //$NON-NLS-1$ |
|
110 |
public Object getAdapter(Class arg0) { |
|
111 |
return null; |
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* Gets the corpus. |
|
116 |
* |
|
117 |
* @return the corpus |
|
118 |
*/ |
|
119 |
public Corpus getCorpus() { |
|
120 |
return corpus; |
|
121 |
} |
|
122 |
|
|
123 |
|
|
124 |
} |
|
0 | 125 |
tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/editors/BalanceEditor.java (revision 402) | ||
---|---|---|
53 | 53 |
* |
54 | 54 |
*/ |
55 | 55 |
public BalanceEditor() { |
56 |
|
|
57 | 56 |
this.supsToSkip = new String[] {"id", "base", "project"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
58 |
|
|
59 | 57 |
} |
60 | 58 |
|
61 | 59 |
|
... | ... | |
90 | 88 |
|
91 | 89 |
groupByTexts = new Button(group, SWT.RADIO); |
92 | 90 |
groupByTexts.setText("text"); |
93 |
groupByTexts.setSelection(!TXMPreferences.getBoolean(TextsBalancePreferences.PREFERENCES_NODE, this.getResultData(), TextsBalancePreferences.GROUP_BY_WORDS));
|
|
91 |
groupByTexts.setSelection(!this.getBooleanParameterValue(TextsBalancePreferences.GROUP_BY_WORDS));
|
|
94 | 92 |
|
95 | 93 |
|
96 | 94 |
groupByWords = new Button(group, SWT.RADIO); |
... | ... | |
104 | 102 |
try { |
105 | 103 |
loadSU(); |
106 | 104 |
} |
107 |
catch (CqiClientException e) {
|
|
105 |
catch (Exception e) { |
|
108 | 106 |
e.printStackTrace(); |
109 | 107 |
} |
110 | 108 |
|
... | ... | |
121 | 119 |
loadSUP(((TextsBalance)getResultData()).getCorpus().getStructuralUnit(suCombo.getText())); |
122 | 120 |
compute(true); |
123 | 121 |
} |
124 |
catch(CqiClientException e1) {
|
|
122 |
catch(Exception e1) { |
|
125 | 123 |
// TODO Auto-generated catch block |
126 | 124 |
e1.printStackTrace(); |
127 | 125 |
} |
... | ... | |
171 | 169 |
public void compute(boolean update) { |
172 | 170 |
try { |
173 | 171 |
|
174 |
String suName = TXMPreferences.getString(TextsBalancePreferences.PREFERENCES_NODE, (TextsBalance) getEditorInput().getResult(), TextsBalancePreferences.STRUCTURAL_UNIT);
|
|
172 |
String suName = this.getStringParameterValue(TextsBalancePreferences.STRUCTURAL_UNIT);
|
|
175 | 173 |
|
176 | 174 |
// gets the structural unit property name |
177 | 175 |
String supName = null; |
... | ... | |
180 | 178 |
if(Arrays.asList(this.supsToSkip).contains(p.getName())) { |
181 | 179 |
continue; |
182 | 180 |
} |
183 |
if(i == TXMPreferences.getInt(TextsBalancePreferences.PREFERENCES_NODE, this.getResultData(), TextsBalancePreferences.STRUCTURAL_UNIT_PROPERTY_INDEX)) {
|
|
181 |
if(i == this.getIntParameterValue(TextsBalancePreferences.STRUCTURAL_UNIT_PROPERTY_INDEX)) {
|
|
184 | 182 |
supName = p.getName(); |
185 | 183 |
break; |
186 | 184 |
} |
187 | 185 |
i++; |
188 | 186 |
} |
189 | 187 |
|
190 |
this.compute(TXMPreferences.getInt(TextsBalancePreferences.PREFERENCES_NODE, TextsBalancePreferences.METHOD), |
|
191 |
((TextsBalance) this.getResultData()).getCorpus().getStructuralUnit(suName), supName, |
|
192 |
!TXMPreferences.getBoolean(TextsBalancePreferences.PREFERENCES_NODE, this.getResultData(), TextsBalancePreferences.GROUP_BY_WORDS), |
|
188 |
this.compute( |
|
189 |
this.getIntParameterValue(TextsBalancePreferences.METHOD), |
|
190 |
((TextsBalance) this.getResultData()).getCorpus().getStructuralUnit(suName), |
|
191 |
supName, |
|
192 |
!this.getBooleanParameterValue(TextsBalancePreferences.GROUP_BY_WORDS), |
|
193 | 193 |
update |
194 | 194 |
); |
195 | 195 |
|
196 | 196 |
|
197 | 197 |
} |
198 |
catch(CqiClientException e) {
|
|
198 |
catch(Exception e) { |
|
199 | 199 |
// TODO Auto-generated catch block |
200 | 200 |
e.printStackTrace(); |
201 | 201 |
} |
... | ... | |
220 | 220 |
try { |
221 | 221 |
textsBalance.compute(method, su, propertyName, groupByTexts); |
222 | 222 |
} |
223 |
catch(CqiClientException e) {
|
|
223 |
catch(Exception e) { |
|
224 | 224 |
// TODO Auto-generated catch block |
225 | 225 |
e.printStackTrace(); |
226 | 226 |
} |
227 |
|
|
228 | 227 |
|
229 | 228 |
computeChart(update); |
230 | 229 |
|
231 |
// // refreshes the view to update the node label |
|
232 |
// getSite().getShell().getDisplay().syncExec(new Runnable() { |
|
233 |
// @Override |
|
234 |
// public void run() { |
|
235 |
// |
|
236 |
// if(!update) { |
|
237 |
// CorporaView.storeResult(textsBalance.getCorpus(), textsBalance); |
|
238 |
// } |
|
239 |
// else { |
|
240 |
// CorporaView.refresh(); |
|
241 |
// } |
|
242 |
// } |
|
243 |
// }); |
|
244 | 230 |
// done |
245 | 231 |
monitor.done(); |
246 | 232 |
return Status.OK_STATUS; |
tmp/org.txm.wordcloud.core/src/org/txm/wordcloud/core/functions/WordCloud.java (revision 402) | ||
---|---|---|
6 | 6 |
import java.util.List; |
7 | 7 |
|
8 | 8 |
import org.txm.chartsengine.core.results.IChartResult; |
9 |
import org.txm.core.preferences.TXMPreferences;
|
|
10 |
import org.txm.functions.Function;
|
|
9 |
import org.txm.functions.ProgressWatcher;
|
|
10 |
import org.txm.functions.TXMCommand;
|
|
11 | 11 |
import org.txm.index.core.functions.Index; |
12 | 12 |
import org.txm.index.core.functions.Line; |
13 | 13 |
import org.txm.lexicon.core.corpusengine.cqp.Lexicon; |
... | ... | |
28 | 28 |
* @author sjacquot |
29 | 29 |
* |
30 | 30 |
*/ |
31 |
public class WordCloud extends Function implements IChartResult {
|
|
31 |
public class WordCloud extends TXMCommand implements IChartResult {
|
|
32 | 32 |
|
33 | 33 |
//TODO: test rw.setStringEncoding("UTF-8"); // or connection |
34 | 34 |
private int[] freqs; |
... | ... | |
42 | 42 |
public WordCloud(Lexicon lex) { |
43 | 43 |
//List<Line> lines = voc.getAllLines(); |
44 | 44 |
super(lex); |
45 |
source = lex; |
|
45 |
this.source = lex;
|
|
46 | 46 |
this.freqs = lex.getFreq(); |
47 | 47 |
this.labels = lex.getForms(); |
48 | 48 |
|
... | ... | |
62 | 62 |
|
63 | 63 |
/** |
64 | 64 |
* |
65 |
* @param voc
|
|
65 |
* @param index
|
|
66 | 66 |
*/ |
67 |
public WordCloud(Index voc) {
|
|
68 |
super(voc);
|
|
69 |
initWith(voc);
|
|
67 |
public WordCloud(Index index) {
|
|
68 |
super(index);
|
|
69 |
this.source = index;
|
|
70 | 70 |
//removeDiacritics(); |
71 | 71 |
} |
72 | 72 |
|
... | ... | |
79 | 79 |
* @throws IOException |
80 | 80 |
* @throws CqiServerError |
81 | 81 |
*/ |
82 |
public WordCloud(Corpus corpus) throws CqiClientException, IOException, CqiServerError {
|
|
82 |
public WordCloud(Corpus corpus) { |
|
83 | 83 |
super(); |
84 |
|
|
85 |
Query query; |
|
86 |
String lang = corpus.getLang(); |
|
87 |
if (corpus.getProperty(lang+"pos") != null) { |
|
88 |
query = new Query(getQueryForLang(lang)); |
|
89 |
} else { |
|
90 |
query = new Query("[]"); |
|
91 |
} |
|
92 |
|
|
93 |
System.out.println("Used query: "+query); |
|
94 |
|
|
95 |
ArrayList<Property> props = new ArrayList<Property>(); |
|
96 |
props.add(corpus.getProperty("word")); |
|
97 |
Index index = new Index(corpus, query, props); |
|
98 |
if (!query.toString().equals("[]")) { |
|
99 |
corpus.addResult(index); |
|
100 |
} |
|
101 |
|
|
102 |
|
|
103 |
index.addResult(this); |
|
104 |
|
|
105 |
List<Line> lines = index.getAllLines(); |
|
106 |
if (lines != null && lines.size() > 0) { |
|
107 |
this.initWith(index); |
|
108 |
} else { |
|
109 |
Log.severe("Error: Could not build a word selection with this corpus"); |
|
110 |
throw new IllegalArgumentException("Error: Index failed with corpus "+corpus+" with lang "+lang+" and query "+query); |
|
111 |
} |
|
112 |
|
|
84 |
this.source = corpus; |
|
113 | 85 |
} |
114 | 86 |
|
115 | 87 |
|
88 |
|
|
116 | 89 |
/** |
117 | 90 |
* |
118 | 91 |
* @param index |
... | ... | |
160 | 133 |
} |
161 | 134 |
|
162 | 135 |
|
163 |
public Object getSource() { |
|
164 |
return source; |
|
165 |
} |
|
166 |
|
|
167 | 136 |
private void removeDiacritics() { |
168 | 137 |
//for (int i = 0; i < labels.length ; i++) |
169 | 138 |
// labels[i] = AsciiUtils.convertNonAscii(labels[i]); |
... | ... | |
272 | 241 |
|
273 | 242 |
@Override |
274 | 243 |
public String getSimpleName() { |
275 |
return WordCloudCoreMessages.RESULT_TYPE + " (" + TXMPreferences.getInt(WordCloudPreferences.PREFERENCES_NODE, this, WordCloudPreferences.FMIN)
|
|
244 |
return WordCloudCoreMessages.RESULT_TYPE + " (" + this.getIntParameterValue(WordCloudPreferences.FMIN)
|
|
276 | 245 |
+ " / " |
277 |
+ TXMPreferences.getInt(WordCloudPreferences.PREFERENCES_NODE, this, WordCloudPreferences.MAX_WORDS)
|
|
246 |
+ this.getIntParameterValue(WordCloudPreferences.MAX_WORDS)
|
|
278 | 247 |
+ ")"; |
279 | 248 |
} |
280 | 249 |
|
... | ... | |
282 | 251 |
public String getDetails() { |
283 | 252 |
return this.getSimpleName(); |
284 | 253 |
} |
285 |
|
|
254 |
|
|
255 |
@Override |
|
256 |
public boolean compute(ProgressWatcher watcher) { |
|
257 |
// from corpus |
|
258 |
if(source instanceof Corpus) { |
|
259 |
try { |
|
260 |
Corpus corpus = (Corpus) source; |
|
261 |
Query query; |
|
262 |
String lang = corpus.getLang(); |
|
263 |
if (corpus.getProperty(lang+"pos") != null) { |
|
264 |
query = new Query(getQueryForLang(lang)); |
|
265 |
} else { |
|
266 |
query = new Query("[]"); |
|
267 |
} |
|
268 |
|
|
269 |
System.out.println("Used query: "+query); |
|
270 |
|
|
271 |
ArrayList<Property> props = new ArrayList<Property>(); |
|
272 |
props.add(corpus.getProperty("word")); |
|
273 |
Index index = new Index(corpus, query, props); |
|
274 |
if (!query.toString().equals("[]")) { |
|
275 |
corpus.addResult(index); |
|
276 |
} |
|
277 |
|
|
278 |
|
|
279 |
index.addResult(this); |
|
280 |
|
|
281 |
List<Line> lines = index.getAllLines(); |
|
282 |
if (lines != null && lines.size() > 0) { |
|
283 |
this.initWith(index); |
|
284 |
} else { |
|
285 |
Log.severe("Error: Could not build a word selection with this corpus"); |
|
286 |
throw new IllegalArgumentException("Error: Index failed with corpus "+corpus+" with lang "+lang+" and query "+query); |
|
287 |
} |
|
288 |
} |
|
289 |
catch(Exception e) { |
|
290 |
// TODO Auto-generated catch block |
|
291 |
e.printStackTrace(); |
|
292 |
return false; |
|
293 |
} |
|
294 |
|
|
295 |
} |
|
296 |
// from index |
|
297 |
else if(this.source instanceof Index) { |
|
298 |
this.initWith((Index) this.source); |
|
299 |
return true; |
|
300 |
} |
|
301 |
|
|
302 |
|
|
303 |
return true; |
|
304 |
} |
|
305 |
|
|
286 | 306 |
} |
287 | 307 |
|
tmp/org.txm.wordcloud.core/src/org/txm/wordcloud/core/chartsengine/jfreechart/JFCWordCloudChartCreator.java (revision 402) | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import org.jfree.chart.JFreeChart; |
4 | 4 |
import org.jfree.data.xy.XYSeriesCollection; |
5 |
import org.txm.core.results.ITXMResult;
|
|
5 |
import org.txm.core.results.TXMResult; |
|
6 | 6 |
import org.txm.chartsengine.jfreechart.core.JFCChartCreator; |
7 | 7 |
import org.txm.wordcloud.core.functions.WordCloud; |
8 | 8 |
|
... | ... | |
13 | 13 |
} |
14 | 14 |
|
15 | 15 |
@Override |
16 |
public JFreeChart createChart(ITXMResult result, String preferencesNode) {
|
|
16 |
public JFreeChart createChart(TXMResult result) {
|
|
17 | 17 |
|
18 | 18 |
// TODO Auto-generated method stub |
19 | 19 |
System.err.println("JFCWordCloudChartCreator.createChart(): Not yet implemented"); |
tmp/org.txm.wordcloud.core/src/org/txm/wordcloud/core/chartsengine/r/RWordCloudChartCreator.java (revision 402) | ||
---|---|---|
3 | 3 |
import java.io.File; |
4 | 4 |
|
5 | 5 |
import org.txm.core.preferences.TXMPreferences; |
6 |
import org.txm.core.results.ITXMResult;
|
|
6 |
import org.txm.core.results.TXMResult; |
|
7 | 7 |
import org.txm.chartsengine.r.core.RChartCreator; |
8 | 8 |
import org.txm.chartsengine.r.core.RChartsEngine; |
9 | 9 |
import org.txm.statsengine.core.StatException; |
... | ... | |
20 | 20 |
|
21 | 21 |
|
22 | 22 |
@Override |
23 |
public File createChartFile(ITXMResult result, File file, String preferencesNode) {
|
|
23 |
public File createChartFile(TXMResult result, File file) {
|
|
24 | 24 |
|
25 | 25 |
try { |
26 | 26 |
WordCloud wordCloud = (WordCloud) result; |
27 | 27 |
|
28 | 28 |
|
29 | 29 |
// parameters |
30 |
int maxWords = TXMPreferences.getInt(preferencesNode, result, WordCloudPreferences.MAX_WORDS);
|
|
31 |
int minFreq = TXMPreferences.getInt(preferencesNode, result, WordCloudPreferences.FMIN);
|
|
32 |
float rotPer = TXMPreferences.getFloat(preferencesNode, result, WordCloudPreferences.ROT);
|
|
33 |
boolean randomOrder = TXMPreferences.getBoolean(preferencesNode, result, WordCloudPreferences.RANDOM_POSITION);
|
|
30 |
int maxWords = result.getIntParameterValue(WordCloudPreferences.MAX_WORDS);
|
|
31 |
int minFreq = result.getIntParameterValue(WordCloudPreferences.FMIN);
|
|
32 |
float rotPer = result.getFloatParameterValue(WordCloudPreferences.ROT);
|
|
33 |
boolean randomOrder = result.getBooleanParameterValue(WordCloudPreferences.RANDOM_POSITION);
|
|
34 | 34 |
|
35 | 35 |
|
36 | 36 |
RWorkspace rw = RWorkspace.getRWorkspaceInstance(); |
Formats disponibles : Unified diff