Class Progressor

All Implemented Interfaces:
Runnable

public abstract class Progressor extends RangedRunnable<Integer>
A progress handler.
Since:
3.1.11
Author:
Joel Uckelman
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final int
     

    Fields inherited from class VASSAL.tools.concurrent.RangedRunnable

    range, submitted
  • Constructor Summary

    Constructors
    Constructor
    Description
    Progressor(int init, int max)
    Creates a Progressor with the given bounds.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int p)
    Adds some amount to the progress.
    int
    get()
    Gets the progress.
    int
    Gets the progress as a percentage.
    void
    Increments the progress.
    protected abstract void
    Updates the current progress.
    void
    set(int prog)
    Sets the progress.
    void
    setPct(int pct)
    Sets the progress as a percentage.
    protected void
    Submits this Runnable to be run on the Event Dispatch Thread.

    Methods inherited from class VASSAL.tools.concurrent.RangedRunnable

    run, setLast

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • max

      protected final int max
  • Constructor Details

    • Progressor

      public Progressor(int init, int max)
      Creates a Progressor with the given bounds.
      Parameters:
      init - the initial progress value
      max - the maximum progress value
      Throws:
      IllegalArgumentException - if init is not in [0,max]
      IllegalArgumentException - if max &lt; 0
  • Method Details

    • set

      public void set(int prog)
      Sets the progress. Setting the progress submits the Runnable only when it would result in a change in the progress percentage.
      Parameters:
      prog - the new progress value
      Throws:
      IllegalArgumentException - if prog is not in [0,max]
      IllegalArgumentException - if prog &lt;= 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

      protected abstract void run(Pair<Integer,Integer> prog)
      Updates the current progress.
      Specified by:
      run in class RangedRunnable<Integer>
      Parameters:
      prog - the range of progress since the last update
    • submit

      protected void submit()
      Submits this Runnable to be run on the Event Dispatch Thread.
      Specified by:
      submit in class RangedRunnable<Integer>