Révision 3342
TXM/trunk/org.txm.ca.core/src/org/txm/ca/core/functions/CA.java (revision 3342) | ||
---|---|---|
137 | 137 |
* @throws StatException stat exception if the structure can not be created in R statistics engine. |
138 | 138 |
*/ |
139 | 139 |
public CA(LexicalTable lexicalTable) { |
140 |
|
|
140 | 141 |
this(null, lexicalTable); |
141 | 142 |
} |
142 | 143 |
|
... | ... | |
147 | 148 |
* @throws StatException stat exception if the structure can not be created in R statistics engine. |
148 | 149 |
*/ |
149 | 150 |
public CA(String parametersNodePath) { |
151 |
|
|
150 | 152 |
this(parametersNodePath, null); |
151 | 153 |
} |
152 | 154 |
|
... | ... | |
157 | 159 |
* @throws StatException stat exception if the structure can not be created in R statistics engine. |
158 | 160 |
*/ |
159 | 161 |
public CA(String parametersNodePath, LexicalTable lexicalTable) { |
162 |
|
|
160 | 163 |
super(parametersNodePath, lexicalTable); |
161 | 164 |
|
162 | 165 |
this.needsToSquareOff = true; |
... | ... | |
164 | 167 |
|
165 | 168 |
@Override |
166 | 169 |
public void clean() { |
170 |
|
|
167 | 171 |
try { |
168 | 172 |
if (this.getCA() != null) { |
169 | 173 |
RWorkspace.getRWorkspaceInstance().removeVariableFromWorkspace(this.getCA().getSymbol()); |
... | ... | |
220 | 224 |
} |
221 | 225 |
|
222 | 226 |
public void displayOptions(String col, String row, float cex) { |
227 |
|
|
223 | 228 |
this.cex = Math.abs(cex); |
224 | 229 |
if (col.matches(pattern)) { |
225 | 230 |
this.colfilter = col; |
... | ... | |
247 | 252 |
// FIXME: to move in an exporter extension |
248 | 253 |
@Deprecated |
249 | 254 |
public boolean exportColInfos(File file, String encoding, String colseparator, String textseparator) { |
255 |
|
|
250 | 256 |
try { |
251 | 257 |
Writer writer = new OutputStreamWriter(new FileOutputStream(file), encoding); |
252 | 258 |
String[] titles = getColInfosTitles(); |
... | ... | |
254 | 260 |
String title = titles[i]; |
255 | 261 |
if (i < titles.length - 1) |
256 | 262 |
writer.write(textseparator + title + textseparator + colseparator); |
257 |
else |
|
258 |
writer.write(textseparator + title + textseparator + colseparator); |
|
263 |
else writer.write(textseparator + title + textseparator + colseparator); |
|
259 | 264 |
} |
260 | 265 |
writer.write("\n"); //$NON-NLS-1$ |
261 | 266 |
Object[] infos = getColInfos(); |
... | ... | |
288 | 293 |
// FIXME: to move in an exporter extension |
289 | 294 |
@Deprecated |
290 | 295 |
public void exportRowInfos(File file, String encoding, String colseparator, String textseparator) { |
296 |
|
|
291 | 297 |
try { |
292 | 298 |
Writer writer = new OutputStreamWriter(new FileOutputStream(file), encoding); |
293 | 299 |
String[] titles = getRowInfosTitles(); |
... | ... | |
324 | 330 |
* @return the ca |
325 | 331 |
*/ |
326 | 332 |
public org.txm.ca.core.statsengine.r.functions.ICA getCA() { |
333 |
|
|
327 | 334 |
return r_ca; |
328 | 335 |
} |
329 | 336 |
|
330 | 337 |
public float getCex() { |
338 |
|
|
331 | 339 |
return cex; |
332 | 340 |
} |
333 | 341 |
|
... | ... | |
337 | 345 |
* @return the column filter -> only used by FactoMineR |
338 | 346 |
*/ |
339 | 347 |
public String getColFilter() { |
348 |
|
|
340 | 349 |
return colfilter; |
341 | 350 |
} |
342 | 351 |
|
... | ... | |
347 | 356 |
* @return the col infos titles |
348 | 357 |
*/ |
349 | 358 |
public String[] getColInfosTitles() { |
359 |
|
|
350 | 360 |
if (coltitles == null) { |
351 | 361 |
List<String> colnames = new ArrayList<>(); |
352 | 362 |
colnames.add(TXMCoreMessages.common_cols); // entry |
... | ... | |
379 | 389 |
* @throws StatException the stat exception |
380 | 390 |
*/ |
381 | 391 |
public String[] getColNames() throws StatException { |
392 |
|
|
382 | 393 |
if (colnames == null) { |
383 | 394 |
colnames = this.getCA().getColNames().asStringsArray(); |
384 | 395 |
} |
... | ... | |
391 | 402 |
* @return the columns coordinates |
392 | 403 |
*/ |
393 | 404 |
public double[][] getColsCoords() { |
405 |
|
|
394 | 406 |
return this.r_ca.getColsCoords(); |
395 | 407 |
} |
396 | 408 |
|
... | ... | |
401 | 413 |
* @throws StatException the stat exception |
402 | 414 |
*/ |
403 | 415 |
public double[] getColsDist() throws StatException { |
416 |
|
|
404 | 417 |
return this.r_ca.getColDist(); |
405 | 418 |
} |
406 | 419 |
|
... | ... | |
411 | 424 |
* @throws StatException the stat exception |
412 | 425 |
*/ |
413 | 426 |
public double[] getColsInertia() throws StatException { |
427 |
|
|
414 | 428 |
return this.r_ca.getColsInertia(); |
415 | 429 |
} |
416 | 430 |
|
... | ... | |
421 | 435 |
* @throws StatException the stat exception |
422 | 436 |
*/ |
423 | 437 |
public double[] getColsMass() throws StatException { |
438 |
|
|
424 | 439 |
return this.r_ca.getColsMass(); |
425 | 440 |
} |
426 | 441 |
|
... | ... | |
432 | 447 |
* @throws RWorkspaceException |
433 | 448 |
*/ |
434 | 449 |
public int getColumnsCount() throws RWorkspaceException, REXPMismatchException { |
450 |
|
|
435 | 451 |
return this.r_ca.getColumnsCount(); |
436 | 452 |
} |
437 | 453 |
|
438 | 454 |
|
439 | 455 |
@Override |
440 | 456 |
public String[] getExportTXTExtensions() { |
457 |
|
|
441 | 458 |
return new String[] { "*.txt" }; |
442 | 459 |
} |
443 | 460 |
|
... | ... | |
447 | 464 |
* @return the first dimension |
448 | 465 |
*/ |
449 | 466 |
public int getFirstDimension() { |
467 |
|
|
450 | 468 |
return firstDimension; |
451 | 469 |
} |
452 | 470 |
|
... | ... | |
456 | 474 |
* @return the lexical table |
457 | 475 |
*/ |
458 | 476 |
public LexicalTable getLexicalTable() { |
477 |
|
|
459 | 478 |
return (LexicalTable) this.parent; |
460 | 479 |
} |
461 | 480 |
|
... | ... | |
466 | 485 |
* @throws StatException |
467 | 486 |
*/ |
468 | 487 |
public double[][] getRowContrib() throws StatException { |
488 |
|
|
469 | 489 |
return r_ca.getRowContrib(); |
470 | 490 |
} |
471 | 491 |
|
... | ... | |
476 | 496 |
* @throws StatException |
477 | 497 |
*/ |
478 | 498 |
public double[][] getRowCos2() throws StatException { |
499 |
|
|
479 | 500 |
return r_ca.getRowCos2(); |
480 | 501 |
} |
481 | 502 |
|
482 | 503 |
public String getRowFilter() { |
504 |
|
|
483 | 505 |
return rowfilter; |
484 | 506 |
} |
485 | 507 |
|
... | ... | |
633 | 655 |
* @return the row infos titles |
634 | 656 |
*/ |
635 | 657 |
public String[] getRowInfosTitles() { |
658 |
|
|
636 | 659 |
if (rowtitles == null) { |
637 | 660 |
List<String> colnames = new ArrayList<>(); |
638 | 661 |
colnames.add(TXMCoreMessages.common_rows); // entry |
... | ... | |
665 | 688 |
* @throws StatException the stat exception |
666 | 689 |
*/ |
667 | 690 |
public String[] getRowNames() throws Exception { |
691 |
|
|
668 | 692 |
if (rownames == null) { |
669 | 693 |
rownames = this.getLexicalTable().getRowNames().asStringsArray(); |
670 | 694 |
} |
... | ... | |
677 | 701 |
* @return the rows coords |
678 | 702 |
*/ |
679 | 703 |
public double[][] getRowsCoords() { |
704 |
|
|
680 | 705 |
return this.r_ca.getRowsCoords(); |
681 | 706 |
} |
682 | 707 |
|
... | ... | |
688 | 713 |
* @throws RWorkspaceException |
689 | 714 |
*/ |
690 | 715 |
public int getRowsCount() throws RWorkspaceException, REXPMismatchException { |
716 |
|
|
691 | 717 |
return this.r_ca.getRowsCount(); |
692 | 718 |
} |
693 | 719 |
|
... | ... | |
698 | 724 |
* @throws StatException the stat exception |
699 | 725 |
*/ |
700 | 726 |
public double[] getRowsDist() throws StatException { |
727 |
|
|
701 | 728 |
return this.r_ca.getRowDist(); |
702 | 729 |
} |
703 | 730 |
|
... | ... | |
708 | 735 |
* @throws StatException the stat exception |
709 | 736 |
*/ |
710 | 737 |
public double[] getRowsInertia() throws StatException { |
738 |
|
|
711 | 739 |
return this.r_ca.getRowsInertia(); |
712 | 740 |
} |
713 | 741 |
|
... | ... | |
718 | 746 |
* @throws StatException the stat exception |
719 | 747 |
*/ |
720 | 748 |
public double[] getRowsMass() throws StatException { |
749 |
|
|
721 | 750 |
return this.r_ca.getRowsMass(); |
722 | 751 |
} |
723 | 752 |
|
... | ... | |
761 | 790 |
* @return the second dimension |
762 | 791 |
*/ |
763 | 792 |
public int getSecondDimension() { |
793 |
|
|
764 | 794 |
return secondDimension; |
765 | 795 |
} |
766 | 796 |
|
767 | 797 |
@Override |
768 | 798 |
public String getSimpleName() { |
799 |
|
|
769 | 800 |
try { |
770 | 801 |
return this.getParent().getProperty().asString() + " (" + this.firstDimension + "," + this.secondDimension + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
771 | 802 |
} |
... | ... | |
776 | 807 |
|
777 | 808 |
@Override |
778 | 809 |
public String getName() { |
810 |
|
|
779 | 811 |
return this.getParent().getName() + TXMPreferences.PARENT_NAME_SEPARATOR + " (" + this.firstDimension + "," + this.secondDimension + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ ; |
780 | 812 |
} |
781 | 813 |
|
782 | 814 |
|
783 | 815 |
@Override |
784 | 816 |
public String getDetails() { |
817 |
|
|
785 | 818 |
try { |
786 | 819 |
return this.getSimpleName() + " " + NLS.bind(TXMCoreMessages.common_fMinEquals, this.getLexicalTable().getFMin()); |
787 | 820 |
} |
... | ... | |
793 | 826 |
|
794 | 827 |
@Override |
795 | 828 |
public String getComputingStartMessage() { |
829 |
|
|
796 | 830 |
// from lexical table |
797 | 831 |
if (this.parent.isVisible()) { |
798 | 832 |
return TXMCoreMessages.bind(CACoreMessages.info_caOfTheP0LexcialTable, this.getParent().getName()); |
... | ... | |
825 | 859 |
* @throws REXPMismatchException |
826 | 860 |
*/ |
827 | 861 |
public double[] getSingularValues() throws StatException, REXPMismatchException { |
862 |
|
|
828 | 863 |
return r_ca.getSingularValues(); |
829 | 864 |
} |
830 | 865 |
|
... | ... | |
835 | 870 |
* @throws REXPMismatchException |
836 | 871 |
*/ |
837 | 872 |
public List<List<Object>> getSingularValuesInfos() throws REXPMismatchException { |
873 |
|
|
838 | 874 |
List<List<Object>> svtabledata = new ArrayList<>(); |
839 | 875 |
|
840 | 876 |
double[] sv = null; |
... | ... | |
879 | 915 |
|
880 | 916 |
@Override |
881 | 917 |
public String getRSymbol() { |
918 |
|
|
882 | 919 |
return r_ca.getSymbol(); |
883 | 920 |
} |
884 | 921 |
|
... | ... | |
890 | 927 |
* @throws REXPMismatchException |
891 | 928 |
*/ |
892 | 929 |
public double[] getValeursPropres() throws StatException, REXPMismatchException { |
930 |
|
|
893 | 931 |
return r_ca.getEigenvalues(); |
894 | 932 |
} |
895 | 933 |
|
... | ... | |
901 | 939 |
* @throws REXPMismatchException |
902 | 940 |
*/ |
903 | 941 |
public double getValeursPropresSum() throws StatException, REXPMismatchException { |
942 |
|
|
904 | 943 |
double sum = 0; |
905 | 944 |
for (double d : getValeursPropres()) { |
906 | 945 |
sum += d; |
... | ... | |
915 | 954 |
* @param outfile the outfile |
916 | 955 |
* @param encoding the encoding |
917 | 956 |
* @return true, if successful |
918 |
* @throws Exception
|
|
957 |
* @throws Exception |
|
919 | 958 |
*/ |
920 | 959 |
// FIXME: to move in an exporter extension |
921 | 960 |
@Deprecated |
922 | 961 |
public boolean toTxt(File outfile, String encoding) throws Exception { |
962 |
|
|
923 | 963 |
return toTxt(outfile, encoding, "\t", ""); //$NON-NLS-1$ //$NON-NLS-2$ |
924 | 964 |
} |
925 | 965 |
|
... | ... | |
936 | 976 |
// FIXME: to move in an exporter extension |
937 | 977 |
@Deprecated |
938 | 978 |
public boolean _toTxt(File outfile, String encoding, String colseparator, String txtseparator) { |
979 |
|
|
939 | 980 |
acquireSemaphore(); |
940 | 981 |
boolean rez = r_ca.toTxt(outfile, encoding, colseparator, txtseparator); |
941 | 982 |
releaseSemaphore(); |
... | ... | |
950 | 991 |
* @return <code>true</code> if the CA uses the FactoMineR R package otherwise <code>false</code> |
951 | 992 |
*/ |
952 | 993 |
public boolean useFactoMineR() { |
994 |
|
|
953 | 995 |
return this.useFactoMineR; |
954 | 996 |
} |
955 | 997 |
|
956 | 998 |
@Override |
957 | 999 |
public boolean canCompute() { |
1000 |
|
|
958 | 1001 |
try { |
959 | 1002 |
return this.getLexicalTable().getNColumns() > 3 |
960 | 1003 |
&& this.firstDimension > 0 |
... | ... | |
970 | 1013 |
|
971 | 1014 |
@Override |
972 | 1015 |
public boolean saveParameters() { |
1016 |
|
|
973 | 1017 |
// nothing to do |
974 | 1018 |
return true; |
975 | 1019 |
} |
976 | 1020 |
|
977 | 1021 |
@Override |
978 | 1022 |
public boolean setParameters(TXMParameters parameters) { |
1023 |
|
|
979 | 1024 |
// TODO Auto-generated method stub |
980 | 1025 |
System.err.println("CA.setParameters(): not yet implemented."); |
981 | 1026 |
return true; |
... | ... | |
983 | 1028 |
|
984 | 1029 |
@Override |
985 | 1030 |
public boolean loadParameters() { |
1031 |
|
|
986 | 1032 |
// nothing to do |
987 | 1033 |
return true; |
988 | 1034 |
} |
... | ... | |
991 | 1037 |
* @return the showIndividuals |
992 | 1038 |
*/ |
993 | 1039 |
public boolean isShowIndividuals() { |
1040 |
|
|
994 | 1041 |
return showIndividuals; |
995 | 1042 |
} |
996 | 1043 |
|
... | ... | |
998 | 1045 |
* @param showIndividuals the showIndividuals to set |
999 | 1046 |
*/ |
1000 | 1047 |
public void setShowIndividuals(boolean showIndividuals) { |
1048 |
|
|
1001 | 1049 |
this.showIndividuals = showIndividuals; |
1002 | 1050 |
} |
1003 | 1051 |
|
... | ... | |
1005 | 1053 |
* @return the showVariables |
1006 | 1054 |
*/ |
1007 | 1055 |
public boolean isShowVariables() { |
1056 |
|
|
1008 | 1057 |
return showVariables; |
1009 | 1058 |
} |
1010 | 1059 |
|
... | ... | |
1012 | 1061 |
* @param showVariables the showVariables to set |
1013 | 1062 |
*/ |
1014 | 1063 |
public void setShowVariables(boolean showVariables) { |
1064 |
|
|
1015 | 1065 |
this.showVariables = showVariables; |
1016 | 1066 |
} |
1017 | 1067 |
|
... | ... | |
1019 | 1069 |
* @return the showPointShapes |
1020 | 1070 |
*/ |
1021 | 1071 |
public boolean isShowPointShapes() { |
1072 |
|
|
1022 | 1073 |
return showPointShapes; |
1023 | 1074 |
} |
1024 | 1075 |
|
... | ... | |
1026 | 1077 |
* @param showPointShapes the showPointShapes to set |
1027 | 1078 |
*/ |
1028 | 1079 |
public void setShowPointShapes(boolean showPointShapes) { |
1080 |
|
|
1029 | 1081 |
this.showPointShapes = showPointShapes; |
1030 | 1082 |
} |
1031 | 1083 |
|
... | ... | |
1033 | 1085 |
* @param firstDimension the firstDimension to set |
1034 | 1086 |
*/ |
1035 | 1087 |
public void setFirstDimension(int firstDimension) { |
1088 |
|
|
1036 | 1089 |
this.firstDimension = firstDimension; |
1037 | 1090 |
} |
1038 | 1091 |
|
... | ... | |
1040 | 1093 |
* @param secondDimension the secondDimension to set |
1041 | 1094 |
*/ |
1042 | 1095 |
public void setSecondDimension(int secondDimension) { |
1096 |
|
|
1043 | 1097 |
this.secondDimension = secondDimension; |
1044 | 1098 |
} |
1045 | 1099 |
|
1046 | 1100 |
@Override |
1047 | 1101 |
public String getResultType() { |
1102 |
|
|
1048 | 1103 |
return CACoreMessages.RESULT_TYPE; |
1049 | 1104 |
} |
1050 | 1105 |
|
... | ... | |
1055 | 1110 |
* @return the unitProperty |
1056 | 1111 |
*/ |
1057 | 1112 |
public Property getUnitProperty() { |
1113 |
|
|
1058 | 1114 |
return this.getLexicalTable().getProperty(); |
1059 | 1115 |
} |
1060 | 1116 |
|
1061 | 1117 |
|
1062 | 1118 |
@Override |
1063 | 1119 |
public LexicalTable getParent() { |
1120 |
|
|
1064 | 1121 |
return (LexicalTable) this.parent; |
1065 | 1122 |
} |
1066 | 1123 |
|
Formats disponibles : Unified diff