echopointng
Class ProgressBar

java.lang.Object
  extended by nextapp.echo2.app.Component
      extended by echopointng.ComponentEx
          extended by echopointng.AbleComponent
              extended by echopointng.ProgressBar
All Implemented Interfaces:
AccessKeyable, Attributeable, Borderable, Delegateable, Heightable, Insetable, MouseCursorable, Sizeable, ToolTipable, Widthable, java.io.Serializable, RenderIdSupport

public class ProgressBar
extends AbleComponent

The ProgressBar> component provides a visual display for an integer value within a bounded interval.

A ProgressBar typically communicates the progress of an event by displaying its percentage of completion and possibly a textual display of this percentage.

The ProgressBar comes with a standard width and height that is optimised for HORIZONATL orientation. If you change the orientation, be sure to flip the height and width otherwise it will look strange. This is done by default on the basic setOrientation() method.

The width and height of the ProgressBar can be adjusted slightly by the ProgressBarRenderer, so it can fit the block size exactly. So dont assume its size is always exact.

See Also:
Serialized Form

Field Summary
protected  ChangeEvent changeEvent
          Only one ChangeEvent is needed per instance since the event's only interesting property is the immutable source, which is the progress bar.
protected  ChangeListener changeListener
           
static Style DEFAULT_STYLE
           
static int ORIENTATION_HORIZONTAL
           
static int ORIENTATION_VERTICAL
           
static java.lang.String PROPERTY_COMPLETED_COLOR
           
static java.lang.String PROPERTY_MODEL
           
static java.lang.String PROPERTY_NUMBER_OF_BLOCKS
           
static java.lang.String PROPERTY_ORIENTATION
           
static java.lang.String PROPERTY_PROGRESS_STRING
           
static java.lang.String PROPERTY_PROGRESS_STRING_PAINTED
           
static java.lang.String PROPERTY_PROGRESSBAR_IMAGE
           
static java.lang.String PROPERTY_RENDERER
           
static java.lang.String PROPERTY_UNCOMPLETED_COLOR
           
 
Fields inherited from class echopointng.ComponentEx
PROPERTY_HIDDEN
 
Fields inherited from class nextapp.echo2.app.Component
CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FOCUS_TRAVERSAL_INDEX_CHANGED_PROPERTY, FOCUS_TRAVERSAL_PARTICIPANT_CHANGED_PROPERTY, LAYOUT_DIRECTION_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, PROPERTY_BACKGROUND, PROPERTY_FONT, PROPERTY_FOREGROUND, PROPERTY_LAYOUT_DATA, STYLE_CHANGED_PROPERTY, STYLE_NAME_CHANGED_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Fields inherited from interface echopointng.able.AccessKeyable
PROPERTY_ACCESS_KEY
 
Fields inherited from interface echopointng.able.Borderable
PROPERTY_BORDER
 
Fields inherited from interface echopointng.able.MouseCursorable
CURSOR_AUTO, CURSOR_CROSSHAIR, CURSOR_CUSTOM_URI, CURSOR_DEFAULT, CURSOR_E_RESIZE, CURSOR_HELP, CURSOR_MOVE, CURSOR_N_RESIZE, CURSOR_NE_RESIZE, CURSOR_NW_RESIZE, CURSOR_POINTER, CURSOR_S_RESIZE, CURSOR_SE_RESIZE, CURSOR_SW_RESIZE, CURSOR_TEXT, CURSOR_W_RESIZE, CURSOR_WAIT, PROPERTY_MOUSE_CURSOR, PROPERTY_MOUSE_CURSOR_URI
 
Fields inherited from interface echopointng.able.Insetable
DEFAULT_INSETS, DEFAULT_OUTSETS, PROPERTY_INSETS, PROPERTY_OUTSETS
 
Fields inherited from interface echopointng.able.Widthable
PROPERTY_WIDTH
 
Fields inherited from interface echopointng.able.Heightable
PROPERTY_HEIGHT
 
Fields inherited from interface echopointng.able.ToolTipable
PROPERTY_TOOL_TIP_TEXT
 
Constructor Summary
ProgressBar()
          Creates a horizontal progress bar.
ProgressBar(BoundedRangeModel newModel)
          Creates a horizontal progress bar, the default orientation.
ProgressBar(int min, int max)
          Creates a horizontal progress bar, which is the default.
 
Method Summary
 void addChangeListener(ChangeListener l)
          Adds a ChangeListener to the ProgressBar.
protected  ChangeListener createChangeListener()
          Subclasses that want to handle ChangeEvents differently can override this to return a subclass of ModelListener or another ChangeListener implementation.
protected  void fireStateChanged()
          Notify all listeners that have registered interest for notification on this event type.
 Color getCompletedColor()
           
 int getMaximum()
          Returns the model's maximum value.
 int getMinimum()
          Returns the model's minimum value.
 BoundedRangeModel getModel()
          Returns the data model used by the ProgressBar.
 int getNumberOfBlocks()
           
 int getOrientation()
          Returns ProgressBar.ORIENTATION_VERTICAL or ProgressBar.ORIENTATION_HORIZONTAL, depending on the orientation of the progress bar.
 double getPercentComplete()
          Returns the percentage/percent complete for the progress bar.
 ImageReference getProgressBarImage()
          This returns the image used to represent the ProgressBar.
 java.lang.String getProgressString()
          Returns the current value of the Progress String.
 ProgressBarRenderer getRenderer()
          Returns the renderer used by the ProgressBar.
 Color getUncompletedColor()
           
 int getValue()
          Returns the model's current value.
 void invalidate()
          Can be called to invalidate the ProgressBar so that it will redraw its internals when next rendered.
 boolean isProgressStringPainted()
          Returns true if the progress bar will render a string onto the representation of the progress bar.
 void removeChangeListener(ChangeListener l)
          Removes a ChangeListener from the ProgressBar.
 void setCompletedColor(Color newColor)
          Sets the completed Color of the ProgressBar.
 void setMaximum(int n)
          Sets the model's maximum to n .
 void setMinimum(int n)
          Sets the model's minimum to n .
 void setModel(BoundedRangeModel newModel)
          Sets the data model used by the ProgressBar.
 void setNumberOfBlocks(int newValue)
          Sets the number of blocks used when displaying the ProgressBar<
 void setOrientation(int newOrientation)
          Sets the progress bar's orientation to newOrientation , which must be ProgressBar.ORIENTATION_VERTICAL or ProgressBar.ORIENTATION_HORIZONTAL.
 void setOrientation(int newOrientation, boolean flipWidthAndHeight)
          Sets the progress bar's orientation to newOrientation , which must be ProgressBar.ORIENTATION_VERTICAL or ProgressBar.ORIENTATION_HORIZONTAL.
 void setProgressString(java.lang.String newValue)
          Sets the value of the Progress String.
 void setProgressStringPainted(boolean newValue)
          Sets whether the progress bar will render a string.
 void setRenderer(ProgressBarRenderer newRenderer)
          Sets the renderer used by the ProgressBar.
 void setUncompletedColor(Color newColor)
          Sets the uncompleted Color of the ProgressBar.
 void setValue(int n)
          Sets the model's value to n .
 java.lang.String toString()
           
 void validate()
          A life-cycle method invoked before the component is rendered to ensure it is in a valid state.
 
Methods inherited from class echopointng.AbleComponent
getAccessKey, getBorder, getHeight, getInsets, getMouseCursor, getMouseCursorURI, getOutsets, getToolTipText, getWidth, setAccessKey, setBorder, setHeight, setInsets, setMouseCursor, setMouseCursorURI, setOutsets, setToolTipText, setWidth
 
Methods inherited from class echopointng.ComponentEx
getAttribute, getAttributeNames, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, isHidden, setAttribute, setHidden, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty
 
Methods inherited from class nextapp.echo2.app.Component
add, add, addPropertyChangeListener, dispose, firePropertyChange, getApplicationInstance, getBackground, getComponent, getComponent, getComponentCount, getComponents, getEventListenerList, getFocusTraversalIndex, getFont, getForeground, getId, getIndexedProperty, getLayoutData, getLayoutDirection, getLocale, getParent, getProperty, getRenderId, getRenderIndexedProperty, getRenderIndexedProperty, getRenderLayoutDirection, getRenderLocale, getRenderProperty, getRenderProperty, getStyle, getStyleName, getVisibleComponent, getVisibleComponentCount, getVisibleComponents, hasEventListenerList, indexOf, init, isAncestorOf, isEnabled, isFocusTraversalParticipant, isRegistered, isRenderEnabled, isRenderVisible, isValidChild, isValidParent, isVisible, processInput, remove, remove, removeAll, removePropertyChangeListener, setBackground, setEnabled, setFocusTraversalIndex, setFocusTraversalParticipant, setFont, setForeground, setId, setIndexedProperty, setLayoutData, setLayoutDirection, setLocale, setProperty, setStyle, setStyleName, setVisible, verifyInput, visibleIndexOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 

Field Detail

PROPERTY_COMPLETED_COLOR

public static final java.lang.String PROPERTY_COMPLETED_COLOR
See Also:
Constant Field Values

PROPERTY_MODEL

public static final java.lang.String PROPERTY_MODEL
See Also:
Constant Field Values

PROPERTY_NUMBER_OF_BLOCKS

public static final java.lang.String PROPERTY_NUMBER_OF_BLOCKS
See Also:
Constant Field Values

PROPERTY_ORIENTATION

public static final java.lang.String PROPERTY_ORIENTATION
See Also:
Constant Field Values

PROPERTY_PROGRESS_STRING

public static final java.lang.String PROPERTY_PROGRESS_STRING
See Also:
Constant Field Values

PROPERTY_PROGRESS_STRING_PAINTED

public static final java.lang.String PROPERTY_PROGRESS_STRING_PAINTED
See Also:
Constant Field Values

PROPERTY_PROGRESSBAR_IMAGE

public static final java.lang.String PROPERTY_PROGRESSBAR_IMAGE
See Also:
Constant Field Values

PROPERTY_RENDERER

public static final java.lang.String PROPERTY_RENDERER
See Also:
Constant Field Values

PROPERTY_UNCOMPLETED_COLOR

public static final java.lang.String PROPERTY_UNCOMPLETED_COLOR
See Also:
Constant Field Values

ORIENTATION_HORIZONTAL

public static final int ORIENTATION_HORIZONTAL
See Also:
Constant Field Values

ORIENTATION_VERTICAL

public static final int ORIENTATION_VERTICAL
See Also:
Constant Field Values

DEFAULT_STYLE

public static final Style DEFAULT_STYLE

changeEvent

protected transient ChangeEvent changeEvent
Only one ChangeEvent is needed per instance since the event's only interesting property is the immutable source, which is the progress bar.


changeListener

protected ChangeListener changeListener
Constructor Detail

ProgressBar

public ProgressBar()
Creates a horizontal progress bar. The default orientation for progress bars is ProgressBar.HORIZONTAL.

By default, the ProgressString is set to null and the ProgressStringPainted is not painted.

Uses the defaultMinimum (0) and defaultMaximum (100). Uses the defaultMinimum for the initial value of the progress bar.


ProgressBar

public ProgressBar(BoundedRangeModel newModel)
Creates a horizontal progress bar, the default orientation.

By default, the ProgressString is set to null and the ProgressStringPainted is not painted.

Uses the specified BoundedRangeModel which holds the minimum, value, and maximum.


ProgressBar

public ProgressBar(int min,
                   int max)
Creates a horizontal progress bar, which is the default.

By default, the ProgressString is set to null and the ProgressStringPainted is not painted.

Uses the specified minimum and maximum. Uses the specified minimum for the initial value of the progress bar.

Method Detail

addChangeListener

public void addChangeListener(ChangeListener l)
Adds a ChangeListener to the ProgressBar.

Parameters:
l - the ChangeListener to add

createChangeListener

protected ChangeListener createChangeListener()
Subclasses that want to handle ChangeEvents differently can override this to return a subclass of ModelListener or another ChangeListener implementation.


fireStateChanged

protected void fireStateChanged()
Notify all listeners that have registered interest for notification on this event type.


getCompletedColor

public Color getCompletedColor()
Returns:
The Color of the ProgressBar's completed blocks.

getMaximum

public int getMaximum()
Returns the model's maximum value. By default, this is 100.

Returns:
an int -- the model's maximum

getMinimum

public int getMinimum()
Returns the model's minimum value. By default, this is 0.


getModel

public BoundedRangeModel getModel()
Returns the data model used by the ProgressBar.


getNumberOfBlocks

public int getNumberOfBlocks()
Returns:
The number of blocks used when displaying the ProgressBar.

getOrientation

public int getOrientation()
Returns ProgressBar.ORIENTATION_VERTICAL or ProgressBar.ORIENTATION_HORIZONTAL, depending on the orientation of the progress bar. The default orientation is ORIENTATION_HORIZONTAL.


getPercentComplete

public double getPercentComplete()
Returns the percentage/percent complete for the progress bar. Note that, as a double, this number is between 0.00 and 1.00.

Returns:
the percent complete for this progress bar.

getProgressBarImage

public ImageReference getProgressBarImage()
This returns the image used to represent the ProgressBar.

Notice that their is no setProgressBarImage() method. The internal image is updated whenever the model is changed.

This is done by making a call to the ProgressBarRenderer.drawProgressBar method, which subclasses can override to customise how the progress bar is drawn.


getProgressString

public java.lang.String getProgressString()
Returns the current value of the Progress String.


getRenderer

public ProgressBarRenderer getRenderer()
Returns the renderer used by the ProgressBar.


getUncompletedColor

public Color getUncompletedColor()
Returns:
The Color of the ProgressBar's uncompleted blocks.

getValue

public int getValue()
Returns the model's current value. The value is always between the model's minimum and maximum values, inclusive. By default, the value equals the minimum.


invalidate

public void invalidate()
Can be called to invalidate the ProgressBar so that it will redraw its internals when next rendered.


isProgressStringPainted

public boolean isProgressStringPainted()
Returns true if the progress bar will render a string onto the representation of the progress bar. Returns false if it will not do this rendering. The default is false - the progress bar does not draw the string by default.


removeChangeListener

public void removeChangeListener(ChangeListener l)
Removes a ChangeListener from the ProgressBar.

Parameters:
l - the ChangeListener to remove

setCompletedColor

public void setCompletedColor(Color newColor)
Sets the completed Color of the ProgressBar.


setMaximum

public void setMaximum(int n)
Sets the model's maximum to n . The underlying BoundedRangeModel will handle any mathematical issues arrising from assigning faulty values.

Notifies any listeners if the data changes.


setMinimum

public void setMinimum(int n)
Sets the model's minimum to n .

The underlying BoundedRangeModel will handle any mathematical issues arrising from assigning faulty values.

Notifies any listeners if the data changes.


setModel

public void setModel(BoundedRangeModel newModel)
Sets the data model used by the ProgressBar.


setNumberOfBlocks

public void setNumberOfBlocks(int newValue)
Sets the number of blocks used when displaying the ProgressBar<


setOrientation

public void setOrientation(int newOrientation)
Sets the progress bar's orientation to newOrientation , which must be ProgressBar.ORIENTATION_VERTICAL or ProgressBar.ORIENTATION_HORIZONTAL. The default orientation is ORIENTATION_HORIZONTAL.


setOrientation

public void setOrientation(int newOrientation,
                           boolean flipWidthAndHeight)
Sets the progress bar's orientation to newOrientation , which must be ProgressBar.ORIENTATION_VERTICAL or ProgressBar.ORIENTATION_HORIZONTAL. The default orientation is ORIENTATION_HORIZONTAL.

If the flipWidthAndHeight parameter is true, then the width and height properties will be flipped around.


setProgressString

public void setProgressString(java.lang.String newValue)
Sets the value of the Progress String. By default, this String is set to null.


setProgressStringPainted

public void setProgressStringPainted(boolean newValue)
Sets whether the progress bar will render a string.


setRenderer

public void setRenderer(ProgressBarRenderer newRenderer)
Sets the renderer used by the ProgressBar.


setUncompletedColor

public void setUncompletedColor(Color newColor)
Sets the uncompleted Color of the ProgressBar.


setValue

public void setValue(int n)
Sets the model's value to n .

The underlying BoundedRangeModel will handle any mathematical issues arrising from assigning faulty values.

Notifies any listeners if the data changes.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

validate

public void validate()
Description copied from class: Component
A life-cycle method invoked before the component is rendered to ensure it is in a valid state. Default implementation is empty. Overriding implementations should ensure to invoke super.validate() out of convention.

Overrides:
validate in class Component
See Also:
Component.validate()