Révision 2464
| tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAFactorialMapChartEditor.java (revision 2464) | ||
|---|---|---|
| 34 | 34 |
|
| 35 | 35 |
/** |
| 36 | 36 |
* Correspondence analysis factorial map chart editor. |
| 37 |
* |
|
| 37 | 38 |
* @author sjacquot |
| 38 | 39 |
* |
| 39 | 40 |
*/ |
| 40 | 41 |
public class CAFactorialMapChartEditor extends ChartEditor<CA> {
|
| 41 |
|
|
| 42 |
|
|
| 42 |
|
|
| 43 |
|
|
| 43 | 44 |
// FIXME: try to automate that |
| 44 | 45 |
// a solution is to stop using two int in CA but a members int[] dimensions, then use a ComboViewer in this editor |
| 45 |
// /**
|
|
| 46 |
// * First dimension.
|
|
| 47 |
// */
|
|
| 48 |
// @Parameter(key=CAPreferences.FIRST_DIMENSION)
|
|
| 49 |
// protected int firstDimension = 1;
|
|
| 46 |
// /**
|
|
| 47 |
// * First dimension. |
|
| 48 |
// */ |
|
| 49 |
// @Parameter(key=CAPreferences.FIRST_DIMENSION)
|
|
| 50 |
// protected int firstDimension = 1;
|
|
| 50 | 51 |
// |
| 51 |
// /**
|
|
| 52 |
// * Second dimension.
|
|
| 53 |
// */
|
|
| 54 |
// @Parameter(key=CAPreferences.SECOND_DIMENSION)
|
|
| 55 |
// protected int secondDimension = 2;
|
|
| 56 |
|
|
| 57 |
|
|
| 52 |
// /**
|
|
| 53 |
// * Second dimension. |
|
| 54 |
// */ |
|
| 55 |
// @Parameter(key=CAPreferences.SECOND_DIMENSION)
|
|
| 56 |
// protected int secondDimension = 2;
|
|
| 57 |
|
|
| 58 |
|
|
| 58 | 59 |
/** |
| 59 | 60 |
* To show/hide individuals. |
| 60 | 61 |
*/ |
| 61 |
@Parameter(key=CAPreferences.SHOW_INDIVIDUALS)
|
|
| 62 |
@Parameter(key = CAPreferences.SHOW_INDIVIDUALS)
|
|
| 62 | 63 |
protected ToolItem showIndividuals; |
| 63 |
|
|
| 64 |
|
|
| 64 | 65 |
/** |
| 65 | 66 |
* To show/hide variables. |
| 66 | 67 |
*/ |
| 67 |
@Parameter(key=CAPreferences.SHOW_VARIABLES)
|
|
| 68 |
@Parameter(key = CAPreferences.SHOW_VARIABLES)
|
|
| 68 | 69 |
protected ToolItem showVariables; |
| 69 |
|
|
| 70 |
|
|
| 70 | 71 |
/** |
| 71 | 72 |
* To show/hide the point shapes or only the labels. |
| 72 | 73 |
*/ |
| 73 |
@Parameter(key=CAPreferences.SHOW_POINT_SHAPES)
|
|
| 74 |
@Parameter(key = CAPreferences.SHOW_POINT_SHAPES)
|
|
| 74 | 75 |
protected ToolItem showPointShapes; |
| 75 |
|
|
| 76 |
|
|
| 76 |
|
|
| 77 |
|
|
| 77 | 78 |
/** |
| 78 | 79 |
* Unit property. |
| 79 | 80 |
*/ |
| 80 |
@Parameter(key=TXMPreferences.UNIT_PROPERTY)
|
|
| 81 |
@Parameter(key = TXMPreferences.UNIT_PROPERTY)
|
|
| 81 | 82 |
protected PropertiesComboViewer unitPropertyComboViewer; |
| 82 |
|
|
| 83 |
|
|
| 83 |
|
|
| 84 |
|
|
| 84 | 85 |
/** |
| 85 | 86 |
* Minimum frequency filtering spinner. |
| 86 | 87 |
*/ |
| 87 |
@Parameter(key=TXMPreferences.F_MIN)
|
|
| 88 |
@Parameter(key = TXMPreferences.F_MIN)
|
|
| 88 | 89 |
protected Spinner fMinSpinner; |
| 89 |
|
|
| 90 |
|
|
| 90 | 91 |
/** |
| 91 | 92 |
* Maximum number of lines filtering. |
| 92 | 93 |
*/ |
| 93 |
@Parameter(key=TXMPreferences.V_MAX)
|
|
| 94 |
@Parameter(key = TXMPreferences.V_MAX)
|
|
| 94 | 95 |
protected Spinner vMaxSpinner; |
| 95 |
|
|
| 96 |
|
|
| 96 |
|
|
| 97 |
|
|
| 97 | 98 |
/** |
| 98 | 99 |
* |
| 99 | 100 |
* @param chartEditorInput |
| ... | ... | |
| 101 | 102 |
public CAFactorialMapChartEditor(ChartEditorInput chartEditorInput) {
|
| 102 | 103 |
super(chartEditorInput); |
| 103 | 104 |
} |
| 104 |
|
|
| 105 | 105 |
|
| 106 |
|
|
| 106 | 107 |
@Override |
| 107 | 108 |
public void setFocus() {
|
| 108 | 109 |
this.parentMultiPagesEditor.setFocus(); |
| 109 | 110 |
} |
| 110 | 111 |
|
| 111 |
|
|
| 112 |
|
|
| 112 | 113 |
@Override |
| 113 | 114 |
public void __createPartControl() {
|
| 114 |
|
|
| 115 |
|
|
| 115 | 116 |
// Main parameters |
| 116 | 117 |
GLComposite mainParametersArea = this.getMainParametersComposite(); |
| 117 |
|
|
| 118 |
|
|
| 118 | 119 |
try {
|
| 119 | 120 |
// display lexical table parameters if it is not visible |
| 120 | 121 |
if (!this.getResult().getParent().isVisible() // the LT parent is not visible |
| 121 |
&& !(this.getResult().getParent().getParent() instanceof PartitionIndex)) { // and its parent is not a PartitionIndex
|
|
| 122 |
&& !(this.getResult().getParent().getParent() instanceof PartitionIndex)) { // and its parent is not a PartitionIndex
|
|
| 122 | 123 |
mainParametersArea.getLayout().numColumns = 2; |
| 123 |
|
|
| 124 |
|
|
| 124 | 125 |
// unit property |
| 125 | 126 |
new Label(mainParametersArea, SWT.NONE).setText(TXMCoreMessages.common_property); |
| 126 | 127 |
this.unitPropertyComboViewer = new PropertiesComboViewer( |
| ... | ... | |
| 131 | 132 |
this.getResult().getUnitProperty(), |
| 132 | 133 |
false); |
| 133 | 134 |
} |
| 134 |
|
|
| 135 |
|
|
| 135 | 136 |
} |
| 136 | 137 |
catch (CqiClientException e) {
|
| 137 | 138 |
// TODO Auto-generated catch block |
| 138 | 139 |
e.printStackTrace(); |
| 139 | 140 |
} |
| 140 |
|
|
| 141 |
|
|
| 141 |
|
|
| 142 |
|
|
| 142 | 143 |
// Extend the chart editor tool bar |
| 143 | 144 |
new ToolItem(this.chartToolBar, SWT.SEPARATOR); |
| 144 |
|
|
| 145 |
ComputeSelectionListener computeSelectionListener = new ComputeSelectionListener(this, true);
|
|
| 146 |
|
|
| 145 |
|
|
| 146 |
ComputeSelectionListener computeSelectionListener = new ComputeSelectionListener(this, true); |
|
| 147 |
|
|
| 147 | 148 |
// Show/hide columns |
| 148 | 149 |
showIndividuals = new ToolItem(this.chartToolBar, SWT.CHECK); |
| 149 | 150 |
// FIXME: keep this for offering an option "large icons" with text in buttons ? |
| 150 |
//showColumns.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_LABEL); |
|
| 151 |
// showColumns.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_LABEL);
|
|
| 151 | 152 |
showIndividuals.setToolTipText(CAUIMessages.showhideTheColumnPoints); |
| 152 | 153 |
showIndividuals.setImage(IImageKeys.getImage(CAFactorialMapChartEditor.class, "icons/show_columns.png")); //$NON-NLS-1$ |
| 153 | 154 |
showIndividuals.addSelectionListener(computeSelectionListener); |
| 154 |
|
|
| 155 |
|
|
| 155 | 156 |
// Show/hide rows |
| 156 | 157 |
showVariables = new ToolItem(this.chartToolBar, SWT.CHECK); |
| 157 | 158 |
// FIXME: keep this for offering an option "large icons" with text in buttons ? |
| 158 |
//this.showRows.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_LABEL); |
|
| 159 |
// this.showRows.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_LABEL);
|
|
| 159 | 160 |
showVariables.setToolTipText(CAUIMessages.showhideTheRowPoints); |
| 160 | 161 |
showVariables.setImage(IImageKeys.getImage(CAFactorialMapChartEditor.class, "icons/show_rows.png")); //$NON-NLS-1$ |
| 161 | 162 |
showVariables.addSelectionListener(computeSelectionListener); |
| 162 |
|
|
| 163 |
|
|
| 163 |
|
|
| 164 |
|
|
| 164 | 165 |
// Show/hide point shapes |
| 165 | 166 |
showPointShapes = new ToolItem(this.chartToolBar, SWT.CHECK); |
| 166 | 167 |
// FIXME: keep this for offering an option "large icons" with text in buttons ? |
| 167 |
//showPointShapes.setText(CAUIMessages.SHOW_HIDE_POINT_SHAPES); |
|
| 168 |
// showPointShapes.setText(CAUIMessages.SHOW_HIDE_POINT_SHAPES);
|
|
| 168 | 169 |
showPointShapes.setToolTipText(CAUIMessages.showhidePointShapes); |
| 169 | 170 |
showPointShapes.setImage(IImageKeys.getImage(CAFactorialMapChartEditor.class, "icons/show_point_shapes.png")); //$NON-NLS-1$ |
| 170 | 171 |
showPointShapes.addSelectionListener(computeSelectionListener); |
| 171 |
|
|
| 172 |
|
|
| 172 |
|
|
| 173 |
|
|
| 173 | 174 |
// Factors plane selection |
| 174 | 175 |
CLabel factorsLabel = new CLabel(this.chartToolBar, SWT.CENTER); |
| 175 | 176 |
factorsLabel.setText(CAUIMessages.axesColon); |
| 176 | 177 |
this.chartToolBar.addControl(factorsLabel); |
| 177 |
|
|
| 178 |
|
|
| 178 | 179 |
final Combo plansCombo = new Combo(this.chartToolBar, SWT.READ_ONLY); |
| 179 |
|
|
| 180 |
|
|
| 180 | 181 |
// FIXME: commented because the infos panel is not ready to manage more axes |
| 181 |
// ArrayList<String> planes = null;
|
|
| 182 |
// try {
|
|
| 183 |
// int nbsv = ((CA) editorPart.getResultData()).getSingularValues().length;
|
|
| 184 |
// planes = new ArrayList<String>();
|
|
| 185 |
// for(int i = 1 ; i < nbsv ; i ++) {
|
|
| 186 |
// for(int j = i ; j < nbsv ; j++) {
|
|
| 187 |
// if(i != j) {
|
|
| 188 |
// planes.add("("+i+","+j+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
| 189 |
// }
|
|
| 190 |
// }
|
|
| 191 |
// }
|
|
| 192 |
// }
|
|
| 193 |
// catch (StatException e1) {
|
|
| 194 |
// // TODO Auto-generated catch block
|
|
| 195 |
// org.txm.utils.logger.Log.printStackTrace(e1);
|
|
| 196 |
// }
|
|
| 197 |
// String [] items = planes.toArray(new String[planes.size()]);
|
|
| 198 |
|
|
| 182 |
// ArrayList<String> planes = null;
|
|
| 183 |
// try {
|
|
| 184 |
// int nbsv = ((CA) editorPart.getResultData()).getSingularValues().length;
|
|
| 185 |
// planes = new ArrayList<String>();
|
|
| 186 |
// for(int i = 1 ; i < nbsv ; i ++) {
|
|
| 187 |
// for(int j = i ; j < nbsv ; j++) {
|
|
| 188 |
// if(i != j) {
|
|
| 189 |
// planes.add("("+i+","+j+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
| 190 |
// }
|
|
| 191 |
// }
|
|
| 192 |
// }
|
|
| 193 |
// }
|
|
| 194 |
// catch (StatException e1) {
|
|
| 195 |
// // TODO Auto-generated catch block
|
|
| 196 |
// org.txm.utils.logger.Log.printStackTrace(e1);
|
|
| 197 |
// }
|
|
| 198 |
// String [] items = planes.toArray(new String[planes.size()]);
|
|
| 199 |
|
|
| 199 | 200 |
String items[] = { "(1,2)", "(1,3)", "(2,3)" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
| 200 |
|
|
| 201 |
|
|
| 201 | 202 |
// TODO : commented because the infos panel is not ready to manage more axes |
| 202 |
// if(couples != null && couples.size() > 3) {
|
|
| 203 |
// items = couples.toArray(new String[couples.size()]); |
|
| 204 |
//} |
|
| 205 |
|
|
| 206 |
|
|
| 203 |
// if(couples != null && couples.size() > 3) {
|
|
| 204 |
// items = couples.toArray(new String[couples.size()]); |
|
| 205 |
// } |
|
| 206 |
|
|
| 207 | 207 |
plansCombo.setItems(items); |
| 208 |
|
|
| 208 |
|
|
| 209 | 209 |
// Preselect the plan from the CA data |
| 210 |
if(this.getIntParameterValue(CAPreferences.FIRST_DIMENSION) == 2) {
|
|
| 210 |
if (this.getIntParameterValue(CAPreferences.FIRST_DIMENSION) == 2) {
|
|
| 211 | 211 |
plansCombo.select(2); |
| 212 | 212 |
} |
| 213 |
else if(this.getIntParameterValue(CAPreferences.SECOND_DIMENSION) == 3) {
|
|
| 213 |
else if (this.getIntParameterValue(CAPreferences.SECOND_DIMENSION) == 3) {
|
|
| 214 | 214 |
plansCombo.select(1); |
| 215 | 215 |
} |
| 216 |
else {
|
|
| 216 |
else {
|
|
| 217 | 217 |
plansCombo.select(0); |
| 218 | 218 |
} |
| 219 |
|
|
| 219 |
|
|
| 220 | 220 |
this.chartToolBar.addControl(plansCombo); |
| 221 |
|
|
| 221 |
|
|
| 222 | 222 |
// Listeners |
| 223 | 223 |
SelectionListener listener = new SelectionListener() {
|
| 224 |
|
|
| 224 |
|
|
| 225 | 225 |
@Override |
| 226 | 226 |
public void widgetSelected(SelectionEvent e) {
|
| 227 |
|
|
| 227 |
|
|
| 228 | 228 |
boolean resetView = false; |
| 229 |
|
|
| 229 |
|
|
| 230 | 230 |
// Change factors |
| 231 |
if(e.getSource() == plansCombo) {
|
|
| 232 |
|
|
| 231 |
if (e.getSource() == plansCombo) {
|
|
| 232 |
|
|
| 233 | 233 |
Combo plans = (Combo) e.getSource(); |
| 234 |
|
|
| 234 |
|
|
| 235 | 235 |
int dimension1 = 1; |
| 236 | 236 |
int dimension2 = 2; |
| 237 |
|
|
| 237 |
|
|
| 238 | 238 |
String str = plans.getItem(plans.getSelectionIndex()); |
| 239 |
str = str.substring(1, str.length() -1); // remove ( and ) |
|
| 239 |
str = str.substring(1, str.length() - 1); // remove ( and )
|
|
| 240 | 240 |
String[] split = str.split(","); // 2 items //$NON-NLS-1$
|
| 241 | 241 |
dimension1 = Integer.parseInt(split[0]); |
| 242 | 242 |
dimension2 = Integer.parseInt(split[1]); |
| 243 |
|
|
| 243 |
|
|
| 244 | 244 |
getResult().setFirstDimension(dimension1); |
| 245 | 245 |
getResult().setSecondDimension(dimension2); |
| 246 |
|
|
| 246 |
|
|
| 247 | 247 |
resetView = true; |
| 248 | 248 |
} |
| 249 | 249 |
getResult().setChartDirty(); |
| 250 | 250 |
getResult().setNeedsToResetView(resetView); |
| 251 | 251 |
compute(true); |
| 252 |
//forceFocus(); |
|
| 252 |
// forceFocus();
|
|
| 253 | 253 |
} |
| 254 |
|
|
| 254 |
|
|
| 255 | 255 |
@Override |
| 256 | 256 |
public void widgetDefaultSelected(SelectionEvent e) {
|
| 257 | 257 |
// TODO Auto-generated method stub |
| 258 | 258 |
} |
| 259 | 259 |
}; |
| 260 | 260 |
plansCombo.addSelectionListener(listener); |
| 261 |
|
|
| 261 |
|
|
| 262 | 262 |
// parent parameters |
| 263 | 263 |
// thresholds |
| 264 | 264 |
if (!this.getResult().getParent().isVisible() // the LT parent is not visible |
| 265 |
&& !(this.getResult().getParent().getParent() instanceof PartitionIndex)) { // and its parent is not a PartitionIndex
|
|
| 265 |
&& !(this.getResult().getParent().getParent() instanceof PartitionIndex)) { // and its parent is not a PartitionIndex
|
|
| 266 | 266 |
ThresholdsGroup thresholdsGroup = new ThresholdsGroup(this.getExtendedParametersGroup(), SWT.NONE, this, false, false); |
| 267 | 267 |
this.fMinSpinner = thresholdsGroup.getFMinSpinner(); |
| 268 | 268 |
this.vMaxSpinner = thresholdsGroup.getVMaxSpinner(); |
| ... | ... | |
| 272 | 272 |
this.chartToolBar.pack(); |
| 273 | 273 |
|
| 274 | 274 |
} |
| 275 |
|
|
| 275 |
|
|
| 276 | 276 |
@Override |
| 277 | 277 |
public void updateEditorFromChart(boolean update) {
|
| 278 | 278 |
|
| ... | ... | |
| 282 | 282 |
// Updating complementary editors |
| 283 | 283 |
try {
|
| 284 | 284 |
// cols and rows tables |
| 285 |
((ColsRowsInfosEditor)this.parentMultiPagesEditor.getEditors().get(1)).refresh(update); |
|
| 286 |
((ColsRowsInfosEditor)this.parentMultiPagesEditor.getEditors().get(2)).refresh(update); |
|
| 285 |
((ColsRowsInfosEditor) this.parentMultiPagesEditor.getEditors().get(1)).refresh(update);
|
|
| 286 |
((ColsRowsInfosEditor) this.parentMultiPagesEditor.getEditors().get(2)).refresh(update);
|
|
| 287 | 287 |
// eigenvalues chart |
| 288 |
//((EigenvaluesChartEditor)this.parentMultiPagesEditor.getEditors().get(4)).refresh(update); |
|
| 288 |
// ((EigenvaluesChartEditor)this.parentMultiPagesEditor.getEditors().get(4)).refresh(update);
|
|
| 289 | 289 |
// eigenvalues table |
| 290 |
((TXMEditor)this.parentMultiPagesEditor.getEditors().get(4)).refresh(update); |
|
| 290 |
((TXMEditor) this.parentMultiPagesEditor.getEditors().get(4)).refresh(update);
|
|
| 291 | 291 |
} |
| 292 | 292 |
catch (Exception e) {
|
| 293 | 293 |
// TODO Auto-generated catch block |
| 294 | 294 |
e.printStackTrace(); |
| 295 | 295 |
} |
| 296 | 296 |
} |
| 297 |
|
|
| 298 | 297 |
|
| 298 |
|
|
| 299 | 299 |
@Override |
| 300 | 300 |
protected void onInit() {
|
| 301 | 301 |
|
| 302 | 302 |
IChartComponent chartComponent = this.getComposite().getChartComponent(); |
| 303 |
|
|
| 303 |
|
|
| 304 | 304 |
// Axis unit square ratio constraint |
| 305 |
//chartComponent.setSquareOffEnabled(true); |
|
| 305 |
// chartComponent.setSquareOffEnabled(true);
|
|
| 306 | 306 |
chartComponent.squareOff(); |
| 307 |
|
|
| 307 |
|
|
| 308 | 308 |
// FIXME: this code is too much AWT related |
| 309 | 309 |
// Axis unit square ratio constraint on resize |
| 310 |
((Component)chartComponent).addComponentListener(new ComponentListener() {
|
|
| 311 |
|
|
| 310 |
((Component) chartComponent).addComponentListener(new ComponentListener() {
|
|
| 311 |
|
|
| 312 | 312 |
@Override |
| 313 | 313 |
public void componentShown(ComponentEvent arg0) {
|
| 314 | 314 |
// TODO Auto-generated method stub |
| 315 | 315 |
} |
| 316 |
|
|
| 316 |
|
|
| 317 | 317 |
@Override |
| 318 | 318 |
public void componentResized(ComponentEvent e) {
|
| 319 | 319 |
getComposite().getChartComponent().squareOff(); |
| 320 | 320 |
} |
| 321 |
|
|
| 321 |
|
|
| 322 | 322 |
@Override |
| 323 | 323 |
public void componentMoved(ComponentEvent arg0) {
|
| 324 | 324 |
// TODO Auto-generated method stub |
| 325 | 325 |
} |
| 326 |
|
|
| 326 |
|
|
| 327 | 327 |
@Override |
| 328 | 328 |
public void componentHidden(ComponentEvent arg0) {
|
| 329 | 329 |
// TODO Auto-generated method stub |
| 330 | 330 |
} |
| 331 | 331 |
}); |
| 332 |
|
|
| 332 |
|
|
| 333 | 333 |
} |
| 334 | 334 |
|
| 335 |
} |
|
| 335 |
} |
|
Formats disponibles : Unified diff