Class ProgressHelper

    • Constructor Summary

      Constructors 
      Constructor Description
      ProgressHelper()
      Creates a new helper with no listener that will report itself as the event source.
      ProgressHelper​(java.lang.Object source, ProgressListener li)
      Creates a new helper with the specified source and listener.
      ProgressHelper​(java.lang.Object source, ProgressListener li, int stepCount)
      Creates a new helper with the specified source, listener, and step count.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCompletedSteps​(int stepCount)
      Called when progress has been made to update the progress listener, if any.
      java.lang.Object getSource()
      Returns the source reported by listener events.
      void resetProgress()
      Resets the number of completed steps.
      void setCompletedSteps​(int stepCount)
      Called when progress has been made to update the progress listener, if any.
      ProgressListener setProgressListener​(ProgressListener li)
      Sets the progress listener that will listen for progress on this algorithm, replacing the existing listener (if any).
      void setSource​(java.lang.Object source)
      Sets the object that will be reported as the source of listener events.
      void setStepCount​(int steps)
      Sets the number of steps required to complete the algorithm and resets the currently completed number of steps to 0.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ProgressHelper

        public ProgressHelper()
        Creates a new helper with no listener that will report itself as the event source.
      • ProgressHelper

        public ProgressHelper​(java.lang.Object source,
                              ProgressListener li)
        Creates a new helper with the specified source and listener.
        Parameters:
        source - the source that will be passed to listener events
        li - the listener to set (may be null)
      • ProgressHelper

        public ProgressHelper​(java.lang.Object source,
                              ProgressListener li,
                              int stepCount)
        Creates a new helper with the specified source, listener, and step count.
        Parameters:
        source - the source that will be passed to listener events
        li - the listener to set (may be null)
        stepCount - the number of steps that must be executed before completion
    • Method Detail

      • setProgressListener

        public ProgressListener setProgressListener​(ProgressListener li)
        Sets the progress listener that will listen for progress on this algorithm, replacing the existing listener (if any). A listener should only be set before the algorithm begins executing, not while it is already in progress.
        Specified by:
        setProgressListener in interface MonitoredAlgorithm
        Parameters:
        li - the listener to set (may be null)
        Returns:
        the previous listener, or null
      • getSource

        public java.lang.Object getSource()
        Returns the source reported by listener events.
        Returns:
        the source that will be passed to listener events
      • setSource

        public void setSource​(java.lang.Object source)
        Sets the object that will be reported as the source of listener events. The default source is this, which is suitable if the algorithm subclasses this class.
        Parameters:
        source - the apparent source of events
      • setStepCount

        public void setStepCount​(int steps)
        Sets the number of steps required to complete the algorithm and resets the currently completed number of steps to 0. If the algorithm is multithreaded, this should be called before the threads begin executing.
        Parameters:
        steps - the number of steps that must be executed before completion
      • resetProgress

        public void resetProgress()
        Resets the number of completed steps. If the algorithm is multithreaded, this should be called before (or after) the threads start (or finish) executing.
      • setCompletedSteps

        public void setCompletedSteps​(int stepCount)
        Called when progress has been made to update the progress listener, if any. The listener will receive a new progress event if at least 100 ms have passed since the last event was fired.
        Parameters:
        stepCount - the number of steps completed
      • addCompletedSteps

        public void addCompletedSteps​(int stepCount)
        Called when progress has been made to update the progress listener, if any. This method adds to the current total number of completed steps rather than setting an explicit total, and so is suited to use with multithreaded algorithms. The listener will receive a new progress event if at least 100 ms have passed since the last event was fired.
        Parameters:
        stepCount - the number of steps completed