Class ProgressBar
- All Implemented Interfaces:
Animatable<ProgressBar>
,CanDrop<ProgressBar>
,Clickable<ProgressBar>
,Draggable<ProgressBar>
,HandleMouseEvents<ProgressBar>
Progress bar component
The progress bar component is used to measure the progress of certain operations that it is assigned to. The bar is filled, depending on how much of the work is done, or how much time has passed. This component can give feedback to the user about certain operations.
The information displayed by the component can be customized, such as the name of the task, or if it should measure the progress in percentages, etc.
Note that the component doesn't handle or analyze the process it is assigned to. The process needs to give this information to this component. The state of the process is defined by first assigning a number that represents the starting and the end value. A number representing the current state must also be assigned. If the current state value is less or equal with the starting value, the process is considered to have not started yet, meaning 0% done, and it will be displayed as such. If the current state value is greater than, or equal to the end value, the process is considered to be finished, meaning that it is 100% done, and it will be displayed as such.
Supported events:
AnimationStart
AnimationEnd
,
Click
,
DoubleClick
,
MouseDown
,
MouseDown
,
MouseLeave
,
MouseMove
,
MouseOver
,
MouseOut
,
MouseUp
,
Wheel
,
Drop
,
DragStart
,
DragEnd
- Since:
- 4.0
- Author:
- JBStrap
-
Field Summary
Fields inherited from class com.jbstrap.ui.Component
animation, attributes, backgroundColor, borderColor, color, defaultHotKeyHandler, handlers, hotKeys, styleClasses, textAlign, toolTip, toolTipPosition
-
Constructor Summary
ConstructorDescriptionCreates a default progress bar component.ProgressBar
(String id) Creates a default progress bar component.ProgressBar
(String title, int minValue, int maxValue, boolean autoPositionText, StyleElement... styles) Creates a progress bar with the specified title, style and specified minimum and maximum values.ProgressBar
(String title, StyleElement... styles) Creates a progress bar with the specified title and style.ProgressBar
(String id, String title, int minValue, int maxValue, boolean autoPositionText, StyleElement... styles) Creates a progress bar with the specified title, style and specified minimum and maximum values.ProgressBar
(String id, String title, StyleElement... styles) Creates a progress bar with the specified title and style. -
Method Summary
Modifier and TypeMethodDescriptionaddComponent
(Component component) No component can be added to the Progress Barint
Gets the numerical value representing the end point of the processint
Gets the numerical value representing the starting point of the processGets the text representing the current state of the processgetTitle()
Gets the title of the assigned processint
getValue()
Gets the numerical value that represents the current state of the processremoveComponent
(Component component) No component can be removed from the Progress BarsetBackgroundColor
(Color color) Sets the component’s background color.final ProgressBar
setMaxValue
(int maxValue) Sets the numerical value representing the end point of the processfinal ProgressBar
setMinValue
(int minValue) Sets the numerical value representing the starting point of the processfinal ProgressBar
setPositionText
(String text) Sets the text representing the current state of the process.setSize
(ProgressBarSize size) Sets the progress bar.final ProgressBar
Sets the title of the assigned processfinal ProgressBar
setValue
(int value) Sets the process' current value that represents its statesetVisible
(boolean visible) Sets the visibility of the component.boolean
writeHTML
(StringWriter writer) Creates the component's HTML equivalentMethods inherited from class com.jbstrap.ui.Component
_hide, _setAttribute, addAllowedRole, addComponent, addComponents, addDeniedRole, addHandler, addStyle, addStyleClass, addStyleClasses, afterDraw, clearfix, closeTag, combinateAccess, containsStyle, containsStyleClass, draw, drawSubComponents, error, flattendComponentTree, getAccess, getAccessMode, getAllowedRoles, getAttribute, getAttributes, getBackgroundColor, getBorderColor, getClient, getComponentById, getComponents, getComponents, getComponentsByClass, getData, getDeniedRoles, getHandlers, getId, getLanguageCode, getName, getParent, getParent, getRegisteredEvents, getStyle, getStyleClasses, getTextAlign, getTextColor, getToolTip, getToolTipPosition, getTypeName, getUI, init, insertComponentAfter, insertComponentBefore, isAccess, isDrawn, isEnabled, isEventBubbling, isVisible, onHide, onHotKeyEventHandler, onShow, openTag, redraw, removeAllComponents, removeAllowedRole, removeAllStyleClasses, removeAttribute, removeComponent, removeComponents, removeDeniedRole, removeHandler, removeStyle, removeStyle, removeStyleClass, removeStyleClasses, replaceComponent, replaceStyleClass, runAfterDraw, runJavaScript, runJavaScript, runJavaScript, runOnHide, runOnShow, say, setAttribute, setBorder, setBorderColor, setData, setDisplayType, setEnabled, setEventBubbling, setFlex, setFloating, setHeight100, setHeight25, setHeight50, setHeight75, setHeightAuto, setLanguage, setMargin, setName, setOverflow, setPadding, setParent, setScrollable, setSelectionType, setShadow, setStyle, setTextAlign, setTextColor, setToolTip, setToolTipPosition, setWidth100, setWidth25, setWidth50, setWidth75, setWidthAuto, showNotification, showNotification, showProcessIndicator, toggleStyleClass
Methods inherited from class com.jbstrap.core.messagebus.MessageBus
closeMessageBus, messageBusOpened, openMessageBus, renewSubscription, sendMessageToMessageBus, subscribeMessageBus, unsubscribeAllListeners, unsubscribeMessageBus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jbstrap.ui.Animatable
addAnimationEndHandler, addAnimationStartHandler, getAnimation, removeAnimation, setAnimation
Methods inherited from interface com.jbstrap.ui.CanDrop
addDropEventHandler
Methods inherited from interface com.jbstrap.ui.Clickable
addClickHandler, addDoubleClickHandler
Methods inherited from interface com.jbstrap.ui.Draggable
addDragEndEventHandler, addDragStartEventHandler, setDraggable
Methods inherited from interface com.jbstrap.ui.HandleMouseEvents
addMouseDownHandler, addMouseEnterHandler, addMouseLeaveHandler, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler
-
Constructor Details
-
ProgressBar
public ProgressBar()Creates a default progress bar component. The starting point will be 0, the end point will be 100.- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
ProgressBar
Creates a default progress bar component. The starting point will be 0, the end point will be 100.- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
ProgressBar
Creates a progress bar with the specified title and style. It will have a minimum value of 0, and a maximum value of 100.- Parameters:
title
- The title of the process, which will appear on the left side of the progress bar. If specified asnull
no title will appear.styles
- The progress bar style. See theProgressBarType
enum for the applicable styles.- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
ProgressBar
Creates a progress bar with the specified title and style. It will have a minimum value of 0, and a maximum value of 100.- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)title
- The title of the process, which will appear on the left side of the progress bar. If specified asnull
no title will appear.styles
- The progress bar style. See theProgressBarType
enum for the applicable styles.- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
ProgressBar
public ProgressBar(String title, int minValue, int maxValue, boolean autoPositionText, StyleElement... styles) Creates a progress bar with the specified title, style and specified minimum and maximum values.- Parameters:
title
- The title of the process, which will appear on the left side of the progress bar. If specified asnull
no title will appear.minValue
- The numerical value, representing the starting point of the processmaxValue
- The numerical value, representing the end point of the processautoPositionText
- Determines if the progress of the operation is displayed automatically. If set totrue
, the progress will be on the right side of the bar, in percentages, and if the position of the progress bar is changed, it is recalculated automatically. If set tofalse
the text set in thesetPositionText()
method will appear on the right side of the bar, which will not be refreshed automatically.styles
- The progress bar stlye. See theProgressBarType
enum for the applicable styles.- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
ProgressBar
public ProgressBar(String id, String title, int minValue, int maxValue, boolean autoPositionText, StyleElement... styles) Creates a progress bar with the specified title, style and specified minimum and maximum values.- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)title
- The title of the process, which will appear on the left side of the progress bar. If specified asnull
no title will appear.minValue
- The numerical value, representing the starting point of the processmaxValue
- The numerical value, representing the end point of the processautoPositionText
- Determines if the progress of the operation is displayed automatically. If set totrue
, the progress will be on the right side of the bar, in percentages, and if the position of the progress bar is changed, it is recalculated automatically. If set tofalse
the text set in thesetPositionText()
method will appear on the right side of the bar, which will not be refreshed automatically.styles
- The progress bar stlye. See theProgressBarType
enum for the applicable styles.- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
-
Method Details
-
setSize
Sets the progress bar.- Parameters:
size
- Progress bar size Ifnull
is specified, the progress bar is displayed using the default (DEFAULT) size. Available sizes are listed in the enumProgressBarSize
.- Returns:
- The progress bar component
-
setMinValue
Sets the numerical value representing the starting point of the process- Parameters:
minValue
- The numerical value representing the starting point- Returns:
- The progress bar component
-
getMinValue
public int getMinValue()Gets the numerical value representing the starting point of the process- Returns:
- The numerical value representing the starting point
-
setMaxValue
Sets the numerical value representing the end point of the process- Parameters:
maxValue
- The numerical value representing the end point of the process- Returns:
- The progress bar component
-
getMaxValue
public int getMaxValue()Gets the numerical value representing the end point of the process- Returns:
- The numerical value representing the end point
-
setValue
Sets the process' current value that represents its state- Parameters:
value
- The numerical value that represents its current state. If this value is less or equal as the value representing the starting point, The process will be considered yet to be started. If the current state value is greater than, or equal to the end value, the process is considered to be finished. If this value falls between the two, the progress bar will be set to the corresponding position, giving feedback to the user about the current state of the assigned process. If the process state is set to be automatically defined, then the percentage value representing the current state will be also displayed to the user- Returns:
- The progress bar component
-
getValue
public int getValue()Gets the numerical value that represents the current state of the process- Returns:
- The numerical value
-
getTitle
Gets the title of the assigned process- Returns:
- The title or
null
if no title was specified
-
setTitle
Sets the title of the assigned process- Parameters:
title
- The title of the assigned process which will be on the left side of the bar. If set tonull
no title will be shown.- Returns:
- The progress bar title
-
getPositionText
Gets the text representing the current state of the process- Returns:
- The text representing the current state of the process or
null
if it wasn't defined or if the or if it's disabled on the component
-
setPositionText
Sets the text representing the current state of the process. This text will appear on the right side of the progress bar.- Parameters:
text
- The text representing the current state of the process. If specified asnull
, no text will be shown. By default, the current state will be displayed in percentages.- Returns:
- The Progress Bar component
-
addComponent
No component can be added to the Progress Bar- Overrides:
addComponent
in classComponent<ProgressBar>
- Parameters:
component
- The component to be added- Returns:
- The component
- Throws:
UnsupportedOperationException
- In every case
-
removeComponent
No component can be removed from the Progress Bar- Overrides:
removeComponent
in classComponent<ProgressBar>
- Parameters:
component
- The component instance- Returns:
- The component
- Throws:
UnsupportedOperationException
- In every case
-
writeHTML
Description copied from class:Component
Creates the component's HTML equivalentThis method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (
StringWriter
class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return withfalse
. Otherwise, it must return withtrue
.- Specified by:
writeHTML
in classComponent<ProgressBar>
- Returns:
- If the componentwas drawn,
true
, otherwisefalse
-
setVisible
Sets the visibility of the component. If not visible, the component won't appear on the interface, but it will be drawn in the HTML DOM. The visibility can be set anytime through code. By default, the component is visible- Overrides:
setVisible
in classComponent<ProgressBar>
- Parameters:
visible
- Iftrue
, the component is visible, iffalse
, it is hidden- Returns:
- The component
-
setBackgroundColor
Sets the component’s background color.- Overrides:
setBackgroundColor
in classComponent<ProgressBar>
- Parameters:
color
- The background color to be set Available colors are listed in the enumColor
.- Returns:
- Component
-