-
Notifications
You must be signed in to change notification settings - Fork 7
/
FilePar.java
executable file
·3588 lines (3094 loc) · 108 KB
/
FilePar.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* @(#)FilePar.java created 01/01/1997 Mesiano
*
* Copyright (c) 1997 Luca Lutterotti All Rights Reserved.
*
* This software is the research result of Luca Lutterotti and it is
* provided as it is as confidential and proprietary information.
* You shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement you
* entered into with the author.
*
* THE AUTHOR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. THE AUTHOR SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
*/
package it.unitn.ing.rista.diffr;
import it.unitn.ing.rista.awt.*;
import it.unitn.ing.rista.comp.*;
import it.unitn.ing.rista.diffr.cal.*;
import it.unitn.ing.rista.diffr.detector.XRFDetector;
import it.unitn.ing.rista.interfaces.Function;
import it.unitn.ing.rista.io.cif.CIFItem;
import it.unitn.ing.rista.io.cif.CIFParser;
import it.unitn.ing.rista.io.cif.CIFtoken;
import it.unitn.ing.rista.util.*;
import it.unitn.ing.rista.diffr.instrument.DefaultInstrument;
import it.unitn.ing.rista.diffr.instbroad.InstrumentBroadeningPVCaglioti;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.*;
import java.io.*;
import java.net.URL;
import java.util.Vector;
import base64.Base64;
/**
* The FilePar is a class to manage the root of the analysis.
*
* @author Luca Lutterotti
* @version $Revision: 1.47 $, $Date: 2006/12/04 14:30:04 $
* @since JDK1.1
*/
public class FilePar extends XRDcat implements lFilePar, Function {
protected static final String[] diclistc = {
"_audit_creation_date", "_audit_creation_method", "_audit_update_record",
"_computing_structure_refinement", "_refine_ls_R_factor_all", "_refine_ls_wR_factor_all",
"_refine_ls_goodness_of_fit_all", "_publ_contact_author_name", "_publ_section_title",
"_pd_proc_ls_extract_int", "_pd_proc_ls_texture_comp", "_computing_reduce_memory_occ",
"_pd_proc_ls_theoretical_weight", "_pd_proc_ls_extract_pos", "_pd_proc_ls_strain_comp",
"_pd_proc_ls_extract_Fhkl", "_pd_proc_ls_Fhkl_comp", "_pd_proc_ls_weight_scheme",
"_refine_ls_weighting_scheme", "_refine_ls_WSS_factor", "_maud_store_spectra_with_analysis",
"_riet_remove_phases_under", "_riet_refine_cell_over", "_riet_refine_sizestrain_over",
"_riet_refine_crystal_structure_over", "_riet_refine_texture_over", "_riet_refine_strain_over",
"_pd_proc_ls_interpolation_comp", "_maud_analysis_name", "_maud_analysis_prog_number",
"_maud_store_structure_factors_with_analysis", "_maud_store_texture_factors_with_analysis",
"_maud_refine_weight_no_bkg", "_maud_refine_weight_q_exp", "_maud_refine_weight_intensity_cal",
"_computing_refinement_algorithm",
"_pd_spec_id"
};
protected static final String[] diclistcrm = {
"_audit_creation_date", "_audit_creation_method", "_audit_update_record",
"_computing_structure_refinement", "_refine_ls_R_factor_all", "_refine_ls_wR_factor_all",
"_refine_ls_goodness_of_fit_all", "_publ_contact_author_name", "_publ_section_title",
"_pd_proc_ls_extract_int", "_pd_proc_ls_texture_comp", "_computing_reduce_memory_occ",
"_pd_proc_ls_theoretical_weight", "_pd_proc_ls_extract_pos", "_pd_proc_ls_strain_comp",
"_pd_proc_ls_extract_Fhkl", "_pd_proc_ls_Fhkl_comp", "_pd_proc_ls_weight_scheme",
"_refine_ls_weighting_scheme", "_refine_ls_WSS_factor", "_maud_store_spectra_with_analysis",
"_riet_remove_phases_under", "_riet_refine_cell_over", "_riet_refine_sizestrain_over",
"_riet_refine_crystal_structure_over", "_riet_refine_texture_over", "_riet_refine_strain_over",
"_pd_proc_ls_interpolation_comp", "name of the analysis file", "progressive number of refinements",
"_maud_store_structure_factors_with_analysis", "_maud_store_texture_factors_with_analysis",
"_maud_refine_weight_no_bkg", "_maud_refine_weight_q_exp", "_maud_refine_weight_intensity_cal",
"_computing_refinement_algorithm",
"_pd_spec_id"
};
protected static final String[] classlistcs = {
"superclass:it.unitn.ing.rista.comp.OptimizationAlgorithm"
};
protected static final String[] classlistc = {
"superclass:it.unitn.ing.rista.diffr.Sample"};
// Lists string
public static final String[] listString = {"Sample"};
public static final String[] database = {"datasets.mdb", "structures.mdb", "samples.mdb", "instruments.mdb"};
public static String analysisFile = "analysis.last";
public static String analysisPath = "analysis.path";
public static int optimizationAlgorithmID = 0;
public static final int sampleID = 0;
public ListVector boundlistv;
// public Vector parametersV;
public Vector backupPar = null;
principalJFrame themainframe = null;
// public static int iterationnumber = MaudPreferences.getInteger(MaudPreferences.iterations);
public CIFtoken ciffile;
public launchBasic computation = null;
public OutputPanel outputframe;
// private int threadPriority = 4;
// String thefilename;
String thefolder = new String(".");
boolean isOptimizing = false;
public static int ComputationOptionNumber = 3;
public static String[] COMP_STATUS = {"never", "end of iteration", "always"};
public static String[] weights = {"default", "sqrt", "linear", "log10"}; // 0-3
// "sqrt, no bkg", "linear, no bkg", "log10, no bkg", // 4-6
// "sqrt, no bkg(-int)", "linear, no bkg(-int)", "log10, no bkg(-int)", // 7-9
// "sqrt*q", "linear*q", "log10*q", // 10-12
// "sqrt*q^2", "linear*q^2", "log10*q^2", // 13-15
// "sqrt*q^4", "linear*q^4", "log10*q^4", // 16-18
// "sqrt/q", "linear/q", "log10/q", // 19-21
// "sqrt/q^1/2", "linear/q^1/2", "log10/q^1/2", // 22-24
// "sqrt*q, no bkg", "linear*q, no bkg", "log10*q, no bkg", // 25-27
// "sqrt*q^2, no bkg", "linear*q^2, no bkg", "log10*q^2, no bkg", // 28-30
// "sqrt*q^4, no bkg", "linear*q^4, no bkg", "log10*q^4, no bkg", // 31-33
// "sqrt/q, no bkg", "linear/q, no bkg", "log10/q, no bkg", // 34-36
// "sqrt/q^1/2, no bkg", "linear/q^1/2, no bkg", "log10/q^1/2, no bkg"}; // 37-39}
public static String[] minimizeQuantity = {"WgtSS", "Rwp"}; //, "Rwp-bkg"};
/* public static String[] differenceQuantity = {"default", "sqrt", "linear", "log10",
"sqrt*q", "linear*q", "log10*q",
"sqrt*q^2", "linear*q^2", "log10*q^2",
"sqrt*q^4", "linear*q^4", "log10*q^4"};*/
// boolean refreshComputation = true;
// boolean isAbilitatetoRefresh = false;
public boolean loadingFile = false;
boolean reduceMemory = false;
boolean theoreticalWeightingScheme = false;
double weightingSchemeQExp = 0;
boolean useNoBkgForWeights = false;
public boolean intensityCalibratedForWeights = false;
public boolean addStatisticalError = false;
int numberOfData = 0;
private double parameters[];
private double[] parameters_multipliers;
int numberOfParameters = 0;
boolean refreshFit = true;
double R = 0.0;
double Rw = 0.0;
int actualfit = 0;
boolean hasBounds[] = null;
double lbound[] = null;
double ubound[] = null;
double dta[] = null;
double fit[] = null;
double wgt[] = null;
boolean computingDerivate = false;
boolean computingFunction = false;
boolean saved = false;
BoundTracker boundList = null;
public double phaseLimitForRemove = MaudPreferences.getDouble("wizard._riet_remove_phases_under", 0.001);
public double phaseLimitForCellParameters = MaudPreferences.getDouble("wizard._riet_refine_cell_over", 0.1);
public double phaseLimitForMicrostructure = MaudPreferences.getDouble("wizard._riet_refine_sizestrain_over", 0.1);
public double phaseLimitForCrystalStructure = MaudPreferences.getDouble("wizard._riet_refine_crystal_structure_over", 0.1);
public double phaseLimitForTexture = MaudPreferences.getDouble("wizard._riet_refine_texture_over", 0.15);
public double phaseLimitForStrain = MaudPreferences.getDouble("wizard._riet_refine_strain_over", 0.25);
public static int phaseLimitForRemoveID = 21;
public static int phaseLimitForCellParametersID = 22;
public static int phaseLimitForMicrostructureID = 23;
public static int phaseLimitForCrystalStructureID = 24;
public static int phaseLimitForTextureID = 25;
public static int phaseLimitForStrainID = 26;
public static int analysisNameID = 28;
public static int refinementNumberID = 29;
public static int saveStructureFactorsID = 30;
public static int saveTextureFactorsID = 31;
public static int weightingSchemeNoBkgID = 32;
public static int weightingSchemeQExpID = 33;
public static int intensityCalibratedForWeightID = 34;
public FilePar(String name) {
super(null, name);
initBaseObject();
identifier = new String(name);
setFileName(name, true);
}
public FilePar(String name, principalJFrame aframe) {
this(name);
themainframe = aframe;
}
public FilePar() {}
public URL getCodeBase() {
return null;
}
public FilePar getFilePar() {
return this;
}
public void initConstant() {
Nstring = 35;
Nstringloop = 0;
Nparameter = 0;
Nparameterloop = 0;
Nsubordinate = 1;
Nsubordinateloop = 1;
}
public void initDictionary() {
for (int i = 0; i < totsubordinateloop; i++)
diclist[i] = diclistc[i];
for (int i = 0; i < totsubordinateloop; i++)
diclistRealMeaning[i] = diclistcrm[i];
for (int i = 0; i < totsubordinate - totparameterloop; i++)
classlists[i] = classlistcs[i];
for (int i = 0; i < totsubordinateloop - totsubordinate; i++)
classlist[i] = classlistc[i];
}
public void initParameters() {
super.initParameters();
boundlistv = new ListVector(0, 1, this);
parametersV = new Vector(0, 1);
stringField[0] = new String(Misc.getCurrentDateTime());
stringField[1] = new String("Maud version " + Double.toString(Constants.maud_version));
stringField[2] = new String("No record");
stringField[3] = new String("Maud version " + Double.toString(Constants.maud_version));
stringField[4] = new String("0");
stringField[5] = new String("0");
stringField[6] = new String("0");
stringField[7] = new String("Pinco Pallino");
stringField[8] = new String("No title");
stringField[11] = new String("true");
stringField[12] = new String("false");
stringField[analysisNameID] = "untitled";
stringField[refinementNumberID] = "0";
setTextureFactorsExtractionStatus(1);
setTextureComputationStatus(1);
setPositionExtractionStatus(1);
setStrainComputationStatus(1);
setMemoryOccupationControl(true);
setStructureFactorExtractionStatus(1);
setStructureFactorComputationStatus(1);
setBackgroundInterpolationStatus(1);
setWeightingScheme(weights[0]);
setMinimizeQuantity(minimizeQuantity[0]);
stringField[19] = "0";
if (MaudPreferences.getBoolean("analysis_default.storeSpectraWithParameters", true))
stringField[20] = "true";
else
stringField[20] = "false";
stringField[phaseLimitForRemoveID] = Double.toString(phaseLimitForRemove);
stringField[phaseLimitForCellParametersID] = Double.toString(phaseLimitForCellParameters);
stringField[phaseLimitForMicrostructureID] = Double.toString(phaseLimitForMicrostructure);
stringField[phaseLimitForCrystalStructureID] = Double.toString(phaseLimitForCrystalStructure);
stringField[phaseLimitForTextureID] = Double.toString(phaseLimitForTexture);
stringField[phaseLimitForStrainID] = Double.toString(phaseLimitForStrain);
if (MaudPreferences.getBoolean("analysis_default.storeStructureFactors", true))
stringField[saveStructureFactorsID] = "true";
else
stringField[saveStructureFactorsID] = "false";
if (MaudPreferences.getBoolean("analysis_default.storeTextureFactors", true))
stringField[saveTextureFactorsID] = "true";
else
stringField[saveTextureFactorsID] = "false";
setOptimizationAlgorithm("Marqardt Least Squares");
setNoBkgForWeightingScheme(false);
setQexpForWeightingScheme(0.0);
setIntensityCalibratedForWeights(false);
}
public void setLimitsForWizard(double phaseLimitForRemove,
double phaseLimitForCellParameters,
double phaseLimitForMicrostructure,
double phaseLimitForCrystalStructure,
double phaseLimitForTexture,
double phaseLimitForStrain) {
stringField[phaseLimitForRemoveID] = Double.toString(phaseLimitForRemove);
stringField[phaseLimitForCellParametersID] = Double.toString(phaseLimitForCellParameters);
stringField[phaseLimitForMicrostructureID] = Double.toString(phaseLimitForMicrostructure);
stringField[phaseLimitForCrystalStructureID] = Double.toString(phaseLimitForCrystalStructure);
stringField[phaseLimitForTextureID] = Double.toString(phaseLimitForTexture);
stringField[phaseLimitForStrainID] = Double.toString(phaseLimitForStrain);
}
public void exportExperimentalComputedData(BufferedWriter output) {
for (int i = 0; i < samplesNumber(); i++) {
Sample tmpSample = getSample(i);
if (tmpSample != null)
tmpSample.exportExperimentalComputedData(output);
}
}
public void dispose() {
super.dispose();
closeLogResultFile();
if (boundlistv != null)
boundlistv.dispose();
if (parametersV != null)
parametersV.removeAllElements();
if (backupPar != null)
backupPar.removeAllElements();
parametersV = null;
boundlistv = null;
backupPar = null;
}
public boolean isSaved() {
return saved;
}
/* protected void finalize() throws Throwable {
// if (Constants.testing)
// System.out.println("DEBUG: " + this.toXRDcatString() + " finalizing");
// int i;
loadingFile = true;
dispose();
outputframe = null;
computation = null;
themainframe = null;
parameters = null;
parameters_multipliers = null;
hasBounds = null;
lbound = null;
ubound = null;
dta = null;
fit = null;
wgt = null;
loadingFile = false;
super.finalize();
}*/
/* public void merge(basicObj obj) {
}
public boolean isObjectSupported(XRDcat source, ListVector list) {
if (source instanceof Phase && list.equals(phaselistv))
return true;
else if (source instanceof Instrument && list.equals(getInstrumentsList()))
return true;
else if (source instanceof Sample && list.equals(getSamplesList()))
return true;
else if (source instanceof DataFileSet && list.equals(getDatasetsList()))
return true;
return false;
}
public boolean isObjectSupported(ListVector list) {
return false;
}*/
public void setDirectory(String folder) {
thefolder = new String(folder);
// if (MaudPreferences != null)
MaudPreferences.setPref(analysisPath, folder);
}
public String getDirectory() {
return thefolder;
}
public String getCreatorID() {
return stringField[1];
}
public double getVersion() {
int length = getCreatorID().length();
int i = -1;
char tmp;
do {
i++;
tmp = getCreatorID().charAt(i);
} while (!Character.isDigit(tmp) && i < length - 1);
return Double.valueOf(getCreatorID().substring(i, getCreatorID().length())).doubleValue();
}
void incrementRefinementNumber() {
int number = Integer.valueOf(stringField[refinementNumberID]).intValue();
number++;
stringField[refinementNumberID] = String.valueOf(number);
}
String getIncrementRefinementNumber() {
return stringField[refinementNumberID];
}
public void resetIncrementRefinementNumber() {
stringField[refinementNumberID] = "0";
}
public String getOperatorField() {
return stringField[7];
}
public String getTitleField() {
return stringField[8];
}
public void setOperatorField(String value) {
stringField[7] = value;
}
public void setTitleField(String value) {
stringField[8] = value;
}
public ListVector getSamplesList() {
return subordinateloopField[sampleID];
}
public boolean shouldNotifyParent(XRDcat source, int reason) {
return false; // there is no parent
}
public Object lock = new Object(); // for synchronization
public void refreshForNotificationUp(XRDcat source, int reason, int paramNumber) {
refreshComputation = true;
saved = false;
notifyDownObjectChanged(source, reason);
// System.out.println("Source " + source.toXRDcatString() + ", Reason " + reason);
if (reason != Constants.PARAMETER_CHANGED && !Constants.textonly) {
// synchronized(lock) {
themainframe.refreshParList(source, reason);
// }
}
}
public void refreshForNotificationDown(XRDcat source, int reason) {
refreshComputation = true;
}
public void refreshAll(boolean firstLoading) {
if (firstLoading) {
int checkNumber = 0;
while (!Constants.allXrayTablesLoaded && checkNumber++ < 10) {
try {
Thread.currentThread().sleep(1000);
} catch (InterruptedException ie) {
}
}
}
if (!isLoadingFile() && isAbilitatetoRefresh) {
refreshComputation = true;
setRefreshAllStatus();
update(firstLoading);
Object[] childrens = getObjectChildren();
int numberOfChildrens = childrens.length;
for (int i = 0; i < numberOfChildrens; i++) {
// System.out.println(childrens[i].toXRDcatString());
((XRDcat) childrens[i]).refreshAll(firstLoading);
}
// System.out.println("Sample indices");
refreshSampleIndices();
}
}
public void checkOwnPolynomial() {
for (int j = 0; j < samplesNumber(); j++) {
Sample asample = getSample(j);
for (int i = 0; i < asample.datasetsNumber(); i++)
asample.getDataSet(i).checkOwnPolynomial();
}
}
public void addMinMaxToParameters() {
}
public void updateStringtoDoubleBuffering(boolean firstLoading) {
super.updateStringtoDoubleBuffering(firstLoading);
if (isLoadingFile() || !isAbilitatetoRefresh)
return;
if (getMemoryOccupationControl())
reduceMemory = true;
else
reduceMemory = false;
weightSchemeSwitch = checkWeightingSchemeSwitch();
minimizingQuantity = checkMinimizeQuantity();
if (theoreticalWeightingScheme())
theoreticalWeightingScheme = true;
else
theoreticalWeightingScheme = false;
weightingSchemeQExp = Double.parseDouble(stringField[weightingSchemeQExpID]);
if (stringField[weightingSchemeNoBkgID].equalsIgnoreCase("true"))
useNoBkgForWeights = true;
else
useNoBkgForWeights = false;
if (stringField[intensityCalibratedForWeightID].equalsIgnoreCase("true"))
intensityCalibratedForWeights = true;
else
intensityCalibratedForWeights = false;
Constants.testIntensityModForWeighting = MaudPreferences.getBoolean("testing.useIntensityModifiedForStatistic", true);
logOutput = MaudPreferences.getBoolean("log_output.saveInFile", Constants.stdoutput != Constants.NO_OUTPUT);
phaseLimitForRemove = Double.parseDouble(stringField[phaseLimitForRemoveID]);
phaseLimitForCellParameters = Double.parseDouble(stringField[phaseLimitForCellParametersID]);
phaseLimitForMicrostructure = Double.parseDouble(stringField[phaseLimitForMicrostructureID]);
phaseLimitForCrystalStructure = Double.parseDouble(stringField[phaseLimitForCrystalStructureID]);
phaseLimitForTexture = Double.parseDouble(stringField[phaseLimitForTextureID]);
phaseLimitForStrain = Double.parseDouble(stringField[phaseLimitForStrainID]);
}
public boolean isLoadingFile() {
return loadingFile;
}
public void setMemoryOccupationControl(boolean control) {
if (control)
stringField[11] = new String("true");
else
stringField[11] = new String("false");
updateStringtoDoubleBuffering(false);
}
public void setMemoryOccupationControl(String control) {
stringField[11] = new String(control);
updateStringtoDoubleBuffering(false);
}
public String getMemoryOccupationControlString() {
return stringField[11];
}
public boolean getMemoryOccupationControl() {
return getMemoryOccupationControlString().equalsIgnoreCase("true");
}
public boolean reduceMemory() {
// return reduceMemory; // still dangerous
return false;
}
public boolean singleFunctionComputing() {
if (MaudPreferences.getBoolean("leastSquares.computeExtractionOnWSSCheck", false))
return true;
switch (getTextureFactorsExtractionStatusI()) {
case 2:
case 1:
return false;
case 0:
default:
{
}
}
return true;
}
int weightSchemeSwitch = 0;
public void setWeightingScheme(String scheme) {
if (stringField[17] == null || !stringField[17].equalsIgnoreCase(scheme)) {
stringField[17] = scheme;
}
weightSchemeSwitch = checkWeightingSchemeSwitch();
}
public String getWeightingScheme() {
return stringField[17];
}
public int checkWeightingSchemeSwitch() {
for (int i = 0; i < weights.length; i++)
if (getWeightingScheme().equalsIgnoreCase(weights[i]))
return i;
return 0;
}
public int getWeightingSchemeSwitch() {
return weightSchemeSwitch;
}
public void setNoBkgForWeightingScheme(boolean value) {
if (value)
stringField[weightingSchemeNoBkgID] = "true";
else
stringField[weightingSchemeNoBkgID] = "false";
}
public String getNoBkgForWeightingScheme() {
return stringField[weightingSchemeNoBkgID];
}
public boolean useNoBkgForWeightingScheme() {
return useNoBkgForWeights;
}
public void setIntensityCalibratedForWeights(boolean value) {
if (value)
stringField[intensityCalibratedForWeightID] = "true";
else
stringField[intensityCalibratedForWeightID] = "false";
}
public String getIntensityCalibratedForWeights() {
return stringField[intensityCalibratedForWeightID];
}
public boolean useIntensityCalibratedForWeights() {
return intensityCalibratedForWeights;
}
public void setQexpForWeightingScheme(double value) {
stringField[weightingSchemeQExpID] = Fmt.format(value);
}
public void setQexpForWeightingScheme(String value) {
stringField[weightingSchemeQExpID] = value;
}
public double getQexpForWeightingScheme() {
return weightingSchemeQExp;
}
public String getQexpForWeightingSchemeS() {
return stringField[weightingSchemeQExpID].toString();
}
int minimizingQuantity = 0;
public void setMinimizeQuantity(String scheme) {
if (stringField[18] == null || !stringField[18].equalsIgnoreCase(scheme)) {
stringField[18] = scheme;
}
minimizingQuantity = checkMinimizeQuantity();
}
public String getMinimizeQuantity() {
return stringField[18];
}
public int checkMinimizeQuantity() {
for (int i = 0; i < minimizeQuantity.length; i++)
if (getMinimizeQuantity().equalsIgnoreCase(minimizeQuantity[i]))
return i;
return 0;
}
public int getMinimizeQuantitySwitch() {
return minimizingQuantity;
}
public void setTheoreticalWeightingScheme(boolean control) {
if (control)
stringField[12] = "true";
else
stringField[12] = "false";
}
public void setTheoreticalWeightingScheme(String control) {
stringField[12] = new String(control);
}
public String getTheoreticalWeightingSchemeString() {
return stringField[12];
}
public boolean theoreticalWeightingScheme() {
if (getTheoreticalWeightingSchemeString().equalsIgnoreCase("true"))
return true;
else
return false;
}
public boolean theoreticalWeight() {
return theoreticalWeightingScheme;
}
public int samplesNumber() {
return getSamplesList().size();
}
public Sample getSample(int index) {
if (index >= 0 && index < samplesNumber())
return (Sample) getSamplesList().elementAt(index);
else
return null;
}
public int getSample(String id) {
for (int i = 0; i < samplesNumber(); i++)
if (id.equals(getSample(i).toXRDcatString()))
return i;
return -1;
}
static Vector listParametersForBound = null;
public static void resetListParameters() {
if (listParametersForBound != null && listParametersForBound.size() > 0)
listParametersForBound.removeAllElements();
listParametersForBound = null;
}
public void addParameterToList(Parameter par) {
if (listParametersForBound == null)
listParametersForBound = new Vector(0, 10);
checkBoundListForCellPars(par);
listParametersForBound.addElement(par);
}
public void checkBoundListForCellPars(Parameter par) {
if (par == null)
return;
if (getVersion() > 1.69 || listParametersForBound.size() < 1)
// if (listParametersForBound.size() < 1)
return;
int parIndex = getCellParOrder(par.toString());
Parameter parTmp = (Parameter) listParametersForBound.lastElement();
if (parTmp == null)
return;
int parLastIndex = getCellParOrder(parTmp.toString());
for (int i = parLastIndex + 1; i < parIndex; i++)
listParametersForBound.addElement(null);
}
public static int getCellParOrder(String label) {
if (label.equalsIgnoreCase("_cell_length_a"))
return 1;
if (label.equalsIgnoreCase("_cell_length_b"))
return 2;
if (label.equalsIgnoreCase("_cell_length_c"))
return 3;
if (label.equalsIgnoreCase("_cell_length_alpha"))
return 4;
if (label.equalsIgnoreCase("_cell_length_beta"))
return 5;
if (label.equalsIgnoreCase("_cell_length_gamma"))
return 6;
if (label.equalsIgnoreCase("_riet_par_strain_thermal"))
return 7;
return 0;
}
public static Vector instruments = null;
public static Vector datasets = null;
public static Vector phases = null;
public void initializeAnalysis() {
Constants.useNewAbsorption = MaudPreferences.getBoolean("absorption.new_model", true);
MultDiffrDataFile.resetCache();
resetListParameters();
}
public void readall(Reader in, ProgressPanel pcontrol) {
// String mem = Misc.freeMemory();
// if (Constants.testing)
// System.out.println(mem);
// System.out.println("Start loading");
loadingFile = true;
initializeAnalysis();
boundList = new BoundTracker();
instruments = new Vector(0, 1);
datasets = new Vector(0, 1);
phases = new Vector(0, 1);
String thecife;
int newtoken, tokentype;
XRDcat theobj = null;
if (in != null) {
ciffile = new CIFtoken(in);
// System.out.println("The try loop");
try {
do {
tokentype = ciffile.nextToken();
/* if (Constants.testing) {
System.out.println(ciffile.thestring);
System.out.println(tokentype);
}*/
switch (tokentype) {
case CIFtoken.TT_DATA:
// new block of data
break;
case CIFtoken.TT_GLOB:
// global data
if (pcontrol != null) {
pcontrol.setProgressText("Reading global data");
pcontrol.increaseValue();
}
theobj = this;
break;
case CIFtoken.TT_INST:
// instrumental data
if (pcontrol != null) {
pcontrol.setProgressText("Reading instrument data");
if (instruments.size() < 1)
pcontrol.increaseValue();
}
if (pcontrol != null) {
pcontrol.setProgressText("Reading instrument: " + ciffile.thestring);
}
instruments.add(new DefaultInstrument(this, ciffile.thestring));
theobj = (XRDcat) instruments.lastElement();
break;
case CIFtoken.TT_DATASET:
// data
if (pcontrol != null) {
pcontrol.setProgressText("Reading data set");
if (datasets.size() < 1)
pcontrol.increaseValue();
}
if (pcontrol != null) {
pcontrol.setProgressText("Reading dataset: " + ciffile.thestring);
}
datasets.add(new DataFileSet(this, ciffile.thestring));
theobj = (XRDcat) datasets.lastElement();
break;
case CIFtoken.TT_SAMPLE:
// sample
if (pcontrol != null) {
pcontrol.setProgressText("Reading sample data");
if (samplesNumber() < 1)
pcontrol.increaseValue();
}
if (pcontrol != null) {
pcontrol.setProgressText("Reading sample: " + ciffile.thestring);
}
theobj = addSample(new Sample(this, ciffile.thestring));
// theobj = (XRDcat) getSamplesList().lastElement();
break;
case CIFtoken.TT_BOUND:
// parameter binding
if (pcontrol != null) {
pcontrol.setProgressText("Reading parameter binding");
if (boundlistv.size() < 1)
pcontrol.increaseValue();
}
boundlistv.addItem(new Bound(this, ciffile.thestring));
theobj = (XRDcat) boundlistv.lastElement();
break;
case CIFtoken.TT_PHASE:
// phase data
if (pcontrol != null) {
pcontrol.setProgressText("Reading phases data");
if (phases.size() < 1)
pcontrol.increaseValue();
}
if (pcontrol != null) {
pcontrol.setProgressText("Reading phase: " + ciffile.thestring);
}
phases.add(new Phase(this, ciffile.thestring));
theobj = (XRDcat) phases.lastElement();
break;
case CIFtoken.TT_SUBO:
// subordinate loop
/* if (Constants.testing) {
System.out.println("SUB:" + ciffile.thestring);
System.out.println(theobj);
}*/
if (getVersion() < 2.042) { // to force loading spectra in the old analysis files
setStoreSpectraOption(false);
}
try {
theobj.readtheobject(ciffile);
} catch (Exception e) {
e.printStackTrace();
}
break;
case CIFtoken.TT_LOOP:
// data loop
Vector itemlistv = new Vector(0, 1);
Vector cifelistv = new Vector(0, 1);
newtoken = ciffile.nextToken();
// System.out.println(ciffile.thestring);
while (newtoken == CIFtoken.TT_CIFE) {
itemlistv.addElement(ciffile.thestring);
newtoken = ciffile.nextToken();
// System.out.println(ciffile.thestring);
}
int loopitem = itemlistv.size();
if (loopitem > 0) {
while (isValidToken(newtoken)) {
cifelistv.addElement(new CIFItem((String) itemlistv.elementAt(0),
ciffile));
for (int i = 1; i < loopitem; i++) {
newtoken = ciffile.nextToken();
// System.out.println(ciffile.thestring);
cifelistv.addElement(new CIFItem((String) itemlistv.elementAt(i),
ciffile));
}
newtoken = ciffile.nextToken();
// System.out.println(ciffile.thestring);
}
}
ciffile.pushBack();
// System.out.println("Pushback: " + ciffile.thestring);
if (theobj != null)
theobj.setLoop(cifelistv, loopitem);
cifelistv.removeAllElements();
itemlistv.removeAllElements();
break;
case CIFtoken.TT_CIFE:
// CIF item
thecife = new String(ciffile.thestring);
newtoken = ciffile.nextToken();
// System.out.println(ciffile.thestring);
if (isValidToken(newtoken))
theobj.setField(thecife, new CIFItem(thecife, ciffile));
else {
ciffile.pushBack();
// System.out.println("Pushback: " + ciffile.thestring);
}
break;
default:
{
}
}
} while (tokentype != CIFtoken.TT_EOF);
} catch (IOException ioe) {
System.out.println("IO exception in reading analysis file!");
ioe.printStackTrace();
}
try {
in.close();
} catch (IOException ioe) {
System.out.println("IO exception in closing the file");
ioe.printStackTrace();
}
} else {
System.out.println("File analysis not opened!!");
}
// theframe.loadingFinished();
// System.out.println("Start binding");
if (getVersion() < 2.0) {
// first Maud version
getSample(0).getDatasetsList().removeAllItems();
for (int i = 0; i < datasets.size(); i++) {
DataFileSet data = (DataFileSet) datasets.elementAt(i);
data.setParent(getSample(0));
getSample(0).addsubordinateloopField(1, data);
getSample(0).checkEnabledDatasets(data);
}
getSample(0).oldEnabledDatasets.removeAllElements();
for (int i = 0; i < phases.size(); i++) {
Phase aphase = (Phase) phases.elementAt(i);
aphase.setParent(getSample(0));
getSample(0).getPhasesList().addItem(aphase);
}
// in = Misc.getReader(getDirectory(), getFileName());
// getSample(0).readOldParFile(in, getDirectory(), getFileName());
}
if (instruments != null) {
instruments.removeAllElements();
instruments = null;
}
if (phases != null) {
phases.removeAllElements();
phases = null;
}
if (datasets != null) {
datasets.removeAllElements();
datasets = null;