for (Leaf leaf: tree.getRoot().getAllLeaves()) {
Transformer t = leaf.getTransformer();
if (t instanceof NumericTransformer) {
// calculate min, max
// set min,max
NumericTransformer nt = (NumericTransformer) t;
// A very specific assumption: the lower the better (!)
// obviously often not true, e.g. for format/numberOfTools
double min = Long.MAX_VALUE;
double max = Long.MIN_VALUE;
for (Alternative a : alternativesDefinition.getConsideredAlternatives()) {
for (Value v: leaf.getValues(a.getName()).getList()) {
INumericValue value = (INumericValue) v;
if (value.value() > max) {
max = value.value();
}
if (value.value() < min) {
min = value.value();
}
}
}
nt.defaults(min,max);
nt.setMode(TransformationMode.LINEAR);
} else {
OrdinalTransformer ot = (OrdinalTransformer) t;
if (leaf.getScale() instanceof BooleanScale) {
ot.getMapping().put("Yes", new TargetValueObject(5));