Revision 133

tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/editors/CAHChartEditor.java (revision 133)
1
package org.txm.cah.rcp.editors;
2

  
3
import org.eclipse.swt.SWT;
4
import org.eclipse.swt.custom.CLabel;
5
import org.eclipse.swt.graphics.Image;
6
import org.eclipse.swt.widgets.Composite;
7
import org.eclipse.swt.widgets.Spinner;
8
import org.eclipse.swt.widgets.ToolItem;
9
import org.txm.cah.functions.CAH;
10
import org.txm.cah.rcp.chartsengine.jfreechart.events.CAHSelectionListener;
11
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
12
import org.txm.chartsengine.rcp.editors.ChartEditorInput;
13
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
14
import org.txm.chartsengine.rcp.messages.SWTComponentsProviderMessages;
15
import org.txm.functions.TXMResult;
16
import org.txm.rcpapplication.IImageKeys;
17
import org.txm.rcpapplication.Messages;
18
import org.txm.rcpapplication.commands.editor.CustomizableEditor;
19
import org.txm.searchengine.cqp.corpus.Corpus;
20

  
21
/**
22
 * CAH chart editor.
23
 * @author sjacquot, mdecorde
24
 *
25
 */
26
public class CAHChartEditor extends ChartEditorPart implements CustomizableEditor {
27

  
28
	/**
29
	 * The <code>EditorPart</code> ID constant.
30
	 */
31
	public static final String ID = CAHChartEditor.class.getCanonicalName();
32

  
33

  
34

  
35
	/**
36
	 * Numbers of clusters.
37
	 */
38
	protected Spinner numbersOfClusters;
39

  
40
	/**
41
	 * Compute columns or rows.
42
	 */
43
	protected ToolItem computeColumns;
44

  
45

  
46

  
47
	/**
48
	 * Creates an empty <code>CAHChartEditor</code>.
49
	 */
50
	public CAHChartEditor() {
51
		super();
52
	}
53

  
54

  
55
	/**
56
	 * Creates a <code>CAHChartEditor</code>.
57
	 * @param editorInput
58
	 */
59
	public CAHChartEditor(ChartEditorInput editorInput) {
60
		this.setInput(editorInput);
61
	}
62

  
63
	@Override
64
	public void createPartControl(Composite parent) {
65

  
66
		super.createPartControl(parent);
67

  
68

  
69
		// Extend the chart editor tool bar
70
		ToolItem separator = new ToolItem(this.toolBar, SWT.SEPARATOR);
71

  
72
		// Number of clusters
73
		ToolItem itemSeparator = new ToolItem(this.toolBar, SWT.SEPARATOR);
74
	    CLabel clustersLabel = new CLabel(this.toolBar, SWT.CENTER);
75
		clustersLabel.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CAH_TOOLBAR_BUTTON_NUMBER_OF_CLUSTERS);
76
		clustersLabel.pack();
77
		itemSeparator.setWidth(clustersLabel.getBounds().width);
78
	    itemSeparator.setControl(clustersLabel);
79

  
80
	    itemSeparator = new ToolItem(this.toolBar, SWT.SEPARATOR);
81
	    this.numbersOfClusters = new Spinner(this.toolBar, SWT.BORDER);
82
	    this.numbersOfClusters.setMinimum(2);
83
	    this.numbersOfClusters.setIncrement(1);
84
	    this.updateNumbersOfClustersCurrentValue();
85
	    this.updateNumbersOfClustersMaxValue();
86

  
87
		this.numbersOfClusters.addSelectionListener(new CAHSelectionListener(this, CAHSelectionListener.NUMBERS_OF_CLUSTERS));
88
		itemSeparator.setControl(this.numbersOfClusters);
89
		this.numbersOfClusters.pack();
90
		itemSeparator.setWidth(this.numbersOfClusters.getBounds().width);
91

  
92

  
93
		// Columns
94
		this.computeColumns = new ToolItem(this.toolBar, SWT.RADIO);
95
		this.computeColumns.setToolTipText(Messages.ComputeClassification_5);
96
		this.computeColumns.setImage(IImageKeys.getImage(IImageKeys.CHARTS_CAH_COMPUTE_COLUMNS));
97
		// FIXME: keep this for offering an option "large icons" with text in buttons ?
98
		//this.computeColumns.setText(Messages.ComputeClassification_5);
99
		this.computeColumns.setSelection(this.getResultData().isColumnsComputing());
100
		this.computeColumns.addSelectionListener(new CAHSelectionListener(this, CAHSelectionListener.COMPUTE_COLUMNS));
101

  
102
		// Rows
103
		ToolItem computeRows = new ToolItem(this.toolBar, SWT.RADIO);
104
		computeRows.setToolTipText(Messages.ComputeClassification_6);
105
		computeRows.setImage(IImageKeys.getImage(IImageKeys.CHARTS_CAH_COMPUTE_ROWS));
106
		// FIXME: keep this for offering an option "large icons" with text in buttons ?
107
		//computeRows.setText(Messages.ComputeClassification_6);
108
		computeRows.setSelection(!this.getResultData().isColumnsComputing());
109

  
110
	}
111

  
112

  
113
	/**
114
	 * Updates the maximum value of the number of clusters spinner according to the CAH configuration.
115
	 */
116
	public void updateNumbersOfClustersMaxValue()	{
117
		 this.numbersOfClusters.setMaximum(this.getResultData().getMaxClustersCount());
118
	}
119

  
120
	/**
121
	 * Updates the current value of the number of clusters spinner.
122
	 */
123
	public void updateNumbersOfClustersCurrentValue()	{
124
		this.numbersOfClusters.setSelection(this.getResultData().getNCluster());
125
	}
126

  
127

  
128
	@Override
129
	public void setName(String name) {
130
		this.setPartName(name);
131
	}
132

  
133
	@Override
134
	public void setIcon(Image titleImage) {
135
		this.setTitleImage(titleImage);
136
	}
137

  
138
	@Override
139
	public void setSource(Object source) {
140
		if (source instanceof CAH)
141
			getEditorInput().setResultData((TXMResult) source);
142
	}
143

  
144
	@Override
145
	public Object getSource() {
146
		return getResultData();
147
	}
148

  
149
	@Override
150
	public Object toConcordance() {
151
		// TODO Auto-generated method stub
152
		return null;
153
	}
154
	@Override
155
	public Object toIndex() {
156
		// TODO Auto-generated method stub
157
		return null;
158
	}
159
	@Override
160
	public Object toProgression() {
161
		// TODO Auto-generated method stub
162
		return null;
163
	}
164

  
165

  
166

  
167
	@Override
168
	public CAH getResultData() {
169
		return (CAH) super.getResultData();
170
	}
171

  
172

  
173
	@Override
174
	public String getID() {
175
		return CAHChartEditor.ID;
176
	}
177

  
178
	@Override
179
	public boolean usingCorpus(Corpus corpus) {
180
		CAH cah = getResultData();
181
		if (cah != null && cah.getCorpus() != null) 
182
			return cah.getCorpus().getName().equals(corpus.getName());
183
		return false;
184
	}
185

  
186

  
187
	@Override
188
	public boolean updateCorpus(Corpus corpus) {
189
		// TODO Auto-generated method stub
190
		return false;
191
	}
192
}
0 193

  
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/chartsengine/jfreechart/events/CAHSelectionListener.java (revision 133)
1
package org.txm.cah.rcp.chartsengine.jfreechart.events;
2

  
3
import org.eclipse.swt.events.SelectionEvent;
4
import org.eclipse.swt.widgets.Spinner;
5
import org.eclipse.swt.widgets.ToolItem;
6
import org.txm.cah.functions.CAH;
7
import org.txm.cah.rcp.commands.ComputeCAH;
8
import org.txm.cah.rcp.editors.CAHChartEditor;
9
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
10
import org.txm.chartsengine.rcp.events.BaseSelectionListener;
11
import org.txm.rcpapplication.TxmPreferences;
12
import org.txm.rcpapplication.preferences.CAHPreferencePage;
13
import org.txm.stat.engine.r.RWorkspaceException;
14

  
15
/**
16
 * CAH listener.
17
 * @author sjacquot
18
 *
19
 */
20
public class CAHSelectionListener extends BaseSelectionListener {
21

  
22
	
23
	/**
24
	 * Command constants.
25
	 */
26
	public final static int NUMBERS_OF_CLUSTERS = 0, COMPUTE_COLUMNS = 1; 
27
	
28
	
29
	/**
30
	 * 
31
	 * @param chartEditor
32
	 * @param commandId
33
	 */
34
	public CAHSelectionListener(ChartEditorPart chartEditor, int commandId) {
35
		super(chartEditor, commandId);
36
	}
37

  
38
	
39
	@Override
40
	public void widgetSelected(SelectionEvent e) {
41

  
42
		try {
43
			CAH cah = ((CAHChartEditor) chartEditor).getResultData();
44

  
45
			// Numbers of clusters
46
			if(this.commandId == CAHSelectionListener.NUMBERS_OF_CLUSTERS)	{
47
				cah.setNCluster(((Spinner)e.getSource()).getSelection());
48
			}
49
			// Compute columns or rows
50
			else if(this.commandId == CAHSelectionListener.COMPUTE_COLUMNS)	{
51
				cah.setColumnsComputing(((ToolItem)e.getSource()).getSelection());
52
				cah.setNCluster(TxmPreferences.getInt(CAHPreferencePage.NCLUSTER));
53
				((CAHChartEditor) chartEditor).updateNumbersOfClustersCurrentValue();
54
			}
55
			
56
			// Update the maximum value of the number of clusters spinner according to the new CAH configuration 
57
			((CAHChartEditor) chartEditor).updateNumbersOfClustersMaxValue();
58
			
59
			// Recompute the CAH
60
			ComputeCAH.compute(cah, chartEditor);
61
			
62
		}
63
		catch(RWorkspaceException e1) {
64
			// TODO Auto-generated catch block
65
			e1.printStackTrace();
66
		}
67
	}
68
	
69
	
70
}
0 71

  
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/Activator.java (revision 133)
1
package org.txm.cah.rcp;
2

  
3
import org.eclipse.ui.plugin.AbstractUIPlugin;
4
import org.osgi.framework.BundleContext;
5

  
6
/**
7
 * The activator class controls the plug-in life cycle
8
 */
9
public class Activator extends AbstractUIPlugin {
10

  
11
	// The plug-in ID
12
	public static final String PLUGIN_ID = "org.txm.cah.rcp"; //$NON-NLS-1$
13

  
14
	// The shared instance
15
	private static Activator plugin;
16
	
17
	/**
18
	 * The constructor
19
	 */
20
	public Activator() {
21
	}
22

  
23
	/*
24
	 * (non-Javadoc)
25
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
26
	 */
27
	public void start(BundleContext context) throws Exception {
28
		super.start(context);
29
		plugin = this;
30
	}
31

  
32
	/*
33
	 * (non-Javadoc)
34
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
35
	 */
36
	public void stop(BundleContext context) throws Exception {
37
		plugin = null;
38
		super.stop(context);
39
	}
40

  
41
	/**
42
	 * Returns the shared instance
43
	 *
44
	 * @return the shared instance
45
	 */
46
	public static Activator getDefault() {
47
		return plugin;
48
	}
49

  
50
}
0 51

  
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/commands/package.html (revision 133)
1
<html>
2
<body>
3
	<p>Commands which call textometry functions</p>
4
</body>
5
</html>
0 6

  
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/commands/ComputeCAH.java (revision 133)
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.cah.rcp.commands;
29

  
30
import org.eclipse.core.commands.AbstractHandler;
31
import org.eclipse.core.commands.ExecutionEvent;
32
import org.eclipse.core.commands.ExecutionException;
33
import org.eclipse.core.runtime.IProgressMonitor;
34
import org.eclipse.core.runtime.IStatus;
35
import org.eclipse.core.runtime.Status;
36
import org.eclipse.jface.dialogs.Dialog;
37
import org.eclipse.jface.viewers.IStructuredSelection;
38
import org.eclipse.jface.window.Window;
39
import org.eclipse.swt.SWT;
40
import org.eclipse.swt.layout.GridLayout;
41
import org.eclipse.swt.widgets.Button;
42
import org.eclipse.swt.widgets.Composite;
43
import org.eclipse.swt.widgets.Control;
44
import org.eclipse.swt.widgets.Display;
45
import org.eclipse.swt.widgets.Label;
46
import org.eclipse.swt.widgets.Shell;
47
import org.eclipse.swt.widgets.Spinner;
48
import org.eclipse.ui.handlers.HandlerUtil;
49
import org.txm.Toolbox;
50
import org.txm.chartsengine.core.ChartsEngine;
51
import org.txm.chartsengine.r.core.RChartsEngine;
52
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
53
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
54
import org.txm.chartsengine.svgbatik.rcp.SVGSWTChartsComponentsProvider;
55
import org.txm.functions.ca.CA;
56
import org.txm.cah.functions.CAH;
57
import org.txm.cah.rcp.editors.CAHChartEditor;
58
import org.txm.rcpapplication.IImageKeys;
59
import org.txm.rcpapplication.JobsTimer;
60
import org.txm.rcpapplication.Messages;
61
import org.txm.rcpapplication.TxmPreferences;
62
import org.txm.rcpapplication.actions.LexicalTableDialog;
63
import org.txm.rcpapplication.preferences.CAHPreferencePage;
64
import org.txm.rcpapplication.preferences.CAPreferencePage;
65
import org.txm.rcpapplication.utils.JobHandler;
66
import org.txm.rcpapplication.views.CorporaView;
67
import org.txm.rcpapplication.views.QueriesView;
68
import org.txm.rcpapplication.views.RVariablesView;
69
import org.txm.searchengine.cqp.corpus.Partition;
70
import org.txm.searchengine.cqp.corpus.Property;
71
import org.txm.stat.StatException;
72
import org.txm.stat.data.LexicalTable;
73
import org.txm.stat.engine.r.RWorkspaceException;
74
import org.txm.utils.logger.Log;
75

  
76
/**
77
 * If the selection is a CA or a Lexical Table result computes the CAH.
78
 *
79
 * @author mdecorde, sjacquot.
80
 */
81
public class ComputeCAH extends AbstractHandler {
82

  
83

  
84
	/**
85
	 * The command ID.
86
	 */
87
	public static final String ID =  ComputeCAH.class.getCanonicalName();
88

  
89

  
90

  
91
	/* (non-Javadoc)
92
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
93
	 */
94
	@Override
95
	public Object execute(ExecutionEvent event) throws ExecutionException {
96

  
97

  
98
		if (!Toolbox.isStatEngineInitialized()) {
99
			System.out.println(Messages.ComputeCAH_4);
100
			return null;
101
		}
102

  
103
		CAH cah = null;
104
		CA ca = null;
105
		LexicalTable lexicaltable = null;
106
		Partition partition = null;
107
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
108

  
109
		
110
		// Build the CA or not depending on the selection
111
		if (selection.getFirstElement() instanceof CAH) {
112
			cah = (CAH) selection.getFirstElement();
113
		} else if (selection.getFirstElement() instanceof CA) {
114
			//System.out.println("Compute CAH with CA : "+((CA)selection.getFirstElement()).getName());
115
			ca = (CA) selection.getFirstElement();
116
		} else if (selection.getFirstElement() instanceof LexicalTable) {
117
			//System.out.println("Compute CAH with LT : "+((LexicalTable)selection.getFirstElement()).getName());
118
			lexicaltable = (LexicalTable) selection.getFirstElement();
119
			
120
			try {
121
				ca = new CA(lexicaltable);
122
			} catch (StatException e) {
123
				System.out.println("Failed to build the CA with lexical table "+lexicaltable+": "+e);
124
				Log.printStackTrace(e);
125
			}
126
			lexicaltable.storeResult(ca);
127
			
128
//			if (lexicaltable.getPartition() != null)
129
//				lexicaltable.getPartition().storeResult(ca);
130
//			else if (lexicaltable.getCorpus() != null)
131
//				lexicaltable.getCorpus().storeResult(ca);
132
		} else if (selection.getFirstElement() instanceof Partition) {
133
			//System.out.println("Compute CAH with Partition : "+((Partition)selection.getFirstElement()).getName());
134
			partition = (Partition)selection.getFirstElement();
135
			try {
136
				String title = Messages.bind(Messages.ComputeCAH_0, partition.getName());
137
				int vmax = TxmPreferences.getInt(CAPreferencePage.VMAX, 200);
138
				int fmin = TxmPreferences.getInt(CAPreferencePage.FMIN, 10);
139
				Shell shell = Display.getCurrent().getActiveShell();
140
				LexicalTableDialog d = new LexicalTableDialog(shell, partition
141
						.getCorpus(), title);
142
				d.setFminAndVMax(fmin, vmax);
143
				
144
				if (d.open() == Window.OK) {
145
					Property property = d.getProperty();
146
					fmin = d.getFmin();
147
					vmax = d.getMaxLines();
148
					
149
					lexicaltable = partition.getLexicalTable(property, fmin); // use the CAPreferencePage Fmin
150
					lexicaltable.cut(vmax);
151
					partition.storeResult(lexicaltable);
152
					
153
					ca = new CA(lexicaltable);
154
					lexicaltable.storeResult(ca);
155
				} else {
156
					// canceled
157
					return null;
158
				}
159
			} catch (Exception e) {
160
				System.out.println("Failed to build the lexical table of "+partition+": "+e);
161
				Log.printStackTrace(e);
162
				return null;
163
			} 
164
		}
165

  
166
		final int ncluster = TxmPreferences.getInt(CAHPreferencePage.NCLUSTER, 2);
167
		final String metric = TxmPreferences.getString(CAHPreferencePage.METRIC, CAH.getDefaultMetric());
168
		final String method = TxmPreferences.getString(CAHPreferencePage.METHOD, CAH.getDefaultMethod());
169
		final Boolean display2D = "2D".equals(TxmPreferences.getString(CAHPreferencePage.DISPLAY, "3D")); //$NON-NLS-1$ //$NON-NLS-2$
170
		final boolean computeColumns = true;
171

  
172
		// Use existent CAH (used when reopening an editor from a CAH result node)
173
		if (cah != null)	{
174
			if (cah.getParent() != null)	{
175
				cah.getParent().removeResult(cah);
176
			}
177
		} else {
178
//			if (ca == null) cah = new CAH(lexicaltable, computeColumns, method, metric, ncluster, display2D);
179
//			else 
180
				cah = new CAH(ca, computeColumns, method, metric, ncluster, display2D);
181
		}
182
	
183
		try {
184
			compute(cah, null);
185
		}
186
		catch(RWorkspaceException e) {
187
			System.out.println("Failed to compute CAH: "+e);
188
			Log.printStackTrace(e);
189
		}
190

  
191
		return null;
192
	}
193

  
194
	/**
195
	 * Computes the CAH. Also creates the chart. Opens a chart editor if <code>chartEditor</code> is null otherwise refreshes the existing chart editor.
196
	 * @param newResult
197
	 * @throws RWorkspaceException
198
	 */
199
	public static void compute(final CAH cah, final ChartEditorPart chartEditor) throws RWorkspaceException {
200

  
201
		JobHandler jobhandler = new JobHandler(Messages.CAHEditor_0) {
202
			@Override
203
			protected IStatus run(IProgressMonitor monitor) {
204
				this.runInit(monitor);
205
				try {
206

  
207
					this.acquireSemaphore();
208
					cah.stepCompute();
209
					this.releaseSemaphore();
210

  
211
					// Store result
212
					if(chartEditor == null)	{
213
//						if (cah.getPartition() != null)	{
214
//							cah.getPartition().storeResult(cah);
215
//						}
216
//						else if (cah.getCorpus() != null)	{
217
//							cah.getCorpus().storeResult(cah);
218
//						}
219
						cah.getCA().storeResult(cah);
220
					}
221

  
222
					// Refresh views
223
					this.syncExec(new Runnable() {
224
						@Override
225
						public void run() {
226

  
227
							System.err.println("ComputeCAH.compute(): charts creator is not yet implemented.");
228
							
229
							// Create a new chart editor
230
							// FIXME: version to restore when the JFC CAH charts will be implemented
231
//							if(chartEditor == null)	{
232
//								ChartEditorPart chartEditor = Application.swtComponentProvider.createCAHChartEditorPart(IImageKeys.getImage(IImageKeys.ACTION_CAH), cah);
233
//								// Create and open the chart editor
234
//								SWTChartsComponentProvider.openEditor(chartEditor);
235
//							}
236
//							// Refresh the existing chart editor
237
//							else	{
238
//								// Create and load the new chart
239
//								chartEditor.getComposite().loadChart(Toolbox.getChartsEngine().createCAHChart(((CAHChartEditor) chartEditor).getResultData(), ((CAHChartEditor) chartEditor).getResultData().isDisplay2D()));
240
//								chartEditor.forceFocus();
241
//							}
242

  
243
							// FIXME: temporary force R/SVG version because the CAH charts are not yet implemented in JFC mode
244
							RChartsEngine tmpChartsEngine = new RChartsEngine(ChartsEngine.OUTPUT_FORMAT_SVG);
245
							if(chartEditor == null)	{
246
								SVGSWTChartsComponentsProvider tmpSWTComponentsProvider = (SVGSWTChartsComponentsProvider) SWTChartsComponentsProvider.getComponentsProvider(tmpChartsEngine);
247
								// FIXME: charts creator is not yet implemented
248
								//ChartEditorPart chartEditor = tmpSWTComponentsProvider.createCAHChartEditorPart(IImageKeys.getImage(IImageKeys.ACTION_CAH), cah);
249
								// Create and open the chart editor
250
								tmpSWTComponentsProvider.openEditor(chartEditor);
251
							}
252
							// Refresh the existing chart editor
253
							else	{
254
								// FIXME: charts creator is not yet implemented
255
								// Create and load the new chart
256
								//chartEditor.getComposite().loadChart(tmpChartsEngine.createCAHChart(((CAHChartEditor) chartEditor).getResultData(), ((CAHChartEditor) chartEditor).getResultData().isDisplay2D()));
257
								chartEditor.forceFocus();
258
							}
259

  
260

  
261
							// Refresh UI
262
							CorporaView.refresh();
263
							CorporaView.expand(cah.getParent());
264
							QueriesView.refresh();
265
							RVariablesView.refresh();
266
						}
267
					});
268

  
269

  
270
				}
271
				catch (ThreadDeath td) {
272
					return Status.CANCEL_STATUS;
273
				}
274
				catch (Exception e) {
275
					System.out.println(e.getLocalizedMessage());
276
					org.txm.rcpapplication.utils.Logger.printStackTrace(e);
277
					Log.severe("Error while computing CAH: "+e.getLocalizedMessage());
278
				}
279
				finally {
280
					monitor.done();
281
					JobsTimer.stopAndPrint();
282
				}
283
				return Status.OK_STATUS;
284
			}
285
		};
286
		jobhandler.startJob();
287

  
288
	}
289

  
290

  
291

  
292

  
293

  
294

  
295

  
296

  
297
	// FIXME: to remove when charts engine will be validated, be careful this method contains some old code to open a dialog bog, do we need to keep it ?
298
//	public Object execute1(ExecutionEvent event) throws ExecutionException {
299
//
300
//		if (!Toolbox.isStatEngineInitialized()) {
301
//			System.out.println("StatEngine is not ready. Canceling command.");
302
//			return null;
303
//		}
304
//
305
//		HandlerUtil.getActiveWorkbenchWindow(event);
306
//		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
307
//
308
//		if (selection.getFirstElement() instanceof CA) {
309
//			//System.out.println("Compute CAH with CA : "+((CA)selection.getFirstElement()).getName());
310
//			ca = (CA) selection.getFirstElement();
311
//		} else if (selection.getFirstElement() instanceof LexicalTable) {
312
//			//System.out.println("Compute CAH with LT : "+((LexicalTable)selection.getFirstElement()).getName());
313
//			lexicaltable = (LexicalTable) selection.getFirstElement();
314
//		}
315
//
316
//		openEditor1(ca, lexicaltable);
317
//
318
////		//Open CAH parameters dialog
319
////		CAHParamDialog d = new CAHParamDialog(window.getShell());
320
////
321
////		if (d.open() == Window.OK) {
322
////			final int ncluster = d.getNcluster();
323
////			final String metric = TxmPreferences.getString(CAHPreferencePage.METRIC, CAH.getDefaultMetric());
324
////			final String method = TxmPreferences.getString(CAHPreferencePage.METHOD, CAH.getDefaultMethod());
325
////			final Boolean displayMode = TxmPreferences.getBoolean(CAHPreferencePage.DISPLAY, false);
326
////			final boolean docol = d.isDoculumns();
327
////
328
////			JobHandler jobhandler = new JobHandler(Messages.ComputeCAH_3+ca.getName()) {
329
////				@Override
330
////				protected IStatus run(IProgressMonitor monitor) {
331
////					try {
332
////						JobsTimer.start();
333
////						monitor.beginTask("", 100); //$NON-NLS-1$
334
////
335
////						monitor.subTask(Messages.ComputeCAH_0);
336
////
337
////						final CAH cah;
338
////						if (ca != null) {
339
////							cah = new CAH(ca, docol, method, metric, ncluster, displayMode);
340
////							cah.stepCompute();
341
////							ca.getPartition().storeResult(cah);
342
////						} else {
343
////							cah = new CAH(lexicaltable, docol, method, metric, ncluster, displayMode);
344
////							cah.stepCompute();
345
////							lexicaltable.getPartition().storeResult(cah);
346
////						}
347
////						if (monitor.isCanceled())
348
////							return Status.CANCEL_STATUS;
349
////
350
////						monitor.worked(20);
351
////
352
////						monitor.subTask(Messages.ComputeCAH_1);
353
////
354
////						syncExec(new Runnable() {
355
////							@Override
356
////							public void run() {
357
////
358
////								RDevice device = RDevice.valueOf(TxmPreferences.getString(ExportPreferencePage.RDEVICE, RDevice.SVG.toString()));
359
////								String txmhome = Toolbox.getParam(Toolbox.USER_TXM_HOME);
360
////								File resultDir = new File(txmhome, "results"); //$NON-NLS-1$
361
////								resultDir.mkdirs();
362
////								File outfile;
363
////								try {
364
////									outfile = File.createTempFile("cah", device.getExt(), resultDir); //$NON-NLS-1$
365
////									if (!outfile.canWrite()) {
366
////										System.out.println(NLS.bind(Messages.ComputeCAH_2, outfile));
367
////									}
368
////								} catch (IOException e1) {
369
////									// TODO Auto-generated catch block
370
////									org.txm.rcpapplication.utils.Logger.printStackTrace(e1);
371
////									return;
372
////								}
373
////
374
////								try {
375
////									//System.out.println("CAH file : "+outfile);
376
////									cah.toSVG(outfile, device);
377
////									OpenGraph.OpenFile(outfile, device, cah.getPartition().getName()+": "+cah.getName(), IImageKeys.ACTION_CAH); //$NON-NLS-1$
378
////								} catch (REXPMismatchException e) {
379
////									// TODO Auto-generated catch block
380
////									org.txm.rcpapplication.utils.Logger.printStackTrace(e);
381
////								} catch (StatException e) {
382
////									// TODO Auto-generated catch block
383
////									org.txm.rcpapplication.utils.Logger.printStackTrace(e);
384
////								}
385
////							}
386
////						});
387
////						monitor.worked(50);
388
////
389
////						syncExec(new Runnable() {
390
////							@Override
391
////							public void run() {
392
////								CorporaView.refresh();
393
////								CorporaView.expand(cah.getPartition());
394
////							}
395
////						});
396
////
397
////						monitor.worked(100);
398
////					} catch (Exception e) {
399
////						org.txm.rcpapplication.utils.Logger.printStackTrace(e);
400
////					} finally {
401
////						monitor.done();
402
////					}
403
////					JobsTimer.stopAndPrint();
404
////					return Status.OK_STATUS;
405
////				}
406
////			};
407
////			jobhandler.startJob();
408
////		}
409
//		return null;
410
//	}
411

  
412

  
413

  
414

  
415
	/**
416
	 * The Class CAHParamDialog.
417
	 */
418
	public class CAHParamDialog extends Dialog {
419

  
420
		//protected Combo methodsCombo;
421
		//protected Combo metricsCombo;
422
		/** The ncluster spinner. */
423
		protected Spinner nclusterSpinner;
424

  
425
		/** The docolumns button. */
426
		protected Button docolumnsButton;
427

  
428
		/** The title. */
429
		protected String title;
430

  
431
		/**
432
		 * Instantiates a new cAH param dialog.
433
		 *
434
		 * @param parentShell the parent shell
435
		 */
436
		public CAHParamDialog(Shell parentShell) {
437
			super(parentShell);
438
			this.title = Messages.CAHEditorTitle;
439
		}
440

  
441
		/* (non-Javadoc)
442
		 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
443
		 */
444
		@Override
445
		protected void configureShell(Shell newShell) {
446
			super.configureShell(newShell);
447

  
448
			if (title != null)
449
				newShell.setText(title);
450
			else
451
				newShell.setText(Messages.CAHEditorTitle);
452
		}
453

  
454
		/** The composite. */
455
		protected Composite composite;
456

  
457
		/** The method. */
458
		private String method;
459

  
460
		/** The metric. */
461
		private String metric;
462

  
463
		/** The Ncluster. */
464
		private int Ncluster;
465

  
466
		/** The doculumns. */
467
		private boolean doculumns;
468

  
469
		/* (non-Javadoc)
470
		 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
471
		 */
472
		@Override
473
		protected Control createDialogArea(Composite parent) {
474
			composite = new Composite(parent, SWT.NONE);
475
			GridLayout layout = new GridLayout(2, false);
476
			composite.setLayout(layout);
477

  
478
			// N CLUSTERS
479
			Label label = new Label(composite, SWT.NONE);
480
			label.setText(Messages.CAHPreferencePage_2);
481

  
482
			nclusterSpinner = new Spinner(composite, SWT.BORDER);
483
			nclusterSpinner.setMinimum(2);
484
			nclusterSpinner.setIncrement(1);
485
			nclusterSpinner.setSelection(TxmPreferences.getInt(CAHPreferencePage.NCLUSTER, 2));
486
			nclusterSpinner.setMaximum(50);
487

  
488
			// ROWS OR COLS
489
			docolumnsButton = new Button(composite, SWT.RADIO);
490
			docolumnsButton.setText(Messages.ComputeClassification_5);
491
			docolumnsButton.setSelection(true);
492

  
493
			Button dorowsButton = new Button(composite, SWT.RADIO);
494
			dorowsButton.setText(Messages.ComputeClassification_6);
495

  
496
			/*
497
			// METHODS
498
			Label methodLabel = new Label(composite, SWT.NONE);
499
			methodLabel.setText("Methods");
500

  
501
			methodLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER,
502
					false, false));
503

  
504
			methodsCombo = new Combo(composite, SWT.READ_ONLY);
505
			methodsCombo.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
506
					true, false));
507
			methodsCombo.select(methodsCombo.indexOf(CAH.getDefaultMethod()));
508
			for(String method : CAH.getMethods())
509
				methodsCombo.add(method);
510

  
511
			// METRICS
512
			Label metricsLabel = new Label(composite, SWT.NONE);
513
			metricsLabel.setText("Methods");
514

  
515
			metricsLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER,
516
					false, false));
517

  
518
			metricsCombo = new Combo(composite, SWT.READ_ONLY);
519
			metricsCombo.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
520
					true, false));
521
			metricsCombo.select(metricsCombo.indexOf(CAH.getDefaultMetric()));
522
			for(String method : CAH.getMetrics())
523
				metricsCombo.add(method);
524
				*/
525

  
526
			return composite;
527
		}
528

  
529
		/* (non-Javadoc)
530
		 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
531
		 */
532
		@Override
533
		protected void okPressed() {
534
			/*int idx = methodsCombo.getSelectionIndex();
535
			method = methodsCombo.getItem(idx);
536

  
537
			idx = metricsCombo.getSelectionIndex();
538
			metric = metricsCombo.getItem(idx);
539
*/
540
			Ncluster = this.nclusterSpinner.getSelection();
541

  
542
			doculumns = this.docolumnsButton.getSelection();
543

  
544
			super.okPressed();
545
		}
546

  
547
		/**
548
		 * Gets the method.
549
		 *
550
		 * @return the method
551
		 */
552
		public String getMethod() {
553
			return method;
554
		}
555

  
556
		/**
557
		 * Gets the metric.
558
		 *
559
		 * @return the metric
560
		 */
561
		public String getMetric() {
562
			return metric;
563
		}
564

  
565
		/**
566
		 * Gets the ncluster.
567
		 *
568
		 * @return the ncluster
569
		 */
570
		public int getNcluster() {
571
			return Ncluster;
572
		}
573

  
574
		/**
575
		 * Checks if is doculumns.
576
		 *
577
		 * @return true, if is doculumns
578
		 */
579
		public boolean isDoculumns() {
580
			return doculumns;
581
		}
582
	}
583

  
584

  
585
}
0 586

  
tmp/org.txm.cah.rcp/build.properties (revision 133)
1
source.. = src/
2
output.. = bin/
3
bin.includes = META-INF/,\
4
               .
0 5

  
tmp/org.txm.cah.rcp/.settings/org.eclipse.jdt.core.prefs (revision 133)
1
eclipse.preferences.version=1
2
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4
org.eclipse.jdt.core.compiler.compliance=1.6
5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7
org.eclipse.jdt.core.compiler.source=1.6
0 8

  
tmp/org.txm.cah.rcp/.classpath (revision 133)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
0 8

  
tmp/org.txm.cah.rcp/META-INF/MANIFEST.MF (revision 133)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: CAH RCP
4
Bundle-SymbolicName: org.txm.cah.rcp
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-Activator: org.txm.cah.rcp.Activator
7
Require-Bundle: org.txm.chartsengine.rcp;bundle-version="1.0.0",
8
 org.eclipse.ui,
9
 org.eclipse.core.runtime,
10
 org.txm.cah.core;bundle-version="1.0.0",
11
 org.txm.chartsengine.core;bundle-version="1.0.0",
12
 org.txm.chartsengine.jfreechart.core;bundle-version="1.0.0",
13
 org.txm.chartsengine.r.core;bundle-version="1.0.0",
14
 org.txm.core;bundle-version="0.7.0",
15
 org.txm.rcp;bundle-version="0.7.8",
16
 org.txm.chartsengine.jfreechart.rcp;bundle-version="1.0.0",
17
 org.txm.chartsengine.r.rcp;bundle-version="1.0.0",
18
 org.txm.chartsengine.raster.rcp;bundle-version="1.0.0",
19
 org.txm.chartsengine.svgbatik.rcp;bundle-version="1.0.0"
20
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
21
Bundle-ActivationPolicy: lazy
22
Export-Package: org.txm.cah.rcp.chartsengine.jfreechart.events,
23
 org.txm.cah.rcp.editors
0 24

  
tmp/org.txm.cah.rcp/.project (revision 133)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.cah.rcp</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
	</buildSpec>
24
	<natures>
25
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.jdt.core.javanature</nature>
27
	</natures>
28
</projectDescription>
0 29

  
tmp/org.txm.cah.core/.settings/org.eclipse.jdt.core.prefs (revision 133)
1
eclipse.preferences.version=1
2
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4
org.eclipse.jdt.core.compiler.compliance=1.6
5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7
org.eclipse.jdt.core.compiler.source=1.6
0 8

  
tmp/org.txm.cah.core/.classpath (revision 133)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
0 8

  
tmp/org.txm.cah.core/META-INF/MANIFEST.MF (revision 133)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: CAH TBX
4
Bundle-SymbolicName: org.txm.cah.core
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-Activator: org.txm.cah.core.Activator
7
Require-Bundle: org.eclipse.ui,
8
 org.eclipse.core.runtime,
9
 org.txm.core;bundle-version="0.7.0",
10
 org.txm.chartsengine.core;bundle-version="1.0.0",
11
 org.txm.chartsengine.r.core;bundle-version="1.0.0",
12
 org.txm.chartsengine.jfreechart.core;bundle-version="1.0.0"
13
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
14
Bundle-ActivationPolicy: lazy
15
Export-Package: org.txm.cah.core,
16
 org.txm.cah.functions
0 17

  
tmp/org.txm.cah.core/.project (revision 133)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.cah.core</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
	</buildSpec>
24
	<natures>
25
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.jdt.core.javanature</nature>
27
	</natures>
28
</projectDescription>
0 29

  
tmp/org.txm.cah.core/src/org/txm/cah/core/Activator.java (revision 133)
1
package org.txm.cah.core;
2

  
3
import org.eclipse.ui.plugin.AbstractUIPlugin;
4
import org.osgi.framework.BundleContext;
5

  
6
/**
7
 * The activator class controls the plug-in life cycle
8
 */
9
public class Activator extends AbstractUIPlugin {
10

  
11
	// The plug-in ID
12
	public static final String PLUGIN_ID = "org.txm.cah.core"; //$NON-NLS-1$
13

  
14
	// The shared instance
15
	private static Activator plugin;
16
	
17
	/**
18
	 * The constructor
19
	 */
20
	public Activator() {
21
	}
22

  
23
	/*
24
	 * (non-Javadoc)
25
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
26
	 */
27
	public void start(BundleContext context) throws Exception {
28
		super.start(context);
29
		plugin = this;
30
	}
31

  
32
	/*
33
	 * (non-Javadoc)
34
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
35
	 */
36
	public void stop(BundleContext context) throws Exception {
37
		plugin = null;
38
		super.stop(context);
39
	}
40

  
41
	/**
42
	 * Returns the shared instance
43
	 *
44
	 * @return the shared instance
45
	 */
46
	public static Activator getDefault() {
47
		return plugin;
48
	}
49

  
50
}
0 51

  
tmp/org.txm.cah.core/src/org/txm/cah/functions/CAH.java (revision 133)
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.cah.functions;
29

  
30
import java.io.File;
31

  
32
import org.rosuda.REngine.REXP;
33
import org.rosuda.REngine.REXPMismatchException;
34
import org.txm.HasResults;
35
import org.txm.Messages;
36
import org.txm.functions.Function;
37
import org.txm.functions.TXMResult;
38
import org.txm.functions.ca.CA;
39
import org.txm.searchengine.cqp.corpus.Corpus;
40
import org.txm.searchengine.cqp.corpus.Partition;
41
import org.txm.stat.data.LexicalTable;
42
import org.txm.stat.engine.r.RWorkspace;
43
import org.txm.stat.engine.r.RWorkspaceException;
44

  
45
// TODO: Auto-generated Javadoc
46
/**
47
 * The Class CAH.
48
 * 
49
 * @author mdecorde
50
 *
51
 */
52
public class CAH extends Function implements TXMResult
53
{
54
	/** The metric. */
55
	String metric = "euclidean"; // euclidean, manhattan //$NON-NLS-1$
56

  
57
	/** The method. */
58
	String method = "ward"; // METHODS <- c("average", "single", "complete", "ward", "weighted", "flexible") //$NON-NLS-1$
59

  
60
	/** The N cluster. */
61
	int NCluster = 3;
62

  
63
	/** The columns. */
64
	boolean columns = true;
65

  
66
	/** The symbol. */
67
	String symbol = null;
68

  
69
	/** The target. */
70
	String target;
71

  
72
	/** The partition. */
73
	Partition partition;
74
	Corpus corpus;
75

  
76
	/** The source. */
77
	Object source;
78

  
79
	/** The name. */
80
	String name;
81

  
82
	/** The display2 d. */
83
	// FIXME : to remove when charts engine will be validated
84
	@Deprecated
85
	boolean display2D;
86

  
87
	// FIXME : to remove when charts engine will be validated
88
	@Deprecated
89
	private File svgFile;
90

  
91

  
92
	/**
93
	 * The coordinates of the clusters.
94
	 */
95
	protected double[][] clusterCoords = null;
96

  
97
	/**
98
	 * The numbers of the clusters.
99
	 */
100
	protected int[] clusterNumbers = null;
101

  
102
	/**
103
	 * The names of the cluster rows.
104
	 */
105
	protected String[] clusterRowNames = null;
106

  
107
	/**
108
	 * The ordered names of the cluster rows.
109
	 */
110
	protected String[] clusterOrderedRowNames = null;
111

  
112
	/**
113
	 * The cluster tree heights.
114
	 */
115
	protected double[] clusterHeights = null;
116

  
117
	/**
118
	 * The cluster tree merges.
119
	 */
120
	protected double[][] clusterMerges = null;
121

  
122
	/**
123
	 * The inertia gains.
124
	 */
125
	protected double[] inertiaGains = null;
126

  
127
	protected CA ca;
128
	protected LexicalTable table;
129

  
130

  
131
	/**
132
	 * Instantiates a new cAH.
133
	 *
134
	 * @param ca the ca
135
	 * @param col the col
136
	 * @param method the method
137
	 * @param metric the metric
138
	 * @param NCluster the n cluster
139
	 * @param display2D the display mode
140
	 */
141
	public CAH(CA ca, boolean col, String method, String metric, int NCluster, Boolean display2D)
142
	{
143
		this.ca = ca;
144
		this.table = ca.getLexicalTable();
145
		this.columns = col;
146
		this.metric = metric;
147
		this.NCluster = NCluster;
148
		this.method = method;
149
		this.display2D = display2D;
150

  
151
		this.source = ca;
152
		this.partition = ca.getPartition();
153
		this.corpus = ca.getCorpus();
154
		this.target = ca.getSymbol();
155
		this.name = ca.getName();
156
	}
157

  
158
	/**
159
	 * Instantiates a new cAH.
160
	 *
161
	 * @param table the table
162
	 * @param col the col
163
	 * @param method the method
164
	 * @param metric the metric
165
	 * @param NCluster the n cluster
166
	 * @param displayMode the display mode
167
	 */
168
	public CAH(LexicalTable table, boolean col, String method, String metric, int NCluster, Boolean display2D)
169
	{
170
		this.columns = col;
171
		this.metric = metric;
172
		this.NCluster = NCluster;
173
		this.method = method;
174
		this.display2D = display2D;
175

  
176
		this.source = table;
177
		this.partition = table.getPartition();
178
		this.corpus = table.getCorpus();
179
		this.target = table.getSymbol();
180
		this.name = table.getName();
181
		this.table = table;
182
	}
183

  
184

  
185
	/**
186
	 * Resets the cached data so the next getter calls will request the values from R.
187
	 */
188
	public void resetCache()	{
189
		this.clusterCoords = null;
190
		this.clusterNumbers = null;
191
		this.clusterRowNames = null;
192
		this.clusterOrderedRowNames = null;
193
		this.clusterHeights = null;
194
		this.clusterMerges = null;
195
	}
196

  
197
	/**
198
	 * Gets the symbol.
199
	 *
200
	 * @return the symbol
201
	 */
202
	public String getSymbol()
203
	{
204
		return symbol;
205
	}
206

  
207
	/**
208
	 * Gets the methods.
209
	 *
210
	 * @return the methods
211
	 */
212
	public static String[] getMethods()
213
	{
214
		String[] methods = {"average", "single", "complete", "ward", "weighted", "flexible"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
215
		return methods;
216
	}
217

  
218
	/**
219
	 * Gets the metrics.
220
	 *
221
	 * @return the metrics
222
	 */
223
	public static String[] getMetrics()
224
	{
225
		String[] metrics = {"euclidean", "manhattan"}; //$NON-NLS-1$ //$NON-NLS-2$
226
		return metrics;
227
	}
228

  
229
	/** The prefix r. */
230
	protected static String prefixR = "FactoMineRAHC"; //$NON-NLS-1$
231

  
232
	/** The nocah. */
233
	protected static int nocah = 1;
234

  
235
	/**
236
	 * Step compute.
237
	 *
238
	 * @throws RWorkspaceException the r workspace exception
239
	 */
240
	public void stepCompute() throws RWorkspaceException
241
	{
242
		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
243

  
244
		String colOrLine = "columns"; //$NON-NLS-1$
245
		if (!columns)
246
			colOrLine ="rows"; //$NON-NLS-1$
247

  
248
		if(symbol == null)	{
249
			symbol = prefixR+(nocah++);
250
		}
251

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff