From e6dd7711c7dad5e000445208eb5845801f4ccffc Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sun, 6 Apr 2014 21:58:53 +0100 Subject: About to make big changes to the way fitness works, committing just in case --- .../gui/settings/parameters/GUIBooleanParameter.java | 11 +++++------ .../gui/settings/parameters/GUIDoubleParameter.java | 17 +++++++++-------- .../gui/settings/parameters/GUIIntegerParameter.java | 17 +++++++++-------- src/jcgp/gui/settings/parameters/GUIParameter.java | 18 +++++++++++++----- 4 files changed, 36 insertions(+), 27 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 fc66e7d..4339562 100644 --- a/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java @@ -3,9 +3,8 @@ package jcgp.gui.settings.parameters; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.scene.control.CheckBox; -import jcgp.backend.parameters.BooleanParameter; -import jcgp.backend.parameters.ParameterStatus; -import jcgp.gui.GUI; +import jcgp.backend.resources.parameters.BooleanParameter; +import jcgp.backend.resources.parameters.ParameterStatus; import jcgp.gui.settings.SettingsPane; public class GUIBooleanParameter extends GUIParameter { @@ -65,15 +64,15 @@ public class GUIBooleanParameter extends GUIParameter { */ private void setValidityStyle() { if (parameter.getStatus() == ParameterStatus.INVALID) { - valueControl.setStyle(GUI.INVALID_PARAMETER_STYLE); + valueControl.setStyle(BASE_CHECKBOX_STYLE + INVALID_PARAMETER_STYLE); valueControl.setTooltip(tooltip); tooltip.setText(parameter.getStatus().getDetails()); } else if (parameter.getStatus() == ParameterStatus.WARNING || parameter.getStatus() == ParameterStatus.WARNING_RESET) { - valueControl.setStyle(GUI.WARNING_PARAMETER_STYLE); + valueControl.setStyle(BASE_CHECKBOX_STYLE + WARNING_PARAMETER_STYLE); valueControl.setTooltip(tooltip); tooltip.setText(parameter.getStatus().getDetails()); } else { - valueControl.setStyle(GUI.VALID_PARAMETER_STYLE); + valueControl.setStyle(BASE_CHECKBOX_STYLE + VALID_PARAMETER_STYLE); valueControl.setTooltip(null); } } diff --git a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java index 190f4b7..eecff2d 100644 --- a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java @@ -8,9 +8,8 @@ import javafx.scene.control.TextField; import javafx.scene.input.KeyEvent; import javafx.scene.layout.Priority; import javafx.scene.text.Text; -import jcgp.backend.parameters.DoubleParameter; -import jcgp.backend.parameters.ParameterStatus; -import jcgp.gui.GUI; +import jcgp.backend.resources.parameters.DoubleParameter; +import jcgp.backend.resources.parameters.ParameterStatus; import jcgp.gui.settings.SettingsPane; public class GUIDoubleParameter extends GUIParameter { @@ -26,13 +25,14 @@ public class GUIDoubleParameter extends GUIParameter { name = new Text(parameter.getName()); valueControl = new TextField(String.valueOf(parameter.get())); - valueControl.setStyle(GUI.VALID_PARAMETER_STYLE); + valueControl.setStyle(VALID_PARAMETER_STYLE); ((TextField) valueControl).setAlignment(Pos.CENTER_RIGHT); setHgrow(valueControl, Priority.ALWAYS); + setHgrow(name, Priority.ALWAYS); - name.setWrappingWidth(GUI.WRAP_WIDTH); + name.wrappingWidthProperty().bind(widthProperty().divide(2)); ((TextField) valueControl).setEditable(!parameter.isMonitor()); @@ -41,6 +41,7 @@ public class GUIDoubleParameter extends GUIParameter { makeLightBinding(); } else { valueControl.addEventFilter(KeyEvent.KEY_TYPED, new EventHandler() { + @Override public void handle( KeyEvent t ) { char ch = t.getCharacter().toCharArray()[t.getCharacter().toCharArray().length - 1]; if (!((ch >= '0' && ch <= '9') || (ch == '.' && !((TextField) valueControl).getText().contains(".")))) { @@ -101,15 +102,15 @@ public class GUIDoubleParameter extends GUIParameter { private void setValidityStyle() { if (parameter.getStatus() == ParameterStatus.INVALID) { - valueControl.setStyle(GUI.INVALID_PARAMETER_STYLE); + valueControl.setStyle(BASE_TEXT_STYLE + INVALID_PARAMETER_STYLE); valueControl.setTooltip(tooltip); tooltip.setText(parameter.getStatus().getDetails()); } else if (parameter.getStatus() == ParameterStatus.WARNING || parameter.getStatus() == ParameterStatus.WARNING_RESET) { - valueControl.setStyle(GUI.WARNING_PARAMETER_STYLE); + valueControl.setStyle(BASE_TEXT_STYLE + WARNING_PARAMETER_STYLE); valueControl.setTooltip(tooltip); tooltip.setText(parameter.getStatus().getDetails()); } else { - valueControl.setStyle(GUI.VALID_PARAMETER_STYLE); + valueControl.setStyle(BASE_TEXT_STYLE + VALID_PARAMETER_STYLE); valueControl.setTooltip(null); } } diff --git a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java index a2040d7..9c84c6a 100644 --- a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java @@ -8,9 +8,8 @@ import javafx.scene.control.TextField; import javafx.scene.input.KeyEvent; import javafx.scene.layout.Priority; import javafx.scene.text.Text; -import jcgp.backend.parameters.IntegerParameter; -import jcgp.backend.parameters.ParameterStatus; -import jcgp.gui.GUI; +import jcgp.backend.resources.parameters.IntegerParameter; +import jcgp.backend.resources.parameters.ParameterStatus; import jcgp.gui.settings.SettingsPane; public class GUIIntegerParameter extends GUIParameter { @@ -26,13 +25,14 @@ public class GUIIntegerParameter extends GUIParameter { name = new Text(parameter.getName()); valueControl = new TextField(String.valueOf(parameter.get())); - valueControl.setStyle(GUI.VALID_PARAMETER_STYLE); + valueControl.setStyle(VALID_PARAMETER_STYLE); ((TextField) valueControl).setAlignment(Pos.CENTER_RIGHT); setHgrow(valueControl, Priority.ALWAYS); + setHgrow(name, Priority.ALWAYS); - name.setWrappingWidth(GUI.WRAP_WIDTH); + name.wrappingWidthProperty().bind(widthProperty().divide(2)); ((TextField) valueControl).setEditable(!parameter.isMonitor()); @@ -41,6 +41,7 @@ public class GUIIntegerParameter extends GUIParameter { makeLightBinding(); } else { valueControl.addEventFilter(KeyEvent.KEY_TYPED, new EventHandler() { + @Override public void handle( KeyEvent t ) { char ch = t.getCharacter().toCharArray()[t.getCharacter().toCharArray().length - 1]; if (!(ch >= '0' && ch <= '9')) { @@ -101,15 +102,15 @@ public class GUIIntegerParameter extends GUIParameter { private void setValidityStyle() { if (parameter.getStatus() == ParameterStatus.INVALID) { - valueControl.setStyle(GUI.INVALID_PARAMETER_STYLE); + valueControl.setStyle(BASE_TEXT_STYLE + INVALID_PARAMETER_STYLE); valueControl.setTooltip(tooltip); tooltip.setText(parameter.getStatus().getDetails()); } else if (parameter.getStatus() == ParameterStatus.WARNING || parameter.getStatus() == ParameterStatus.WARNING_RESET) { - valueControl.setStyle(GUI.WARNING_PARAMETER_STYLE); + valueControl.setStyle(BASE_TEXT_STYLE + WARNING_PARAMETER_STYLE); valueControl.setTooltip(tooltip); tooltip.setText(parameter.getStatus().getDetails()); } else { - valueControl.setStyle(GUI.VALID_PARAMETER_STYLE); + valueControl.setStyle(BASE_TEXT_STYLE + VALID_PARAMETER_STYLE); valueControl.setTooltip(null); } } diff --git a/src/jcgp/gui/settings/parameters/GUIParameter.java b/src/jcgp/gui/settings/parameters/GUIParameter.java index da2fe86..6bfdf30 100644 --- a/src/jcgp/gui/settings/parameters/GUIParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIParameter.java @@ -10,14 +10,22 @@ import javafx.scene.control.Control; import javafx.scene.control.Tooltip; import javafx.scene.layout.HBox; import javafx.scene.text.Text; -import jcgp.backend.parameters.BooleanParameter; -import jcgp.backend.parameters.DoubleParameter; -import jcgp.backend.parameters.IntegerParameter; -import jcgp.backend.parameters.Parameter; -import jcgp.backend.parameters.ParameterStatus; +import jcgp.backend.resources.parameters.BooleanParameter; +import jcgp.backend.resources.parameters.DoubleParameter; +import jcgp.backend.resources.parameters.IntegerParameter; +import jcgp.backend.resources.parameters.Parameter; +import jcgp.backend.resources.parameters.ParameterStatus; +import jcgp.gui.GUI; 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; protected Parameter parameter; protected Text name; -- cgit v1.2.3