Package chemaxon.jchem.file
Class ProgressWriter
java.lang.Object
chemaxon.jchem.file.ProgressWriter
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
Modifier and TypeClassDescriptionstatic interface
Interface for retrieving messages for events (especially errors) which were suppressed during execution. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Log level errorstatic final int
Log level infoprotected 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
ConstructorDescriptionProgressWriter
(String note, long min, long max) Constructs a object displaying progress and starts monitoring the elapsed time. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLogger
(ProgressWriter.Logger logger) Adds aProgressWriter.Logger
to retrieve suppressed (error) messages.void
Recalculates expected time.void
clear()
Clears texts except main text.void
close()
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.getNote()
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.getText()
Returns the main text of the progress message.void
Increments progress.boolean
Indicates, if the progress was canceled.void
Log a message which needs to be retrieved for a "suppressed" event during execution.void
reset()
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 ProgressWritervoid
setVisible
(boolean visible) Sets visibility.
-
Field Details
-
ERROR
public static final int ERRORLog level error- Since:
- 3.2.8
- See Also:
-
WARNING
public static final int WARNINGLog level warning- Since:
- 3.2.8
- See Also:
-
INFO
public static final int INFOLog level info- Since:
- 3.2.8
- See Also:
-
min
protected long minThe minimum value -- the lower end of the progress value. -
max
protected long maxThe maximum value -- the higher end of the progress value. -
text
The main progress message. -
note
The additional note that is displayed along with the progress message.
-
-
Constructor Details
-
ProgressWriter
public ProgressWriter() -
ProgressWriter
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 rangemax
- the upper bound of the range
-
-
Method Details
-
addLogger
Adds aProgressWriter.Logger
to retrieve suppressed (error) messages.- Parameters:
logger
- logger to distribute messages to.
-
log
Log a message which needs to be retrieved for a "suppressed" event during execution. If there areProgressWriter.Logger
s added to thisProgressWriter
instance, the message will be passed to those instances. If there is noProgressWriter.Logger
instance registered, the message is written to the standard error.- Parameters:
severity
- severity of the messagemessage
- the logmessaget
- 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
Sets the main text of the ProgressWriter- Parameters:
text
- the main text- Since:
- 5.1.2
- See Also:
-
getText
Returns the main text of the progress message.- Returns:
- the progress message header
- Since:
- 5.1.2
- See Also:
-
setNote
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
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. MethodcalcExpTime()
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. MethodcalcExpTime()
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. MethodcalcExpTime()
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. MethodcalcExpTime()
should be called before, to udate calculations.- Returns:
- number of hours days left
-
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 callinggetRemainingSeconds()
,getRemainingMinutes()
,getRemainingHours()
andgetRemainingDays()
. -
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 totrue
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
-