use of edu.cmu.tetradapp.util.DoubleTextField in project tetrad by cmu-phil.
the class AlgorithmParameterPanel method getDoubleField.
private DoubleTextField getDoubleField(final String parameter, final Parameters parameters, double defaultValue, final double lowerBound, final double upperBound) {
final DoubleTextField field = new DoubleTextField(parameters.getDouble(parameter, defaultValue), 8, new DecimalFormat("0.####"), new DecimalFormat("0.0#E0"), 0.001);
field.setFilter((value, oldValue) -> {
if (value == field.getValue()) {
return oldValue;
}
if (value < lowerBound) {
return oldValue;
}
if (value > upperBound) {
return oldValue;
}
try {
parameters.set(parameter, value);
} catch (Exception e) {
// Ignore.
}
return value;
});
return field;
}
Aggregations