Class ProgressWriter

java.lang.Object
chemaxon.jchem.file.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 
    Interface for retrieving messages for events (especially errors) which were suppressed during execution.
  • Field Summary

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

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

    Modifier and Type
    Method
    Description
    void
    Adds a ProgressWriter.Logger to retrieve suppressed (error) messages.
    void
    Recalculates expected time.
    void
    Clears texts except main text.
    void
    Indicate that the operation is complete.
    Returns text for displaying the expected remaining time.
    long
    Returns the maximum value -- the higher end of the progress value.
    long
    Returns the minimum value -- the lower end of the progress value.
    Returns the additional note that is displayed along with the progress message.
    long
    Return the current value of the monitored progress.
    long
    Returns the "days" part of the remaining time.
    long
    Returns the "hours" part of the remaining time.
    long
    Returns the "minutes" part of the remaining time.
    long
    Returns the "seconds" part of the remaining time.
    Returns the main text of the progress message.
    void
    Increments progress.
    boolean
    Indicates, if the progress was canceled.
    void
    log(int severity, String message, Throwable t)
    Log a message which needs to be retrieved for a "suppressed" event during execution.
    void
    Resets the state of the current progress writer.
    void
    setCanceled(boolean value)
    Specifies, if the progress was canceled.
    void
    setMaximum(long m)
    Specifies the maximum value.
    void
    setMinimum(long m)
    Specifies the minimum value.
    void
    Specifies the additional note that is displayed along with the progress message.
    void
    setProgress(long nv)
    Indicate the progress of the operation being monitored.
    void
    Sets the main text of the ProgressWriter
    void
    setVisible(boolean visible)
    Sets visibility.

    Methods inherited from class java.lang.Object

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

    • ERROR

      public static final int ERROR
      Log level error
      Since:
      3.2.8
      See Also:
    • WARNING

      public static final int WARNING
      Log level warning
      Since:
      3.2.8
      See Also:
    • INFO

      public static final int INFO
      Log level info
      Since:
      3.2.8
      See Also:
    • 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 Details

    • 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 Details

    • addLogger

      public void addLogger(ProgressWriter.Logger logger)
      Adds a ProgressWriter.Logger to retrieve suppressed (error) messages.
      Parameters:
      logger - logger to distribute messages to.
    • 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:
    • 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

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

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

      public void setMaximum(long m)
      Specifies the maximum value.
      Parameters:
      m - specifies the maximum value
      See Also:
    • 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

      public String getText()
      Returns the main text of the progress message.
      Returns:
      the progress message header
      Since:
      5.1.2
      See Also:
    • 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

      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:
    • 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.
    • calcExpTime

      public void calcExpTime()
      Recalculates expected time.
      This method should be called once, before calling getRemainingSeconds(), getRemainingMinutes(), getRemainingHours() and getRemainingDays().
    • 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