public class ProgressSpinner
extends java.lang.Object
OutputStream
.
This is class is not thread-safe. The update method may only be used from a
single thread. Updates are sent only as frequently as update()
is
invoked by the caller, and are capped at no more than 2 times per second by
requiring at least 500 milliseconds between updates.
Modifier and Type | Field and Description |
---|---|
private static long |
MIN_REFRESH_MILLIS |
private java.lang.String |
msg |
private long |
nextUpdateMillis |
private java.io.OutputStream |
out |
private boolean |
shown |
private int |
state |
private static char[] |
STATES |
private boolean |
write |
Constructor and Description |
---|
ProgressSpinner(java.io.OutputStream out)
Initialize a new spinner.
|
Modifier and Type | Method and Description |
---|---|
void |
beginTask(java.lang.String title,
long delay,
java.util.concurrent.TimeUnit delayUnits)
Begin a time consuming task.
|
void |
endTask(java.lang.String result)
Denote the current task completed.
|
private void |
send(long now) |
void |
update()
Update the spinner if it is showing.
|
private void |
write(java.lang.String s) |
private static final long MIN_REFRESH_MILLIS
private static final char[] STATES
private final java.io.OutputStream out
private java.lang.String msg
private int state
private boolean write
private boolean shown
private long nextUpdateMillis
public ProgressSpinner(java.io.OutputStream out)
out
- where to send output to.public void beginTask(java.lang.String title, long delay, java.util.concurrent.TimeUnit delayUnits)
title
- description of the task, suitable for human viewing.delay
- delay to wait before displaying anything at all.delayUnits
- unit for delay
.public void update()
private void send(long now)
public void endTask(java.lang.String result)
result
- text to print after the task's title
"$title ... $result"
.private void write(java.lang.String s)