Class ProgressWriter


  • @PublicAPI
    public class ProgressWriter
    extends Object
    Class to display the progress of some operation. This class can be used standalone, or as an ancestor for custom progress reporter classes.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  ProgressWriter.Logger
      Interface for retrieving messages for events (especially errors) which were suppressed during execution.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ERROR
      Log level error
      static int INFO
      Log level info
      protected long max
      The maximum value -- the higher end of the progress value.
      protected long min
      The minimum value -- the lower end of the progress value.
      protected String note
      The additional note that is displayed along with the progress message.
      protected String text
      The main progress message.
      static int WARNING
      Log level warning
    • Constructor Summary

      Constructors 
      Constructor Description
      ProgressWriter()  
      ProgressWriter​(String note, long min, long max)
      Constructs a object displaying progress and starts monitoring the elapsed time.
    • Field Detail

      • WARNING

        public static final int WARNING
        Log level warning
        Since:
        3.2.8
        See Also:
        Constant Field Values
      • min

        protected long min
        The minimum value -- the lower end of the progress value.
      • max

        protected long max
        The maximum value -- the higher end of the progress value.
      • text

        protected String text
        The main progress message.
      • note

        protected String note
        The additional note that is displayed along with the progress message.
    • Constructor Detail

      • ProgressWriter

        public ProgressWriter()
      • ProgressWriter

        public ProgressWriter​(String note,
                              long min,
                              long max)
        Constructs a object displaying progress and starts monitoring the elapsed time.
        Parameters:
        note - a short note describing the state of the operation. As the operation progresses, you can call setNote to change the note displayed. This is used, for example, in operations that iterate through a list of files to show the name of the file being processed.
        min - the lower bound of the range
        max - the upper bound of the range
    • Method Detail

      • log

        public void log​(int severity,
                        String message,
                        Throwable t)
        Log a message which needs to be retrieved for a "suppressed" event during execution. If there are ProgressWriter.Loggers added to this ProgressWriter instance, the message will be passed to those instances. If there is no ProgressWriter.Logger instance registered, the message is written to the standard error.
        Parameters:
        severity - severity of the message
        message - the logmessage
        t - optional exception
      • getProgress

        public long getProgress()
        Return the current value of the monitored progress.
        Returns:
        the current value being processed.
      • setProgress

        public void setProgress​(long nv)
        Indicate the progress of the operation being monitored.
        Parameters:
        nv - specifies the current value, between the maximum and minimum specified for this component
        See Also:
        setMinimum(long), setMaximum(long), close()
      • incProgress

        public void incProgress()
        Increments progress.
      • setVisible

        public void setVisible​(boolean visible)
        Sets visibility.
        Parameters:
        visible - true if set visible
      • close

        public void close()
        Indicate that the operation is complete.
      • getMinimum

        public long getMinimum()
        Returns the minimum value -- the lower end of the progress value.
        Returns:
        represents the minimum value
        See Also:
        setMinimum(long)
      • setMinimum

        public void setMinimum​(long m)
        Specifies the minimum value.
        Parameters:
        m - specifies the minimum value
        See Also:
        getMinimum()
      • getMaximum

        public long getMaximum()
        Returns the maximum value -- the higher end of the progress value.
        Returns:
        represents the maximum value
        See Also:
        setMaximum(long)
      • setMaximum

        public void setMaximum​(long m)
        Specifies the maximum value.
        Parameters:
        m - specifies the maximum value
        See Also:
        getMaximum()
      • setText

        public void setText​(String text)
        Sets the main text of the ProgressWriter
        Parameters:
        text - the main text
        Since:
        5.1.2
        See Also:
        getText()
      • getText

        public String getText()
        Returns the main text of the progress message.
        Returns:
        the progress message header
        Since:
        5.1.2
        See Also:
        setText(String)
      • setNote

        public void setNote​(String note)
        Specifies the additional note that is displayed along with the progress message. Used, for example, to show which file the is currently being copied during a multiple-file copy.
        Parameters:
        note - a String specifying the note to display
        See Also:
        getNote()
      • getNote

        public String getNote()
        Returns the additional note that is displayed along with the progress message.
        Returns:
        a String specifying the note to display
        See Also:
        setNote(java.lang.String)
      • getRemainingSeconds

        public long getRemainingSeconds()
        Returns the "seconds" part of the remaining time.
        Note: Does not recalculate time. Method calcExpTime() should be called before, to udate calculations.
        Returns:
        number of seconds s, where 0 ≤ s < 60
      • getRemainingMinutes

        public long getRemainingMinutes()
        Returns the "minutes" part of the remaining time.
        Note: Does not recalculate time. Method calcExpTime() should be called before, to udate calculations.
        Returns:
        number of minutes s, where 0 ≤ s < 60
      • getRemainingHours

        public long getRemainingHours()
        Returns the "hours" part of the remaining time. Note: Does not recalculate time. Method calcExpTime() should be called before, to udate calculations.
        Returns:
        number of hours s, where 0 ≤ s < 24
      • getRemainingDays

        public long getRemainingDays()
        Returns the "days" part of the remaining time. Note: Does not recalculate time. Method calcExpTime() should be called before, to udate calculations.
        Returns:
        number of hours days left
      • getExpTimeString

        public String getExpTimeString()
        Returns text for displaying the expected remaining time.
        Automatically recalculates expected time.
        Returns:
        the text representation of remaining time.
      • isCanceled

        public boolean isCanceled()
        Indicates, if the progress was canceled.
        Returns:
        true if the progress was canceled
      • setCanceled

        public void setCanceled​(boolean value)
        Specifies, if the progress was canceled.
        Parameters:
        value - set to true to cancel the operation
      • reset

        public void reset()
        Resets the state of the current progress writer.
        Since:
        JChem 5.1.2
      • clear

        public void clear()
        Clears texts except main text. This implementation clears the note.
        Since:
        JChem 5.10