Search in sources :

Example 26 with DoubleTextField

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;
}
Also used : DoubleTextField(edu.cmu.tetradapp.util.DoubleTextField) DecimalFormat(java.text.DecimalFormat)

Aggregations

DoubleTextField (edu.cmu.tetradapp.util.DoubleTextField)26 ActionEvent (java.awt.event.ActionEvent)10 ActionListener (java.awt.event.ActionListener)10 DecimalFormat (java.text.DecimalFormat)7 IntTextField (edu.cmu.tetradapp.util.IntTextField)6 ArrayList (java.util.ArrayList)6 Parameters (edu.cmu.tetrad.util.Parameters)5 DataModel (edu.cmu.tetrad.data.DataModel)4 Node (edu.cmu.tetrad.graph.Node)4 DataWrapper (edu.cmu.tetradapp.model.DataWrapper)4 List (java.util.List)4 EmptyBorder (javax.swing.border.EmptyBorder)4 MatteBorder (javax.swing.border.MatteBorder)4 TitledBorder (javax.swing.border.TitledBorder)4 DataSet (edu.cmu.tetrad.data.DataSet)3 Graph (edu.cmu.tetrad.graph.Graph)3 DagWrapper (edu.cmu.tetradapp.model.DagWrapper)3 GraphWrapper (edu.cmu.tetradapp.model.GraphWrapper)3 SemGraphWrapper (edu.cmu.tetradapp.model.SemGraphWrapper)3 Iterator (java.util.Iterator)3