Class MultiProgress

java.lang.Object
com.codename1.cli.MultiProgress
All Implemented Interfaces:
AutoCloseable

public final class MultiProgress extends Object implements AutoCloseable

Several progress bars drawn together, one line each, for work that runs in parallel:

try (MultiProgress all = new MultiProgress()) {
    ProgressBar a = all.add("images", 120);
    ProgressBar b = all.add("videos", 8);
    // ... a.step() and b.step() from any thread ...
    all.println("skipped broken.png");
}

On a terminal the bars are redrawn ten times a second by a background thread, so a bar that is not stepped still shows its rate and an unknown total still animates; stepping only updates numbers and is cheap from any thread. Off a terminal each bar prints a line as it passes every tenth of its total (at most one a second) and a final line when it completes.

  • Constructor Summary

    Constructors
    Constructor
    Description
    A group on standard output.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(String label, long total)
    Adds a bar for total units of work; a total of 0 or less is unknown and the bar animates without a percentage.
    void
    Stops redrawing and leaves the final state of every bar on screen; bars still running are shown as they are.
    boolean
    Whether the bars redraw in place.
    void
    Prints text above the bars.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MultiProgress

      public MultiProgress()
      A group on standard output.
  • Method Details

    • add

      public ProgressBar add(String label, long total)
      Adds a bar for total units of work; a total of 0 or less is unknown and the bar animates without a percentage.
    • println

      public void println(String text)
      Prints text above the bars.
    • isLive

      public boolean isLive()
      Whether the bars redraw in place.
    • close

      public void close()
      Stops redrawing and leaves the final state of every bar on screen; bars still running are shown as they are.
      Specified by:
      close in interface AutoCloseable