public class ProgressBar extends Object implements AutoCloseable
| Constructor and Description |
|---|
ProgressBar(String task,
long initialMax)
Creates a progress bar with the specific task name and initial maximum value.
|
ProgressBar(String task,
long initialMax,
int updateIntervalMillis) |
ProgressBar(String task,
long initialMax,
int updateIntervalMillis,
PrintStream os,
ProgressBarStyle style,
String unitName,
long unitSize)
Creates a progress bar with the specific task name, initial maximum value,
customized update interval (default 1000 ms), the PrintStream to be used, and output style.
|
ProgressBar(String task,
long initialMax,
ProgressBarStyle style) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Stops this progress bar, effectively stops tracking the underlying process.
|
long |
getCurrent()
Returns the current progress.
|
String |
getExtraMessage()
Returns the extra message at the end of the progress bar.
|
long |
getMax()
Returns the maximum value of this progress bar.
|
String |
getTask()
Returns the name of this task.
|
ProgressBar |
maxHint(long n)
Gives a hint to the maximum value of the progress bar.
|
ProgressBar |
setExtraMessage(String msg)
Sets the extra message at the end of the progress bar.
|
ProgressBar |
start()
Deprecated.
Please use the Java try-with-resource pattern instead.
|
ProgressBar |
step()
Advances this progress bar by one step.
|
ProgressBar |
stepBy(long n)
Advances this progress bar by a specific amount.
|
ProgressBar |
stepTo(long n)
Advances this progress bar to the specific progress value.
|
ProgressBar |
stop()
Deprecated.
Please use the Java try-with-resource pattern instead.
|
static InputStream |
wrap(InputStream is,
ProgressBarBuilder pbb)
Wraps an
InputStream so that when read, a progress bar is shown to track the reading progress. |
static InputStream |
wrap(InputStream is,
String task)
Wraps an
InputStream so that when read, a progress bar is shown to track the reading progress. |
static <T> Iterable<T> |
wrap(Iterable<T> ts,
ProgressBarBuilder pbb)
Wraps an
Iterable so that when iterated, a progress bar is shown to track the traversal progress. |
static <T> Iterable<T> |
wrap(Iterable<T> ts,
String task)
Wraps an
Iterable so that when iterated, a progress bar is shown to track the traversal progress. |
static <T> Iterator<T> |
wrap(Iterator<T> it,
ProgressBarBuilder pbb)
Wraps an iterator so that when iterated, a progress bar is shown to track the traversal progress.
|
static <T> Iterator<T> |
wrap(Iterator<T> it,
String task)
Wraps an iterator so that when iterated, a progress bar is shown to track the traversal progress.
|
public ProgressBar(String task, long initialMax)
task - Task nameinitialMax - Initial maximum valuepublic ProgressBar(String task, long initialMax, ProgressBarStyle style)
public ProgressBar(String task, long initialMax, int updateIntervalMillis)
public ProgressBar(String task, long initialMax, int updateIntervalMillis, PrintStream os, ProgressBarStyle style, String unitName, long unitSize)
task - Task nameinitialMax - Initial maximum valueupdateIntervalMillis - Update interval (default value 1000 ms)os - Print stream (default value System.err)style - Output style (default value ProgressBarStyle.UNICODE_BLOCK)@Deprecated public ProgressBar start()
public ProgressBar stepBy(long n)
n - Step sizepublic ProgressBar stepTo(long n)
n - New progress valuepublic ProgressBar step()
public ProgressBar maxHint(long n)
n - Hint of the maximum value@Deprecated public ProgressBar stop()
public void close()
Stops this progress bar, effectively stops tracking the underlying process.
Implements the AutoCloseable interface which enables the try-with-resource
pattern with progress bars.
close in interface AutoCloseablepublic ProgressBar setExtraMessage(String msg)
msg - New messagepublic long getCurrent()
public long getMax()
public String getTask()
public String getExtraMessage()
public static <T> Iterator<T> wrap(Iterator<T> it, String task)
it - Underlying iteratortask - Task namepublic static <T> Iterator<T> wrap(Iterator<T> it, ProgressBarBuilder pbb)
it - Underlying iteratorpbb - Progress bar builderpublic static <T> Iterable<T> wrap(Iterable<T> ts, String task)
Iterable so that when iterated, a progress bar is shown to track the traversal progress.
Sample usage: for (T x : ProgressBar.wrap(collection, "Traversal")) { ... }
ts - Underlying iterabletask - Task namepublic static <T> Iterable<T> wrap(Iterable<T> ts, ProgressBarBuilder pbb)
Iterable so that when iterated, a progress bar is shown to track the traversal progress.
For this function the progress bar can be fully customized by using a ProgressBarBuilder.ts - Underlying iterablepbb - An instance of a ProgressBarBuilderpublic static InputStream wrap(InputStream is, String task)
InputStream so that when read, a progress bar is shown to track the reading progress.is - Input stream to be wrappedtask - Name of the progresspublic static InputStream wrap(InputStream is, ProgressBarBuilder pbb)
InputStream so that when read, a progress bar is shown to track the reading progress.
For this function the progress bar can be fully customized by using a ProgressBarBuilder.is - Input stream to be wrappedpbb - An instance of a ProgressBarBuilderCopyright © 2018. All rights reserved.