net.rim.device.api.ui.component.progressindicator
Class ProgressIndicatorModel

java.lang.Object
  extended by net.rim.device.api.ui.component.progressindicator.AbstractProgressIndicatorModel
      extended by net.rim.device.api.ui.component.progressindicator.ProgressIndicatorModel

public class ProgressIndicatorModel
extends AbstractProgressIndicatorModel

Implementation of AbstractProgressIndicatorModel. This model represents progress where the work being accomplished can be represented by a measurable quantity. This model uses an Adjustment to allow for threaded access to the data model and to allow progress to be represented by integer values. The progress takes a minimum value, a maximum value, and an initial value. Additionally, the Adjustment allows for optional use of a stepping and paging increment to advance progress.

This model allows the value to also be changed by the user. Any AbstractProgressIndicatorController that allows for users to edit the value should call ProgressIndicatorModel.setNonProgrammaticValue(int). This will update the model, notifying every ProgressIndicatorListener that the update is non-programmatic.

This model caps all values at the provided maximum value.

An Adjustment is created during initialization of this class based on the provided parameters. Setting an Adjustment later will override the one created during initialization.

Since:
BlackBerry API 6.0.0

Constructor Summary
ProgressIndicatorModel()
          Constructs a new ProgressIndicatorModel.
ProgressIndicatorModel(int initial, int max, int min)
          Constructs a new ProgressIndicatorModel.
ProgressIndicatorModel(int pageSize, int stepSize, int initial, int max, int min)
          Constructs a new ProgressIndicatorModel.
 
Method Summary
 int getInitialValue()
          Returns the initial value that was provided when the model was initialized.
 int getValue()
          Returns the value that the model is currently set to.
 int getValueMax()
          Returns the maximum value that is set for the model.
 int getValueMin()
          Returns the minimum value that is set for the model.
 void initialize(int initial, int max, int min)
          Initializes the model.
 void initialize(int pageSize, int stepSize, int initial, int max, int min)
          Initializes the model.
 boolean isComplete()
          Indicates whether or not the progress has reached completion.
 void page()
          Advances the current value by one page.
 void reset(int initial, int max, int min)
          Resets the data model and changes the parameters to those provided.
 void reset(int pageSize, int stepSize, int initial, int max, int min)
          Resets the data model and changes the parameters to those provided.
 void setInitialValue(int initial)
          Overrides the initial value that was set when this model was initialized.
 void setNonProgrammaticValue(int value)
          Sets a value such that such that every ProgressIndicatorListener is notified that the update is from a non-programmatic source.
 void setValue(int value)
          Sets the current value of the model.
 void setValueMax(int max)
          Sets the maximum value for this model.
 void setValueMin(int min)
          Sets the minimum value for this model.
 void step()
          Advances the current value by the amount that is assigned to a step.
 
Methods inherited from class net.rim.device.api.ui.component.progressindicator.AbstractProgressIndicatorModel
addListener, cancel, getAdjustment, getController, removeAdjustment, removeListener, reset, resume, setAdjustment, setController
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

ProgressIndicatorModel

public ProgressIndicatorModel()
Constructs a new ProgressIndicatorModel. Sets all values to 0.

Since:
BlackBerry API 6.0.0

ProgressIndicatorModel

public ProgressIndicatorModel(int initial,
                              int max,
                              int min)
Constructs a new ProgressIndicatorModel. Sets both page and step amounts to 0.

Parameters:
initial - The value at which the model is initialized.
max - The maximum value that the progress is allowed to reach.
min - The minimum value that the progress is allowed to have.
Since:
BlackBerry API 6.0.0

ProgressIndicatorModel

public ProgressIndicatorModel(int pageSize,
                              int stepSize,
                              int initial,
                              int max,
                              int min)
Constructs a new ProgressIndicatorModel.

Parameters:
pageSize - The amount to increase the value by when ProgressIndicatorModel.page() is called.
stepSize - the amount to increase the value by when ProgressIndicatorModel.step() is called.
initial - The value at which the model is initialized.
max - The maximum value that the progress is allowed to reach.
min - The minimum value that the progress is allowed to have.
Since:
BlackBerry API 6.0.0


Method Detail

getInitialValue

public int getInitialValue()
Returns the initial value that was provided when the model was initialized.

Returns:
The initial value the model was set to.
Since:
BlackBerry API 6.0.0

getValue

public int getValue()
Returns the value that the model is currently set to.

Returns:
The current value of the model.
Since:
BlackBerry API 6.0.0

getValueMax

public int getValueMax()
Returns the maximum value that is set for the model.

Returns:
The current maximum value that the model can reach.
Since:
BlackBerry API 6.0.0

getValueMin

public int getValueMin()
Returns the minimum value that is set for the model.

Returns:
The current minimum value that the model can reach.
Since:
BlackBerry API 6.0.0

initialize

public void initialize(int initial,
                       int max,
                       int min)
Initializes the model. Creates a new Adjustment based on the provided parameters and assigns it to this model. Sets the values used for step and page to 0.

Parameters:
initial - The initial value for the model.
max - The maximum value that the model can reach.
min - The minimum value for the model.
Since:
BlackBerry API 6.0.0

initialize

public void initialize(int pageSize,
                       int stepSize,
                       int initial,
                       int max,
                       int min)
Initializes the model. Creates a new Adjustment based on the provided parameters and assigns it to this model.

Parameters:
pageSize - The amount by which to increment the value when paging.
stepSize - The amount by which to increment the value when stepping.
initial - The initial value for the model.
max - The maximum value that the model can reach.
min - The minimum value for the model.
Since:
BlackBerry API 6.0.0

isComplete

public boolean isComplete()
Indicates whether or not the progress has reached completion.

Specified by:
isComplete in class AbstractProgressIndicatorModel
Returns:
true if the progress is complete, false otherwise.
Since:
BlackBerry API 6.0.0

page

public void page()
Advances the current value by one page. The value is bounded by the currently set maximum value.

See Also:
Adjustment.pageStepUp()
Since:
BlackBerry API 6.0.0

reset

public void reset(int initial,
                  int max,
                  int min)
Resets the data model and changes the parameters to those provided. The currently set Adjustment will be updated to reflect the changes. Note that this method retains the existing values for page and step in the currently set Adjustment.

Parameters:
initial - The initial value for the model.
max - The maximum value that the model can reach.
min - The minimum value for the model.
Since:
BlackBerry API 6.0.0

reset

public void reset(int pageSize,
                  int stepSize,
                  int initial,
                  int max,
                  int min)
Resets the data model and changes the parameters to those provided. The currently set Adjustment will be updated to reflect these changes.

Parameters:
pageSize - The amount to increment the value by when paging.
stepSize - The amount to increment the value by when stepping.
initial - The initial value for the model.
max - The maximum value that the model can reach.
min - The minimum value for the model.
Since:
BlackBerry API 6.0.0

setInitialValue

public void setInitialValue(int initial)
Overrides the initial value that was set when this model was initialized.

Parameters:
initial - The value to set as the initial value for this model.
Since:
BlackBerry API 6.0.0

setNonProgrammaticValue

public void setNonProgrammaticValue(int value)
Sets a value such that such that every ProgressIndicatorListener is notified that the update is from a non-programmatic source. This is intended for use when the user changes the value. The value assigned will be bounded by the current minimum and maximum values.

Overrides:
setNonProgrammaticValue in class AbstractProgressIndicatorModel
Parameters:
value - The new value for the model.
Since:
BlackBerry API 6.0.0

setValue

public void setValue(int value)
Sets the current value of the model. This value will be bounded by the currently set minimum and maximum values.

Parameters:
value - The value to set the model to.
Since:
BlackBerry API 6.0.0

setValueMax

public void setValueMax(int max)
Sets the maximum value for this model. The current value will then be bounded by this new maximum value.

Parameters:
max - The value to set as the maximum value.
Since:
BlackBerry API 6.0.0

setValueMin

public void setValueMin(int min)
Sets the minimum value for this model. The current value will then be bounded by this new minimum value.

Parameters:
min - The value to set as the minimum value.
Since:
BlackBerry API 6.0.0

step

public void step()
Advances the current value by the amount that is assigned to a step. The value is bounded by the currently set maximum and minimum values.

See Also:
Adjustment.stepUp()
Since:
BlackBerry API 6.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal