public class ProgressBar extends Object implements AutoCloseable
| Constructor and Description |
|---|
ProgressBar(String task,
long initialMax)
Creates a progress bar with the specific taskName name and initial maximum value.
|
ProgressBar(String task,
long initialMax,
int updateIntervalMillis,
boolean continuousUpdate,
long processed,
Duration elapsed,
ProgressBarRenderer renderer,
ProgressBarConsumer consumer)
Deprecated.
Use
ProgressBarBuilder instead. Will be private in future versions. |
ProgressBar(String task,
long initialMax,
int updateIntervalMillis,
boolean continuousUpdate,
PrintStream os,
ProgressBarStyle style,
String unitName,
long unitSize,
boolean showSpeed,
DecimalFormat speedFormat,
ChronoUnit speedUnit,
long processed,
Duration elapsed)
Deprecated.
Use
ProgressBarBuilder instead. |
| 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 |
getTaskName()
Returns the name of this task.
|
ProgressBar |
maxHint(long n)
Gives a hint to the maximum value of the progress bar.
|
ProgressBar |
pause()
Pauses this current progress.
|
void |
refresh()
Prompts the progress bar to refresh.
|
ProgressBar |
reset()
Resets the progress bar to its initial state (where progress equals to 0).
|
ProgressBar |
resume()
Resumes this current progress.
|
ProgressBar |
setExtraMessage(String msg)
Sets the extra message at the end of the progress bar.
|
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.
|
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.
|
static OutputStream |
wrap(OutputStream os,
ProgressBarBuilder pbb)
Wraps an
OutputStream so that when written, a progress bar is shown to track the writing progress. |
static OutputStream |
wrap(OutputStream os,
String task)
Wraps an
OutputStream so that when written, a progress bar is shown to track the writing progress. |
static Reader |
wrap(Reader reader,
ProgressBarBuilder pbb)
Wraps a
Reader so that when read, a progress bar is shown to track the reading progress. |
static Reader |
wrap(Reader reader,
String task)
Wraps a
Reader so that when read, a progress bar is shown to track the reading progress. |
static <T> Spliterator<T> |
wrap(Spliterator<T> sp,
ProgressBarBuilder pbb)
Wraps a
Spliterator so that when iterated, a progress bar is shown to track the traversal progress. |
static <T> Spliterator<T> |
wrap(Spliterator<T> sp,
String task)
Wraps a
Spliterator so that when iterated, a progress bar is shown to track the traversal progress. |
static <T,S extends BaseStream<T,S>> |
wrap(S stream,
ProgressBarBuilder pbb)
Wraps a
Stream so that when iterated, a progress bar is shown to track the traversal progress. |
static <T,S extends BaseStream<T,S>> |
wrap(S stream,
String task)
Wraps a
Stream so that when iterated, a progress bar is shown to track the traversal progress. |
static <T> Stream<T> |
wrap(T[] array,
ProgressBarBuilder pbb)
Wraps an array so that when iterated, a progress bar is shown to track the traversal progress.
|
static <T> Stream<T> |
wrap(T[] array,
String task)
Wraps an array so that when iterated, a progress bar is shown to track the traversal progress.
|
static Writer |
wrap(Writer writer,
ProgressBarBuilder pbb)
Wraps a
Writer so that when written, a progress bar is shown to track the writing progress. |
static Writer |
wrap(Writer writer,
String task)
Wraps a
Writer so that when written, a progress bar is shown to track the writing progress. |
public ProgressBar(String task, long initialMax)
task - Task nameinitialMax - Initial maximum valuepublic ProgressBar(String task, long initialMax, int updateIntervalMillis, boolean continuousUpdate, PrintStream os, ProgressBarStyle style, String unitName, long unitSize, boolean showSpeed, DecimalFormat speedFormat, ChronoUnit speedUnit, long processed, Duration elapsed)
ProgressBarBuilder instead.task - Task nameinitialMax - Initial maximum valueupdateIntervalMillis - Update interval (default value 1000 ms)continuousUpdate - Rerender every time the update interval happens regardless of progress count.style - Output style (default value ProgressBarStyle.UNICODE_BLOCK)showSpeed - Should the calculated speed be displayedspeedFormat - Speed number formatpublic ProgressBar(String task, long initialMax, int updateIntervalMillis, boolean continuousUpdate, long processed, Duration elapsed, ProgressBarRenderer renderer, ProgressBarConsumer consumer)
ProgressBarBuilder instead. Will be private in future versions.ProgressBarRenderer) and consumer (ProgressBarConsumer).task - Task nameinitialMax - Initial maximum valueupdateIntervalMillis - Update time interval (default value 1000ms)continuousUpdate - Rerender every time the update interval happens regardless of progress count.processed - Initial completed process valueelapsed - Initial elapsedBeforeStart second beforerenderer - Progress bar rendererconsumer - Progress bar consumerpublic 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. A value of -1 indicates that the progress bar is indefinite.public ProgressBar pause()
public ProgressBar resume()
public ProgressBar reset()
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 getTaskName()
public String getExtraMessage()
public void refresh()
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 ProgressBarBuilderpublic static OutputStream wrap(OutputStream os, String task)
OutputStream so that when written, a progress bar is shown to track the writing progress.os - Output stream to be wrappedtask - Name of the progresspublic static OutputStream wrap(OutputStream os, ProgressBarBuilder pbb)
OutputStream so that when written, a progress bar is shown to track the writing progress.
For this function the progress bar can be fully customized by using a ProgressBarBuilder.os - Output stream to be wrappedpbb - An instance of a ProgressBarBuilderpublic static Reader wrap(Reader reader, String task)
Reader so that when read, a progress bar is shown to track the reading progress.reader - Reader to be wrappedtask - Name of the progresspublic static Reader wrap(Reader reader, ProgressBarBuilder pbb)
Reader 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.reader - Reader to be wrappedpbb - An instance of a ProgressBarBuilderpublic static Writer wrap(Writer writer, String task)
Writer so that when written, a progress bar is shown to track the writing progress.writer - Writer to be wrappedtask - Name of the progresspublic static Writer wrap(Writer writer, ProgressBarBuilder pbb)
Writer so that when written, a progress bar is shown to track the writing progress.
For this function the progress bar can be fully customized by using a ProgressBarBuilder.writer - Writer to be wrappedpbb - An instance of a ProgressBarBuilderpublic static <T> Spliterator<T> wrap(Spliterator<T> sp, String task)
Spliterator so that when iterated, a progress bar is shown to track the traversal progress.sp - Underlying spliteratortask - Task namepublic static <T> Spliterator<T> wrap(Spliterator<T> sp, ProgressBarBuilder pbb)
Spliterator 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.sp - Underlying spliteratorpbb - An instance of a ProgressBarBuilderpublic static <T,S extends BaseStream<T,S>> Stream<T> wrap(S stream, String task)
Stream so that when iterated, a progress bar is shown to track the traversal progress.stream - Underlying stream (can be sequential or parallel)task - Task namepublic static <T,S extends BaseStream<T,S>> Stream<T> wrap(S stream, ProgressBarBuilder pbb)
Stream 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.stream - Underlying stream (can be sequential or parallel)pbb - An instance of a ProgressBarBuilderpublic static <T> Stream<T> wrap(T[] array, String task)
array - Array to be wrappedtask - Task nameStream.public static <T> Stream<T> wrap(T[] array, ProgressBarBuilder pbb)
ProgressBarBuilder.array - Array to be wrappedpbb - An instance of a ProgressBarBuilderStream.Copyright © 2022. All rights reserved.