- java.lang.Object
-
- org.arakhne.afc.progress.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
-
-
Field Summary
Fields Modifier and Type Field Description protected ListenerCollection<ProgressionListener>listenersCollection of listeners.
-
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 voidaddProgressionListener(ProgressionListener listener)Add a listener on this model.(package private) voiddisconnectSubTask(SubProgressionModel subTask, double value, boolean overwriteComment)Set the parent value and disconnect this subtask from its parent.voidend()Force this progression task to end its indicator.voidensureNoSubTask()Ensure that there is no opened subtask.protected voidfireStateChange()Notify listeners about state change.protected voidfireValueChange()Notify listeners about value change.StringgetComment()Replies the comment associated to the currect task.protected doublegetFloatValue()Replies the floating-point precision value.intgetMaximum()Returns the model's maximum.intgetMinimum()Returns the minimum acceptable value.doublegetPercent()Returns the model's current value in percent of pregression.doublegetProgressionFactor()Returns the model's current value in percent of pregression.ProgressiongetSubTask()Replies the current subtask of this task model.ProgressiongetSuperTask()Replies the super task of this task model.intgetTaskDepth()Replies the depth level of this task.intgetValue()Returns the model's current value.voidincrement()Increment the current value by 1.voidincrement(int amount)Increment the current value by the given amount.voidincrement(int amount, String comment)Increment the current value by the given amount.voidincrement(String comment)Increment the current value by 1.booleanisAdjusting()Returns true if the current changes to the value property are part of a series of changes.booleanisIndeterminate()Returns the value of theindeterminateproperty.booleanisRootModel()Replies if is task model is a root model.voidremoveProgressionListener(ProgressionListener listener)Remove a listener on this model.voidsetAdjusting(boolean adjusting)This attribute indicates that any upcoming changes to the value of the model should be considered a single event.voidsetComment(String comment)Set the comment associated to the currect task.voidsetIndeterminate(boolean newValue)Sets theindeterminateproperty of the task progression, which determines whether the progression is in determinate or indeterminate mode.voidsetMaximum(int newMaximum)Sets the model's maximum to newMaximum.voidsetMinimum(int newMinimum)Sets the model's minimum to newMinimum.voidsetProperties(int value, int min, int max, boolean adjusting)This method sets all of the model's data with a single method call.voidsetProperties(int value, int min, int max, boolean adjusting, String comment)This method sets all of the model's data with a single method call.voidsetValue(int newValue)Sets the model's current value tonewValueifnewValuesatisfies the model's constraints.voidsetValue(int newValue, String comment)Sets the model's current value tonewValueifnewValuesatisfies the model's constraints.(package private) voidsetValue(SubProgressionModel subTask, double newValue, String comment)Set the value with a float-point precision.ProgressionsubTask(int extent)Enter into a subtask.ProgressionsubTask(int extent, boolean overwriteComment)Enter into a subtask.ProgressionsubTask(int extent, int minValue, int maxValue)Enter into a subtask.ProgressionsubTask(int extent, int minValue, int maxValue, boolean overwriteComment)Enter into a subtask.
-
-
-
Field Detail
-
listeners
protected final ListenerCollection<ProgressionListener> listeners
Collection of listeners.
-
-
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 (betweenminandmax).min- is the minimal valuemax- is the maximal valueadjusting- 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 (betweenminandmax).min- is the minimal valuemax- 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 valuemax- 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:ProgressionForce this progression task to end its indicator.- Specified by:
endin interfaceProgression
-
addProgressionListener
public void addProgressionListener(ProgressionListener listener)
Description copied from interface:ProgressionAdd a listener on this model.- Specified by:
addProgressionListenerin interfaceProgression- Parameters:
listener- is the listener to add.
-
removeProgressionListener
public void removeProgressionListener(ProgressionListener listener)
Description copied from interface:ProgressionRemove a listener on this model.- Specified by:
removeProgressionListenerin interfaceProgression- Parameters:
listener- is the listener to remove.
-
isRootModel
public boolean isRootModel()
Description copied from interface:ProgressionReplies if is task model is a root model.isRootMode() == (getTaskDepth()==0)- Specified by:
isRootModelin interfaceProgression- Returns:
trueif this model is a root model, otherwisefalse
-
getSuperTask
public Progression getSuperTask()
Description copied from interface:ProgressionReplies the super task of this task model.- Specified by:
getSuperTaskin interfaceProgression- Returns:
- the super task or
nullthis task was not a decomposition of a super task.
-
getTaskDepth
public int getTaskDepth()
Description copied from interface:ProgressionReplies the depth level of this task. The root task (ie. a task without parent task) has always a depth of0. A subtask of the root task has a depth of1. A subtask of this subtask has a depth of2, etc.isRootMode() == (getTaskDepth()==0)- Specified by:
getTaskDepthin interfaceProgression- Returns:
- the depth of the task.
-
getSubTask
public final Progression getSubTask()
Description copied from interface:ProgressionReplies the current subtask of this task model.- Specified by:
getSubTaskin interfaceProgression- Returns:
- the current subtask or
nullthis task was not decomposed.
-
ensureNoSubTask
public final void ensureNoSubTask()
Description copied from interface:ProgressionEnsure that there is no opened subtask. If a subtask is existing, it is ended().- Specified by:
ensureNoSubTaskin interfaceProgression
-
fireStateChange
protected void fireStateChange()
Notify listeners about state change.
-
fireValueChange
protected void fireValueChange()
Notify listeners about value change.
-
getMaximum
public int getMaximum()
Description copied from interface:ProgressionReturns the model's maximum.- Specified by:
getMaximumin interfaceProgression- Returns:
- the value of the maximum property.
- See Also:
Progression.setMaximum(int)
-
getMinimum
public int getMinimum()
Description copied from interface:ProgressionReturns the minimum acceptable value.- Specified by:
getMinimumin interfaceProgression- Returns:
- the value of the minimum property
- See Also:
Progression.setMinimum(int)
-
getPercent
public double getPercent()
Description copied from interface:ProgressionReturns the model's current value in percent of pregression.- Specified by:
getPercentin interfaceProgression- Returns:
- the model's value between 0 and 100
- See Also:
Progression.getValue(),Progression.getProgressionFactor()
-
getProgressionFactor
public double getProgressionFactor()
Description copied from interface:ProgressionReturns the model's current value in percent of pregression.- Specified by:
getProgressionFactorin interfaceProgression- Returns:
- the model's value between 0 and 1
- See Also:
Progression.getValue(),Progression.getPercent()
-
getValue
public int getValue()
Description copied from interface:ProgressionReturns the model's current value. Note that the upper limit on the model's value ismaximumand the lower limit isminimum.- Specified by:
getValuein interfaceProgression- 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.
-
isAdjusting
public boolean isAdjusting()
Description copied from interface:ProgressionReturns true if the current changes to the value property are part of a series of changes.- Specified by:
isAdjustingin interfaceProgression- Returns:
- the valueIsAdjustingProperty.
- See Also:
Progression.setAdjusting(boolean)
-
isIndeterminate
public boolean isIndeterminate()
Description copied from interface:ProgressionReturns the value of theindeterminateproperty.- Specified by:
isIndeterminatein interfaceProgression- Returns:
- the value of the
indeterminateproperty - See Also:
Progression.setIndeterminate(boolean)
-
setIndeterminate
public void setIndeterminate(boolean newValue)
Description copied from interface:ProgressionSets theindeterminateproperty 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:
setIndeterminatein interfaceProgression- Parameters:
newValue-trueif the progress bar should change to indeterminate mode;falseif it should revert to normal.- See Also:
Progression.isIndeterminate()
-
setMaximum
public void setMaximum(int newMaximum)
Description copied from interface:ProgressionSets the model's maximum to newMaximum. The other properties may be changed as well, to ensure thatminimum <= value <= maximum
- Specified by:
setMaximumin interfaceProgression- Parameters:
newMaximum- the model's new maximum- See Also:
Progression.getMaximum()
-
setMinimum
public void setMinimum(int newMinimum)
Description copied from interface:ProgressionSets the model's minimum to newMinimum. The other properties may be changed as well, to ensure that:minimum <= value <= maximum
- Specified by:
setMinimumin interfaceProgression- Parameters:
newMinimum- the model's new minimum- See Also:
Progression.getMinimum()
-
setProperties
public void setProperties(int value, int min, int max, boolean adjusting, String comment)Description copied from interface:ProgressionThis method sets all of the model's data with a single method call. The method results in a single change event being generated. This is convenient when you need to adjust all the model data simultaneously and do not want individual change events to occur.- Specified by:
setPropertiesin interfaceProgression- Parameters:
value- an int giving the current valuemin- an int giving the minimum valuemax- an int giving the maximum valueadjusting- a boolean, true if a series of changes are in progresscomment- is the comment associated to the current task, ornull- See Also:
Progression.setValue(int),Progression.setMinimum(int),Progression.setMaximum(int),Progression.setComment(String),Progression.setAdjusting(boolean)
-
setProperties
public void setProperties(int value, int min, int max, boolean adjusting)Description copied from interface:ProgressionThis method sets all of the model's data with a single method call. The method results in a single change event being generated. This is convenient when you need to adjust all the model data simultaneously and do not want individual change events to occur.- Specified by:
setPropertiesin interfaceProgression- Parameters:
value- an int giving the current valuemin- an int giving the minimum valuemax- an int giving the maximum valueadjusting- a boolean, true if a series of changes are in progress- See Also:
Progression.setValue(int),Progression.setMinimum(int),Progression.setMaximum(int),Progression.setComment(String),Progression.setAdjusting(boolean)
-
setValue
public void setValue(int newValue)
Description copied from interface:ProgressionSets the model's current value tonewValueifnewValuesatisfies the model's constraints. Those constraints are:minimum <= value <= maximum
Otherwise, ifnewValueis less thanminimumit's set tominimum, if its greater thanmaximumthen it's set tomaximum.- Specified by:
setValuein interfaceProgression- Parameters:
newValue- the model's new value- See Also:
Progression.getValue()
-
setValue
public void setValue(int newValue, String comment)Description copied from interface:ProgressionSets the model's current value tonewValueifnewValuesatisfies the model's constraints. Those constraints are:minimum <= value <= maximum
Otherwise, ifnewValueis less thanminimumit's set tominimum, if its greater thanmaximumthen it's set tomaximum.- Specified by:
setValuein interfaceProgression- Parameters:
newValue- the model's new valuecomment- 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:ProgressionThis 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:
setAdjustingin interfaceProgression- Parameters:
adjusting-trueif 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:ProgressionEnter 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
extendplus the current value is exceeding the maximum value, it will be bounded to the maximum.- Specified by:
subTaskin interfaceProgression- 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:ProgressionEnter 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
extendplus the current value is exceeding the maximum value, it will be bounded to the maximum.- Specified by:
subTaskin interfaceProgression- 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:ProgressionEnter 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
extendplus 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:
subTaskin interfaceProgression- 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:ProgressionEnter 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
extendplus 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:
subTaskin interfaceProgression- 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:ProgressionReplies the comment associated to the currect task.- Specified by:
getCommentin interfaceProgression- Returns:
- the comment for the current task or
nullif the current task has not any comment.
-
setComment
public void setComment(String comment)
Description copied from interface:ProgressionSet the comment associated to the currect task.If the given string is
nullor empty, the current task is assumed to not have a comment.- Specified by:
setCommentin interfaceProgression- Parameters:
comment- is the comment for the current task.
-
increment
public void increment(int amount)
Description copied from interface:ProgressionIncrement the current value by the given amount.This function is equivalent to:
this.setValue(this.getValue()+amount);- Specified by:
incrementin interfaceProgression- Parameters:
amount- is the amount to add to the current value.
-
increment
public void increment(int amount, String comment)Description copied from interface:ProgressionIncrement the current value by the given amount.This function is equivalent to:
this.setValue(this.getValue()+amount, comment);- Specified by:
incrementin interfaceProgression- 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:ProgressionIncrement the current value by 1.This function is equivalent to:
this.setValue(this.getValue()+1);- Specified by:
incrementin interfaceProgression
-
increment
public void increment(String comment)
Description copied from interface:ProgressionIncrement the current value by 1.This function is equivalent to:
this.setValue(this.getValue()+1, comment);- Specified by:
incrementin interfaceProgression- Parameters:
comment- is the comment to display.
-
-