From b0c0698e5503c2506217117bf144fde31e6f6601 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Fri, 25 Apr 2014 19:38:16 +0100 Subject: Commented lots of packages. --- src/jcgp/gui/settings/parameters/GUIBooleanParameter.java | 3 ++- src/jcgp/gui/settings/parameters/GUIDoubleParameter.java | 7 +++++-- src/jcgp/gui/settings/parameters/GUIIntegerParameter.java | 6 ++++-- src/jcgp/gui/settings/parameters/GUIParameter.java | 4 +--- 4 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src/jcgp/gui/settings/parameters') diff --git a/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java b/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java index e708c53..cc7113d 100644 --- a/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java @@ -62,7 +62,8 @@ public class GUIBooleanParameter extends GUIParameter { checkBox.setStyle(BASE_CHECKBOX_STYLE + INVALID_PARAMETER_STYLE); checkBox.setTooltip(tooltip); tooltip.setText(parameter.getStatus().getDetails()); - } else if (parameter.getStatus() == ParameterStatus.WARNING || parameter.getStatus() == ParameterStatus.WARNING_RESET) { + } else if (parameter.getStatus() == ParameterStatus.WARNING + || parameter.getStatus() == ParameterStatus.WARNING_RESET) { checkBox.setStyle(BASE_CHECKBOX_STYLE + WARNING_PARAMETER_STYLE); checkBox.setTooltip(tooltip); tooltip.setText(parameter.getStatus().getDetails()); diff --git a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java index f177ffa..777e739 100644 --- a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java @@ -36,6 +36,7 @@ public class GUIDoubleParameter extends GUIParameter { @Override protected Control makeControl() { + // we use a text field, and a formatting class to enforce decimals decimalFormat = new DecimalFormat(); decimalFormat.setMaximumFractionDigits(10); textField = new TextField(decimalFormat.format(parameter.get().doubleValue())); @@ -48,14 +49,16 @@ public class GUIDoubleParameter extends GUIParameter { @Override protected void setControlListeners() { /* pass the TextField value back to the parameter whenever it gets - * modified, provided it is not empty and the experiment isn't running */ + * modified, provided it is not empty, the experiment isn't running + * and it matches the double-precision regex filter */ textField.textProperty().addListener(new ChangeListener() { @Override public void changed( ObservableValue observable, String oldValue, String newValue) { if (!settingsPane.isExperimentRunning()) { - if (newValue.matches("([0-9]*[.]*[0-9]*)")) { + //if (newValue.matches("([0-9]*[.]?[0-9]*)")) { + if (newValue.matches("^[-+]?[0-9]*\\.?[0-9]+$")) { if (!newValue.isEmpty()) { double value = Double.parseDouble(newValue); parameter.set(value); diff --git a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java index e1b0b75..6e8b3f1 100644 --- a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java @@ -33,6 +33,7 @@ public class GUIIntegerParameter extends GUIParameter { @Override protected Control makeControl() { + // this uses a text field textField = new TextField(String.valueOf(parameter.get())); textField.setStyle(VALID_PARAMETER_STYLE); textField.setAlignment(Pos.CENTER_RIGHT); @@ -44,7 +45,8 @@ public class GUIIntegerParameter extends GUIParameter { @Override protected void setControlListeners() { /* pass the TextField value back to the parameter whenever it gets - * modified, provided it is not empty and the experiment isn't running */ + * modified, provided it is not empty, the experiment isn't running + * and it matches the integer regex pattern */ textField.textProperty().addListener(new ChangeListener() { @Override public void changed( @@ -98,7 +100,7 @@ public class GUIIntegerParameter extends GUIParameter { @Override public void refreshValue() { if (!textField.isFocused()) { - textField.setText(String.valueOf(parameter.get())); + textField.setText(parameter.get().toString()); } } } diff --git a/src/jcgp/gui/settings/parameters/GUIParameter.java b/src/jcgp/gui/settings/parameters/GUIParameter.java index 79762ff..b675fb5 100644 --- a/src/jcgp/gui/settings/parameters/GUIParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIParameter.java @@ -30,9 +30,8 @@ import jcgp.gui.settings.SettingsPane; * Monitor parameters have their Control disabled so that no changed can be made via the GUI. * Non-monitor parameters are updated automatically as well, but may be changed by the user * if the program is not evolving. - *

- * For more information on how parameters work in JCGP, see {@link Parameter}. * + * @see Parameter * @author Eduardo Pedroni * @param the parameter data type */ @@ -174,7 +173,6 @@ public abstract class GUIParameter extends HBox { */ public void validate() { parameter.validate(parameter.get()); - //refreshValue(); setValidityStyle(); } -- cgit v1.2.3