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
  • 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

      public ProgressBar(String id)
      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

      public ProgressBar(String title, StyleElement... styles)
      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 as null no title will appear.
      styles - The progress bar style. See the ProgressBarType 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, StyleElement... styles)
      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 as null no title will appear.
      styles - The progress bar style. See the ProgressBarType 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 as null no title will appear.
      minValue - The numerical value, representing the starting point of the process
      maxValue - The numerical value, representing the end point of the process
      autoPositionText - Determines if the progress of the operation is displayed automatically. If set to true, 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 to false the text set in the setPositionText() method will appear on the right side of the bar, which will not be refreshed automatically.
      styles - The progress bar stlye. See the ProgressBarType 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 as null no title will appear.
      minValue - The numerical value, representing the starting point of the process
      maxValue - The numerical value, representing the end point of the process
      autoPositionText - Determines if the progress of the operation is displayed automatically. If set to true, 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 to false the text set in the setPositionText() method will appear on the right side of the bar, which will not be refreshed automatically.
      styles - The progress bar stlye. See the ProgressBarType enum for the applicable styles.
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
  • Method Details

    • setSize

      public ProgressBar setSize(ProgressBarSize size)
      Sets the progress bar.
      Parameters:
      size - Progress bar size If null is specified, the progress bar is displayed using the default (DEFAULT) size. Available sizes are listed in the enum ProgressBarSize.
      Returns:
      The progress bar component
    • setMinValue

      public final ProgressBar setMinValue(int minValue)
      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

      public final ProgressBar setMaxValue(int maxValue)
      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

      public final ProgressBar setValue(int value)
      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

      public String getTitle()
      Gets the title of the assigned process
      Returns:
      The title or null if no title was specified
    • setTitle

      public final ProgressBar setTitle(String title)
      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 to null no title will be shown.
      Returns:
      The progress bar title
    • getPositionText

      public String 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

      public final ProgressBar setPositionText(String text)
      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 as null, no text will be shown. By default, the current state will be displayed in percentages.
      Returns:
      The Progress Bar component
    • addComponent

      public ProgressBar addComponent(Component component)
      No component can be added to the Progress Bar
      Overrides:
      addComponent in class Component<ProgressBar>
      Parameters:
      component - The component to be added
      Returns:
      The component
      Throws:
      UnsupportedOperationException - In every case
    • removeComponent

      public ProgressBar removeComponent(Component component)
      No component can be removed from the Progress Bar
      Overrides:
      removeComponent in class Component<ProgressBar>
      Parameters:
      component - The component instance
      Returns:
      The component
      Throws:
      UnsupportedOperationException - In every case
    • writeHTML

      public boolean writeHTML(StringWriter writer)
      Description copied from class: Component
      Creates the component's HTML equivalent

      This 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 with false. Otherwise, it must return with true.

      Specified by:
      writeHTML in class Component<ProgressBar>
      Returns:
      If the componentwas drawn, true, otherwise false
    • setVisible

      public ProgressBar setVisible(boolean visible)
      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 class Component<ProgressBar>
      Parameters:
      visible - If true, the component is visible, if false, it is hidden
      Returns:
      The component
    • setBackgroundColor

      public ProgressBar setBackgroundColor(Color color)
      Sets the component’s background color.
      Overrides:
      setBackgroundColor in class Component<ProgressBar>
      Parameters:
      color - The background color to be set Available colors are listed in the enum Color.
      Returns:
      Component