Class SimpleProgressMonitor

  • All Implemented Interfaces:
    ProgressMonitor

    public class SimpleProgressMonitor
    extends Object
    implements ProgressMonitor
    A simple implementation of ProgressMonitor that prints messages to System.out.
    Author:
    Holger Knublauch
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void beginTask​(String label, int totalWork)
      Informs the progress monitor that a new task has been started, with a given number of expected steps.
      void done()
      Informs the progress monitor that all is completed.
      boolean isCanceled()
      Typically used by the (long-running) process to determine whether the user has requested cancellation.
      protected void println​(String text)  
      void setCanceled​(boolean value)
      Typically called from a parallel thread triggered by the user, this informs the progress monitor that it needs to return true for isCanceled.
      void setTaskName​(String value)
      Changes the name or label of the current task.
      void subTask​(String label)
      Sets the label that serves as sub-task, typically printed under the main task name.
      void worked​(int amount)
      Informs the progress monitor that one or more steps have been completed towards the current task (see beginTask).
    • Constructor Detail

      • SimpleProgressMonitor

        public SimpleProgressMonitor​(String name)
    • Method Detail

      • beginTask

        public void beginTask​(String label,
                              int totalWork)
        Description copied from interface: ProgressMonitor
        Informs the progress monitor that a new task has been started, with a given number of expected steps. A UI connected to the ProgressMonitor would typically display something like a progress bar and the task name.
        Specified by:
        beginTask in interface ProgressMonitor
        Parameters:
        label - the name of the task
        totalWork - the number of steps (see worked) that is expected to be needed to complete the task
      • done

        public void done()
        Description copied from interface: ProgressMonitor
        Informs the progress monitor that all is completed.
        Specified by:
        done in interface ProgressMonitor
      • isCanceled

        public boolean isCanceled()
        Description copied from interface: ProgressMonitor
        Typically used by the (long-running) process to determine whether the user has requested cancellation. The process should then find a suitable, clean termination.
        Specified by:
        isCanceled in interface ProgressMonitor
        Returns:
        true if cancel was requested
      • println

        protected void println​(String text)
      • setCanceled

        public void setCanceled​(boolean value)
        Description copied from interface: ProgressMonitor
        Typically called from a parallel thread triggered by the user, this informs the progress monitor that it needs to return true for isCanceled. Once a process has been canceled, it should not be un-canceled.
        Specified by:
        setCanceled in interface ProgressMonitor
        Parameters:
        value - true if canceled
      • subTask

        public void subTask​(String label)
        Description copied from interface: ProgressMonitor
        Sets the label that serves as sub-task, typically printed under the main task name.
        Specified by:
        subTask in interface ProgressMonitor
        Parameters:
        label - the subtask label
      • worked

        public void worked​(int amount)
        Description copied from interface: ProgressMonitor
        Informs the progress monitor that one or more steps have been completed towards the current task (see beginTask).
        Specified by:
        worked in interface ProgressMonitor
        Parameters:
        amount - the number of steps completed