Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class MultiProgress

  1. Object
  2. MultiProgress

ImplementsAutoCloseable

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.

Constructors

public MultiProgress()A group on standard output.

Methods

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.
public void println(String text)Prints text above the bars.
public boolean isLive()Whether the bars redraw in place.
public void close()Stops redrawing and leaves the final state of every bar on screen; bars still running are shown as they are.

Inherited methods

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.