Class ControllerUtil

java.lang.Object
es.upm.fi.cig.multictbnc.util.ControllerUtil

public final class ControllerUtil extends Object
Utility class with methods related to controlling the UI behaviour.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    extractDecimal(String text, double defaultValue)
    Receives an String and tries to convert it to a double.
    static int
    extractInteger(String text, int defaultValue)
    Receives an String and tries to convert it to an Integer.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • extractDecimal

      public static double extractDecimal(String text, double defaultValue)
      Receives an String and tries to convert it to a double. If it is not possible, the provided default value is returned.
      Parameters:
      text - String from which the double is extracted
      defaultValue - default value
      Returns:
      extracted double
    • extractInteger

      public static int extractInteger(String text, int defaultValue)
      Receives an String and tries to convert it to an Integer. If it is not possible, the provided default value is returned.
      Parameters:
      text - String from which the Integer is extracted
      defaultValue - 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 changed
      show - true to show the node, otherwise false