Class DefaultProgression

  • All Implemented Interfaces:
    Progression
    Direct Known Subclasses:
    SubProgressionModel

    public class DefaultProgression
    extends Object
    implements Progression
    An object that permits to indicates the progression of a task. The progression of the value is always ascendent.
    Version:
    17.0 2020-01-04 14:41:38
    Author:
    Stéphane GALLAND
    Maven Group Id:
    org.arakhne.afc.core
    Maven Artifact Id:
    util
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultProgression()
      Create a progress model in a indeterminate state.
      DefaultProgression​(int min, int max)
      Create a progress model with the specified indeterminate state.
      DefaultProgression​(int value, int min, int max)
      Create a progress model with the specified determinate state.
      DefaultProgression​(int value, int min, int max, boolean adjusting)
      Create a progress model with the specified determinate state.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addProgressionListener​(ProgressionListener listener)
      Add a listener on this model.
      (package private) void disconnectSubTask​(SubProgressionModel subTask, double value, boolean overwriteComment)
      Set the parent value and disconnect this subtask from its parent.
      void end()
      Force this progression task to end its indicator.
      void ensureNoSubTask()
      Ensure that there is no opened subtask.
      protected void fireStateChange()
      Notify listeners about state change.
      protected void fireValueChange()
      Notify listeners about value change.
      String getComment()
      Replies the comment associated to the currect task.
      protected double getFloatValue()
      Replies the floating-point precision value.
      int getMaximum()
      Returns the model's maximum.
      int getMinimum()
      Returns the minimum acceptable value.
      double getPercent()
      Returns the model's current value in percent of pregression.
      double getProgressionFactor()
      Returns the model's current value in percent of pregression.
      Progression getSubTask()
      Replies the current subtask of this task model.
      Progression getSuperTask()
      Replies the super task of this task model.
      int getTaskDepth()
      Replies the depth level of this task.
      int getValue()
      Returns the model's current value.
      void increment()
      Increment the current value by 1.
      void increment​(int amount)
      Increment the current value by the given amount.
      void increment​(int amount, String comment)
      Increment the current value by the given amount.
      void increment​(String comment)
      Increment the current value by 1.
      boolean isAdjusting()
      Returns true if the current changes to the value property are part of a series of changes.
      boolean isIndeterminate()
      Returns the value of the indeterminate property.
      boolean isRootModel()
      Replies if is task model is a root model.
      void removeProgressionListener​(ProgressionListener listener)
      Remove a listener on this model.
      void setAdjusting​(boolean adjusting)
      This attribute indicates that any upcoming changes to the value of the model should be considered a single event.
      void setComment​(String comment)
      Set the comment associated to the currect task.
      void setIndeterminate​(boolean newValue)
      Sets the indeterminate property of the task progression, which determines whether the progression is in determinate or indeterminate mode.
      void setMaximum​(int newMaximum)
      Sets the model's maximum to newMaximum.
      void setMinimum​(int newMinimum)
      Sets the model's minimum to newMinimum.
      void setProperties​(int value, int min, int max, boolean adjusting)
      This method sets all of the model's data with a single method call.
      void setProperties​(int value, int min, int max, boolean adjusting, String comment)
      This method sets all of the model's data with a single method call.
      void setValue​(int newValue)
      Sets the model's current value to newValue if newValue satisfies the model's constraints.
      void setValue​(int newValue, String comment)
      Sets the model's current value to newValue if newValue satisfies the model's constraints.
      (package private) void setValue​(SubProgressionModel subTask, double newValue, String comment)
      Set the value with a float-point precision.
      Progression subTask​(int extent)
      Enter into a subtask.
      Progression subTask​(int extent, boolean overwriteComment)
      Enter into a subtask.
      Progression subTask​(int extent, int minValue, int maxValue)
      Enter into a subtask.
      Progression subTask​(int extent, int minValue, int maxValue, boolean overwriteComment)
      Enter into a subtask.
    • Constructor Detail

      • DefaultProgression

        public DefaultProgression​(int value,
                                  int min,
                                  int max,
                                  boolean adjusting)
        Create a progress model with the specified determinate state.
        Parameters:
        value - is the initial value of this model (between min and max).
        min - is the minimal value
        max - is the maximal value
        adjusting - indicates if this model is under adjustement or not.
      • DefaultProgression

        public DefaultProgression​(int value,
                                  int min,
                                  int max)
        Create a progress model with the specified determinate state. The model is not adjusting.
        Parameters:
        value - is the initial value of this model (between min and max).
        min - is the minimal value
        max - is the maximal value
      • DefaultProgression

        public DefaultProgression​(int min,
                                  int max)
        Create a progress model with the specified indeterminate state. The model is not adjusting.
        Parameters:
        min - is the minimal value
        max - is the maximal value
      • DefaultProgression

        public DefaultProgression()
        Create a progress model in a indeterminate state. The model is not adjusting.
    • Method Detail

      • end

        public void end()
        Description copied from interface: Progression
        Force this progression task to end its indicator.
        Specified by:
        end in interface Progression
      • isRootModel

        public boolean isRootModel()
        Description copied from interface: Progression
        Replies if is task model is a root model.

        isRootMode() == (getTaskDepth()==0)

        Specified by:
        isRootModel in interface Progression
        Returns:
        true if this model is a root model, otherwise false
      • getSuperTask

        public Progression getSuperTask()
        Description copied from interface: Progression
        Replies the super task of this task model.
        Specified by:
        getSuperTask in interface Progression
        Returns:
        the super task or null this task was not a decomposition of a super task.
      • getTaskDepth

        public int getTaskDepth()
        Description copied from interface: Progression
        Replies the depth level of this task. The root task (ie. a task without parent task) has always a depth of 0. A subtask of the root task has a depth of 1. A subtask of this subtask has a depth of 2, etc.

        isRootMode() == (getTaskDepth()==0)

        Specified by:
        getTaskDepth in interface Progression
        Returns:
        the depth of the task.
      • getSubTask

        public final Progression getSubTask()
        Description copied from interface: Progression
        Replies the current subtask of this task model.
        Specified by:
        getSubTask in interface Progression
        Returns:
        the current subtask or null this task was not decomposed.
      • ensureNoSubTask

        public final void ensureNoSubTask()
        Description copied from interface: Progression
        Ensure that there is no opened subtask. If a subtask is existing, it is ended().
        Specified by:
        ensureNoSubTask in interface Progression
      • fireStateChange

        protected void fireStateChange()
        Notify listeners about state change.
      • fireValueChange

        protected void fireValueChange()
        Notify listeners about value change.
      • getValue

        public int getValue()
        Description copied from interface: Progression
        Returns the model's current value. Note that the upper limit on the model's value is maximum and the lower limit is minimum.
        Specified by:
        getValue in interface Progression
        Returns:
        the model's value
        See Also:
        Progression.setValue(int)
      • getFloatValue

        protected double getFloatValue()
        Replies the floating-point precision value.
        Returns:
        the floating-point precision value.
      • setIndeterminate

        public void setIndeterminate​(boolean newValue)
        Description copied from interface: Progression
        Sets the indeterminate property of the task progression, which determines whether the progression is in determinate or indeterminate mode. For example an indeterminate progress bar continuously displays animation indicating that an operation of unknown length is occurring.
        Specified by:
        setIndeterminate in interface Progression
        Parameters:
        newValue - true if the progress bar should change to indeterminate mode; false if it should revert to normal.
        See Also:
        Progression.isIndeterminate()
      • setMaximum

        public void setMaximum​(int newMaximum)
        Description copied from interface: Progression
        Sets the model's maximum to newMaximum. The other properties may be changed as well, to ensure that
         minimum <= value <= maximum
         
        Specified by:
        setMaximum in interface Progression
        Parameters:
        newMaximum - the model's new maximum
        See Also:
        Progression.getMaximum()
      • setMinimum

        public void setMinimum​(int newMinimum)
        Description copied from interface: Progression
        Sets the model's minimum to newMinimum. The other properties may be changed as well, to ensure that:
         minimum <= value <= maximum
         
        Specified by:
        setMinimum in interface Progression
        Parameters:
        newMinimum - the model's new minimum
        See Also:
        Progression.getMinimum()
      • setValue

        public void setValue​(int newValue)
        Description copied from interface: Progression
        Sets the model's current value to newValue if newValue satisfies the model's constraints. Those constraints are:
         minimum <= value <= maximum
         
        Otherwise, if newValue is less than minimum it's set to minimum, if its greater than maximum then it's set to maximum.
        Specified by:
        setValue in interface Progression
        Parameters:
        newValue - the model's new value
        See Also:
        Progression.getValue()
      • setValue

        public void setValue​(int newValue,
                             String comment)
        Description copied from interface: Progression
        Sets the model's current value to newValue if newValue satisfies the model's constraints. Those constraints are:
         minimum <= value <= maximum
         
        Otherwise, if newValue is less than minimum it's set to minimum, if its greater than maximum then it's set to maximum.
        Specified by:
        setValue in interface Progression
        Parameters:
        newValue - the model's new value
        comment - is the comment to display.
        See Also:
        Progression.getValue()
      • setValue

        void setValue​(SubProgressionModel subTask,
                      double newValue,
                      String comment)
        Set the value with a float-point precision. This method is invoked from a subtask.
        Parameters:
        subTask - the subtask.
        newValue - the new value.
        comment - the new comment.
      • setAdjusting

        public void setAdjusting​(boolean adjusting)
        Description copied from interface: Progression
        This attribute indicates that any upcoming changes to the value of the model should be considered a single event. This attribute will be set to true at the start of a series of changes to the value, and will be set to false when the value has finished changing. Normally this allows a listener to only take action when the final value change in committed, instead of having to do updates for all intermediate values.
        Specified by:
        setAdjusting in interface Progression
        Parameters:
        adjusting - true if the upcoming changes to the value property are part of a series
        See Also:
        Progression.subTask(int)
      • subTask

        public final Progression subTask​(int extent,
                                         int minValue,
                                         int maxValue)
        Description copied from interface: Progression
        Enter into a subtask. When a sub task is created, it will progress as a sub part of the main task.

        The minimum value of the subtask in its parent will correspond to the current value of the main task. The maximum value of the sub task in its parent will correspond to the current value of the main task plus the given extend.

        If the extend plus the current value is exceeding the maximum value, it will be bounded to the maximum.

        Specified by:
        subTask in interface Progression
        Parameters:
        extent - is the size of the sub task inside the main task.
        minValue - is the minimum value inside the subtask.
        maxValue - is the maximum value inside the subtask.
        Returns:
        the subtask progression
      • subTask

        public Progression subTask​(int extent,
                                   int minValue,
                                   int maxValue,
                                   boolean overwriteComment)
        Description copied from interface: Progression
        Enter into a subtask. When a sub task is created, it will progress as a sub part of the main task.

        The minimum value of the subtask in its parent will correspond to the current value of the main task. The maximum value of the sub task in its parent will correspond to the current value of the main task plus the given extend.

        If the extend plus the current value is exceeding the maximum value, it will be bounded to the maximum.

        Specified by:
        subTask in interface Progression
        Parameters:
        extent - is the size of the sub task inside the main task.
        minValue - is the minimum value inside the subtask.
        maxValue - is the maximum value inside the subtask.
        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
      • subTask

        public final Progression subTask​(int extent)
        Description copied from interface: Progression
        Enter into a subtask. When a sub task is created, it will progress as a sub part of the main task.

        The minimum value of the subtask in its parent will correspond to the current value of the main task. The maximum value of the sub task in its parent will correspond to the current value of the main task plus the given extend.

        If the extend plus the current value is exceeding the maximum value, it will be bounded to the maximum.

        The minimum and maximum values of the subtask should be manually set the the caller.

        Specified by:
        subTask in interface Progression
        Parameters:
        extent - is the size of the sub task inside the main task.
        Returns:
        the subtask progression
      • subTask

        public Progression subTask​(int extent,
                                   boolean overwriteComment)
        Description copied from interface: Progression
        Enter into a subtask. When a sub task is created, it will progress as a sub part of the main task.

        The minimum value of the subtask in its parent will correspond to the current value of the main task. The maximum value of the sub task in its parent will correspond to the current value of the main task plus the given extend.

        If the extend plus the current value is exceeding the maximum value, it will be bounded to the maximum.

        The minimum and maximum values of the subtask should be manually set the the caller.

        Specified by:
        subTask in interface Progression
        Parameters:
        extent - is the size of the sub task inside the main task.
        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
      • disconnectSubTask

        void disconnectSubTask​(SubProgressionModel subTask,
                               double value,
                               boolean overwriteComment)
        Set the parent value and disconnect this subtask from its parent. This method is invoked from a subtask.
        Parameters:
        subTask - the subtask to disconnect.
        value - the value of the task.
        overwriteComment - indicates if the comment of this parent model may be overwritten by the child's comment.
      • getComment

        public String getComment()
        Description copied from interface: Progression
        Replies the comment associated to the currect task.
        Specified by:
        getComment in interface Progression
        Returns:
        the comment for the current task or null if the current task has not any comment.
      • setComment

        public void setComment​(String comment)
        Description copied from interface: Progression
        Set the comment associated to the currect task.

        If the given string is null or empty, the current task is assumed to not have a comment.

        Specified by:
        setComment in interface Progression
        Parameters:
        comment - is the comment for the current task.
      • increment

        public void increment​(int amount)
        Description copied from interface: Progression
        Increment the current value by the given amount.

        This function is equivalent to:

        
         this.setValue(this.getValue()+amount);
         
        Specified by:
        increment in interface Progression
        Parameters:
        amount - is the amount to add to the current value.
      • increment

        public void increment​(int amount,
                              String comment)
        Description copied from interface: Progression
        Increment the current value by the given amount.

        This function is equivalent to:

        
         this.setValue(this.getValue()+amount, comment);
         
        Specified by:
        increment in interface Progression
        Parameters:
        amount - is the amount to add to the current value.
        comment - is the comment to display.
      • increment

        public void increment()
        Description copied from interface: Progression
        Increment the current value by 1.

        This function is equivalent to:

        
         this.setValue(this.getValue()+1);
         
        Specified by:
        increment in interface Progression
      • increment

        public void increment​(String comment)
        Description copied from interface: Progression
        Increment the current value by 1.

        This function is equivalent to:

        
         this.setValue(this.getValue()+1, comment);
         
        Specified by:
        increment in interface Progression
        Parameters:
        comment - is the comment to display.