Package VASSAL.tools.swing
Class Progressor
- All Implemented Interfaces:
Runnable
A progress handler.
- Since:
- 3.1.11
- Author:
- Joel Uckelman
-
Field Summary
FieldsFields inherited from class VASSAL.tools.concurrent.RangedRunnable
range, submitted -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int p) Adds some amount to the progress.intget()Gets the progress.intgetPct()Gets the progress as a percentage.voidIncrements the progress.protected abstract voidUpdates the current progress.voidset(int prog) Sets the progress.voidsetPct(int pct) Sets the progress as a percentage.protected voidsubmit()Submits thisRunnableto be run on the Event Dispatch Thread.Methods inherited from class VASSAL.tools.concurrent.RangedRunnable
run, setLast
-
Field Details
-
max
protected final int max
-
-
Constructor Details
-
Progressor
public Progressor(int init, int max) Creates aProgressorwith the given bounds.- Parameters:
init- the initial progress valuemax- the maximum progress value- Throws:
IllegalArgumentException- ifinitis not in[0,max]IllegalArgumentException- ifmax < 0
-
-
Method Details
-
set
public void set(int prog) Sets the progress. Setting the progress submits theRunnableonly when it would result in a change in the progress percentage.- Parameters:
prog- the new progress value- Throws:
IllegalArgumentException- ifprogis not in[0,max]IllegalArgumentException- ifprog <=current value
-
get
public int get()Gets the progress.- Returns:
- the progress value
-
increment
public void increment()Increments the progress. -
add
public void add(int p) Adds some amount to the progress. -
setPct
public void setPct(int pct) Sets the progress as a percentage.- Parameters:
pct- the progress percentage
-
getPct
public int getPct()Gets the progress as a percentage.- Returns:
- the progress percentage
-
run
Updates the current progress.- Specified by:
runin classRangedRunnable<Integer>- Parameters:
prog- the range of progress since the last update
-
submit
protected void submit()Submits thisRunnableto be run on the Event Dispatch Thread.- Specified by:
submitin classRangedRunnable<Integer>
-