From e145523a2ae686dd2a2ae7996639e6e8d14d992a Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Fri, 10 Oct 2014 13:22:16 +0200 Subject: Moved constants to a separate file, added a formal README --- src/jcgp/gui/settings/parameters/GUIBooleanParameter.java | 7 ++++--- src/jcgp/gui/settings/parameters/GUIDoubleParameter.java | 9 +++++---- src/jcgp/gui/settings/parameters/GUIIntegerParameter.java | 9 +++++---- src/jcgp/gui/settings/parameters/GUIParameter.java | 8 -------- 4 files changed, 14 insertions(+), 19 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 a13a52b..a1f03fe 100644 --- a/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java @@ -6,6 +6,7 @@ import javafx.scene.control.CheckBox; import javafx.scene.control.Control; import jcgp.backend.parameters.BooleanParameter; import jcgp.backend.parameters.ParameterStatus; +import jcgp.gui.constants.Constants; import jcgp.gui.settings.SettingsPane; /** @@ -59,16 +60,16 @@ public class GUIBooleanParameter extends GUIParameter { protected void setValidityStyle() { // update the Control's style and tooltip based on the status of the parameter if (parameter.getStatus() == ParameterStatus.INVALID) { - checkBox.setStyle(BASE_CHECKBOX_STYLE + INVALID_PARAMETER_STYLE); + checkBox.setStyle(Constants.BASE_CHECKBOX_STYLE + Constants.INVALID_PARAMETER_STYLE); checkBox.setTooltip(tooltip); tooltip.setText(parameter.getStatus().getDetails()); } else if (parameter.getStatus() == ParameterStatus.WARNING || parameter.getStatus() == ParameterStatus.WARNING_RESET) { - checkBox.setStyle(BASE_CHECKBOX_STYLE + WARNING_PARAMETER_STYLE); + checkBox.setStyle(Constants.BASE_CHECKBOX_STYLE + Constants.WARNING_PARAMETER_STYLE); checkBox.setTooltip(tooltip); tooltip.setText(parameter.getStatus().getDetails()); } else { - checkBox.setStyle(BASE_CHECKBOX_STYLE + VALID_PARAMETER_STYLE); + checkBox.setStyle(Constants.BASE_CHECKBOX_STYLE + Constants.VALID_PARAMETER_STYLE); checkBox.setTooltip(null); } } diff --git a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java index 9f4ea28..feee34c 100644 --- a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java @@ -9,6 +9,7 @@ import javafx.scene.control.Control; import javafx.scene.control.TextField; import jcgp.backend.parameters.DoubleParameter; import jcgp.backend.parameters.ParameterStatus; +import jcgp.gui.constants.Constants; import jcgp.gui.settings.SettingsPane; /** @@ -40,7 +41,7 @@ public class GUIDoubleParameter extends GUIParameter { decimalFormat = new DecimalFormat(); decimalFormat.setMaximumFractionDigits(10); textField = new TextField(decimalFormat.format(parameter.get().doubleValue())); - textField.setStyle(VALID_PARAMETER_STYLE); + textField.setStyle(Constants.VALID_PARAMETER_STYLE); textField.setAlignment(Pos.CENTER_RIGHT); textField.prefWidthProperty().bind(widthProperty().divide(2)); return textField; @@ -87,15 +88,15 @@ public class GUIDoubleParameter extends GUIParameter { protected void setValidityStyle() { // update the Control's style and tooltip based on the status of the parameter if (parameter.getStatus() == ParameterStatus.INVALID) { - textField.setStyle(BASE_TEXT_STYLE + INVALID_PARAMETER_STYLE); + textField.setStyle(Constants.BASE_TEXT_STYLE + Constants.INVALID_PARAMETER_STYLE); textField.setTooltip(tooltip); tooltip.setText(parameter.getStatus().getDetails()); } else if (parameter.getStatus() == ParameterStatus.WARNING || parameter.getStatus() == ParameterStatus.WARNING_RESET) { - textField.setStyle(BASE_TEXT_STYLE + WARNING_PARAMETER_STYLE); + textField.setStyle(Constants.BASE_TEXT_STYLE + Constants.WARNING_PARAMETER_STYLE); textField.setTooltip(tooltip); tooltip.setText(parameter.getStatus().getDetails()); } else { - textField.setStyle(BASE_TEXT_STYLE + VALID_PARAMETER_STYLE); + textField.setStyle(Constants.BASE_TEXT_STYLE + Constants.VALID_PARAMETER_STYLE); textField.setTooltip(null); } } diff --git a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java index d36c1b3..bcfbe50 100644 --- a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java @@ -7,6 +7,7 @@ import javafx.scene.control.Control; import javafx.scene.control.TextField; import jcgp.backend.parameters.IntegerParameter; import jcgp.backend.parameters.ParameterStatus; +import jcgp.gui.constants.Constants; import jcgp.gui.settings.SettingsPane; /** @@ -35,7 +36,7 @@ public class GUIIntegerParameter extends GUIParameter { protected Control makeControl() { // this uses a text field textField = new TextField(String.valueOf(parameter.get())); - textField.setStyle(VALID_PARAMETER_STYLE); + textField.setStyle(Constants.VALID_PARAMETER_STYLE); textField.setAlignment(Pos.CENTER_RIGHT); textField.prefWidthProperty().bind(widthProperty().divide(2)); @@ -83,16 +84,16 @@ public class GUIIntegerParameter extends GUIParameter { protected void setValidityStyle() { // update the Control's style and tooltip based on the status of the parameter if (parameter.getStatus() == ParameterStatus.INVALID) { - textField.setStyle(BASE_TEXT_STYLE + INVALID_PARAMETER_STYLE); + textField.setStyle(Constants.BASE_TEXT_STYLE + Constants.INVALID_PARAMETER_STYLE); textField.setTooltip(tooltip); tooltip.setText(parameter.getStatus().getDetails()); } else if (parameter.getStatus() == ParameterStatus.WARNING || parameter.getStatus() == ParameterStatus.WARNING_RESET) { - textField.setStyle(BASE_TEXT_STYLE + WARNING_PARAMETER_STYLE); + textField.setStyle(Constants.BASE_TEXT_STYLE + Constants.WARNING_PARAMETER_STYLE); textField.setTooltip(tooltip); tooltip.setText(parameter.getStatus().getDetails()); } else { - textField.setStyle(BASE_TEXT_STYLE + VALID_PARAMETER_STYLE); + textField.setStyle(Constants.BASE_TEXT_STYLE + Constants.VALID_PARAMETER_STYLE); textField.setTooltip(null); } } diff --git a/src/jcgp/gui/settings/parameters/GUIParameter.java b/src/jcgp/gui/settings/parameters/GUIParameter.java index 9188aec..59aecf6 100644 --- a/src/jcgp/gui/settings/parameters/GUIParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIParameter.java @@ -15,7 +15,6 @@ import jcgp.backend.parameters.DoubleParameter; import jcgp.backend.parameters.IntegerParameter; import jcgp.backend.parameters.Parameter; import jcgp.backend.parameters.ParameterStatus; -import jcgp.gui.GUI; import jcgp.gui.settings.SettingsPane; /** @@ -39,13 +38,6 @@ import jcgp.gui.settings.SettingsPane; */ public abstract class GUIParameter extends HBox { - public static final String BASE_TEXT_STYLE = "-fx-border-color: #C9C9C9; -fx-border-radius: 2; -fx-padding: 0; "; - public static final String BASE_CHECKBOX_STYLE = "-fx-padding: 0; "; - - public static final String INVALID_PARAMETER_STYLE = "-fx-background-color: " + GUI.BAD_SELECTION_COLOUR; - public static final String WARNING_PARAMETER_STYLE = "-fx-background-color: " + GUI.NEUTRAL_SELECTION_COLOUR; - public static final String VALID_PARAMETER_STYLE = "-fx-background-color: " + GUI.NEUTRAL_COLOUR; - private Label name; private Control valueControl; -- cgit v1.2.3