java.lang.Object
es.upm.fi.cig.multictbnc.util.ControllerUtil
Utility class with methods related to controlling the UI behaviour.
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
extractDecimal
(String text, double defaultValue) Receives anString
and tries to convert it to adouble
.static int
extractInteger
(String text, int defaultValue) Receives anString
and tries to convert it to anInteger
.static void
onlyPositiveDouble
(javafx.scene.control.TextField textField) Checks that the text field only contains positive decimals.static void
onlyPositiveInteger
(javafx.scene.control.TextField textField) Checks that the text field only contains positive integers.static void
onlyZeroOrGreaterInteger
(javafx.scene.control.TextField textField) Checks that the text field only contains integers greater than zero.static void
showNode
(javafx.scene.Node node, boolean show) Changes the visibility of a node.
-
Method Details
-
extractDecimal
Receives anString
and tries to convert it to adouble
. If it is not possible, the provided default value is returned.- Parameters:
text
-String
from which thedouble
is extracteddefaultValue
- default value- Returns:
- extracted
double
-
extractInteger
Receives anString
and tries to convert it to anInteger
. If it is not possible, the provided default value is returned.- Parameters:
text
-String
from which theInteger
is extracteddefaultValue
- default value- Returns:
- extracted
Integer
-
onlyPositiveDouble
public static void onlyPositiveDouble(javafx.scene.control.TextField textField) Checks that the text field only contains positive decimals.- Parameters:
textField
- text field
-
onlyPositiveInteger
public static void onlyPositiveInteger(javafx.scene.control.TextField textField) Checks that the text field only contains positive integers.- Parameters:
textField
- text field
-
onlyZeroOrGreaterInteger
public static void onlyZeroOrGreaterInteger(javafx.scene.control.TextField textField) Checks that the text field only contains integers greater than zero.- Parameters:
textField
- text field
-
showNode
public static void showNode(javafx.scene.Node node, boolean show) Changes the visibility of a node.- Parameters:
node
- node whose status is changedshow
- true to show the node, otherwise false
-