Class ProgressionUtil


  • public final class ProgressionUtil
    extends Object
    Utilities around task progression.
    Version:
    17.0 2020-01-04 14:41:38
    Author:
    Stéphane GALLAND
    Maven Group Id:
    org.arakhne.afc.core
    Maven Artifact Id:
    util
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void advance​(Progression model)
      Increment the value of the given task progression, if not null, by 1.
      static void advance​(Progression model, int value)
      Increment the value of the given task progression, if not null, by the given amount.
      static void advance​(Progression model, int value, String comment)
      Increment the value of the given task progression, if not null, by the given amount.
      static void advance​(Progression model, String comment)
      Increment the value of the given task progression, if not null, by 1.
      static void end​(Progression model)
      Force the given task progression, if not null, to have its value equals to the maximal value.
      static void ensureNoSubTask​(Progression model)
      Ensure that there is no opened subtask.
      static double getPercent​(Progression model)
      Replies the percent of progression for the given task progression, if not null.
      static int getValue​(Progression model)
      Replies the value of the given task progression, if not null.
      static int getValueToEnd​(Progression model)
      Replies the value from the current progression value to the maximal progression value of the given task progression, if not null.
      static void init​(Progression model, int min, int max)
      Initialize the given task progression if not null.
      static void init​(Progression model, int min, int max, boolean isAdjusting)
      Initialize the given task progression if not null.
      static void init​(Progression model, int min, int max, boolean isAdjusting, String comment)
      Initialize the given task progression if not null.
      static void init​(Progression model, int value, int min, int max, boolean isAdjusting, boolean isInderterminate)
      Initialize the given task progression if not null.
      static void init​(Progression model, int value, int min, int max, boolean isAdjusting, boolean isInderterminate, String comment)
      Initialize the given task progression if not null.
      static void init​(Progression model, int min, int max, String comment)
      Initialize the given task progression if not null.
      static boolean isMinValue​(Progression model)
      Replies if the given progression indicators has its value equal to its min value.
      static void setValue​(Progression model, int value)
      Set the value of the given task progression, if not null.
      static void setValue​(Progression model, int value, String comment)
      Set the value of the given task progression, if not null.
      static Progression sub​(Progression model, int extent)
      Create and replies a task progression model that is for a subtask of the task associated to the given progression model.
      static Progression sub​(Progression model, int extent, boolean overwriteComment)
      Create and replies a task progression model that is for a subtask of the task associated to the given progression model.
      static Progression subToEnd​(Progression model)
      Create and replies a task progression model that is for a subtask of the task associated to the given progression model.
      static Progression subToEnd​(Progression model, boolean overwriteComment)
      Create and replies a task progression model that is for a subtask of the task associated to the given progression model.
    • Method Detail

      • init

        public static void init​(Progression model,
                                int value,
                                int min,
                                int max,
                                boolean isAdjusting,
                                boolean isInderterminate)
        Initialize the given task progression if not null.
        Parameters:
        model - is the task progression to initialize.
        value - is the progression value.
        min - is the minimum value.
        max - is the maximum value.
        isAdjusting - indicates if the value is still under changes.
        isInderterminate - indicates if the progression value is inderterminate or not.
      • init

        public static void init​(Progression model,
                                int min,
                                int max,
                                boolean isAdjusting)
        Initialize the given task progression if not null.

        The inderterminate state is not changed.

        Parameters:
        model - is the task progression to initialize.
        min - is the minimum value.
        max - is the maximum value.
        isAdjusting - indicates if the value is still under changes.
      • init

        public static void init​(Progression model,
                                int min,
                                int max)
        Initialize the given task progression if not null.

        The inderterminate state is not changed. The adjusting state is set to false.

        Parameters:
        model - is the task progression to initialize.
        min - is the minimum value.
        max - is the maximum value.
      • init

        public static void init​(Progression model,
                                int value,
                                int min,
                                int max,
                                boolean isAdjusting,
                                boolean isInderterminate,
                                String comment)
        Initialize the given task progression if not null.
        Parameters:
        model - is the task progression to initialize.
        value - is the progression value.
        min - is the minimum value.
        max - is the maximum value.
        isAdjusting - indicates if the value is still under changes.
        isInderterminate - indicates if the progression value is inderterminate or not
        comment - is the text associated with the progression.
      • init

        public static void init​(Progression model,
                                int min,
                                int max,
                                boolean isAdjusting,
                                String comment)
        Initialize the given task progression if not null.

        The inderterminate state is not changed.

        Parameters:
        model - is the task progression to initialize.
        min - is the minimum value.
        max - is the maximum value.
        isAdjusting - indicates if the value is still under changes.
        comment - is the text associated with the progression.
      • init

        public static void init​(Progression model,
                                int min,
                                int max,
                                String comment)
        Initialize the given task progression if not null.

        The inderterminate state is not changed. The adjusting state is set to false.

        Parameters:
        model - is the task progression to initialize.
        min - is the minimum value.
        max - is the maximum value.
        comment - is the text associated with the progression.
      • sub

        public static Progression sub​(Progression model,
                                      int extent)
        Create and replies a task progression model that is for a subtask of the task associated to the given progression model.

        The subtask progression model is not initialized. When the subtask progression model reaches its end, the value of the task progression is s + extent where s is the value of the task progression when this function is called.

        Parameters:
        model - is the model to derivate
        extent - is the size of the subtask progression that is covered in the task progression.
        Returns:
        the subtask progression model; or null.
      • sub

        public static Progression sub​(Progression model,
                                      int extent,
                                      boolean overwriteComment)
        Create and replies a task progression model that is for a subtask of the task associated to the given progression model.

        The subtask progression model is not initialized. When the subtask progression model reaches its end, the value of the task progression is s + extent where s is the value of the task progression when this function is called.

        Parameters:
        model - is the model to derivate
        extent - is the size of the subtask progression that is covered in the task progression.
        overwriteComment - indicates if the comment of this task model may be overwritten by the comment of the subtask when it is disconnected.
        Returns:
        the subtask progression model; or null.
      • subToEnd

        public static Progression subToEnd​(Progression model)
        Create and replies a task progression model that is for a subtask of the task associated to the given progression model.

        The subtask progression model is not initialized. When the subtask progression model reaches its end, the value of the task progression is equal to the maximum.

        Parameters:
        model - is the model to derivate
        Returns:
        the subtask progression model; or null.
      • subToEnd

        public static Progression subToEnd​(Progression model,
                                           boolean overwriteComment)
        Create and replies a task progression model that is for a subtask of the task associated to the given progression model.

        The subtask progression model is not initialized. When the subtask progression model reaches its end, the value of the task progression is equal to the maximum.

        Parameters:
        model - is the model to derivate
        overwriteComment - indicates if the comment of this task model may be overwritten by the comment of the subtask when it is disconnected.
        Returns:
        the subtask progression model; or null.
      • advance

        public static void advance​(Progression model,
                                   int value)
        Increment the value of the given task progression, if not null, by the given amount.
        Parameters:
        model - is the progression to change
        value - is the value to add to the progression value.
      • advance

        public static void advance​(Progression model)
        Increment the value of the given task progression, if not null, by 1.
        Parameters:
        model - is the progression to change
      • advance

        public static void advance​(Progression model,
                                   int value,
                                   String comment)
        Increment the value of the given task progression, if not null, by the given amount.
        Parameters:
        model - is the progression to change
        value - is the value to add to the progression value.
        comment - is the comment associated to the progression.
      • advance

        public static void advance​(Progression model,
                                   String comment)
        Increment the value of the given task progression, if not null, by 1.
        Parameters:
        model - is the progression to change
        comment - is the comment associated to the progression.
      • getValue

        public static int getValue​(Progression model)
        Replies the value of the given task progression, if not null.
        Parameters:
        model - is the progression to change
        Returns:
        the value or 0 if there is no progession model.
      • getValueToEnd

        public static int getValueToEnd​(Progression model)
        Replies the value from the current progression value to the maximal progression value of the given task progression, if not null.
        Parameters:
        model - is the progression to change
        Returns:
        the positive value to end or 0 if there is no progession model.
      • getPercent

        public static double getPercent​(Progression model)
        Replies the percent of progression for the given task progression, if not null.
        Parameters:
        model - is the progression to change
        Returns:
        the percent of progress or Double.NaN if there is no progession model.
      • setValue

        public static void setValue​(Progression model,
                                    int value)
        Set the value of the given task progression, if not null. The value must be greater than the current progression value.
        Parameters:
        model - is the progression to change
        value - is the value to add to the progression value.
      • setValue

        public static void setValue​(Progression model,
                                    int value,
                                    String comment)
        Set the value of the given task progression, if not null. The value must be greater than the current progression value.
        Parameters:
        model - is the progression to change
        value - is the value to add to the progression value.
        comment - is the comment associated to the progression.
      • end

        public static void end​(Progression model)
        Force the given task progression, if not null, to have its value equals to the maximal value.

        The inderterminate and adjusting states are not changed. The comment is reset.

        Parameters:
        model - is the task progression to initialize.
      • ensureNoSubTask

        public static void ensureNoSubTask​(Progression model)
        Ensure that there is no opened subtask. If a subtask is existing, it is ended().
        Parameters:
        model - is the task progression to initialize.
      • isMinValue

        public static boolean isMinValue​(Progression model)
        Replies if the given progression indicators has its value equal to its min value.
        Parameters:
        model - is the task progression to initialize.
        Returns:
        true if the indicator is at its min value or if model is null.