// Read base model
Element baseElement = modelElement.getChild("model", Extractor.ns);
ModelExtractor extractor =
(ModelExtractor) ExtractorManager.getExtractor(baseElement
.getName());
Strategy baseStrategy = extractor.extract(baseElement);
MassAbsorptionCoefficient baseMAC =
(MassAbsorptionCoefficient) baseStrategy
.getAlgorithm(MassAbsorptionCoefficient.class);
// Read MAC values
UserSpecifiedCoefficient mac =
new UserSpecifiedCoefficient(baseMAC);
gov.nist.microanalysis.EPQLibrary.Element absorber;
double energy, macValue;
int z, src, dest;
XRayTransition transition;
for (Element subelement : modelElement.getChildren("mac")) {
try {
absorber =
gov.nist.microanalysis.EPQLibrary.Element
.byAtomicNumber(subelement.getAttribute(
"absorber").getIntValue());
} catch (DataConversionException e) {
throw new IOException(e);
}
if (subelement.getAttribute("energy") != null) {
try {
energy =
subelement.getAttribute("energy")
.getDoubleValue();
} catch (DataConversionException e) {
throw new IOException(e);
}
} else {
try {
z = subelement.getAttribute("z").getIntValue();
src = subelement.getAttribute("src").getIntValue() - 1;
dest =
subelement.getAttribute("dest").getIntValue() - 1;
} catch (DataConversionException e) {
throw new IOException(e);
}
transition =
new XRayTransition(
gov.nist.microanalysis.EPQLibrary.Element
.byAtomicNumber(z),
src, dest);
try {
energy = transition.getEnergy_eV();
} catch (EPQException e) {
throw new IOException(e);
}
}
macValue = Double.parseDouble(subelement.getText());
mac.put(absorber, ToSI.eV(energy), macValue);
}
Strategy st = new Strategy();
st.addAlgorithm(MassAbsorptionCoefficient.class, mac);
return st;
}