edu.northwestern.at.utils.swing
Class ProgressLabelAdapter

java.lang.Object
  extended by edu.northwestern.at.utils.swing.ProgressLabelAdapter
All Implemented Interfaces:
ProgressReporter

public class ProgressLabelAdapter
extends java.lang.Object
implements ProgressReporter

Wraps a JLabel with a progress reporter.


Field Summary
protected  boolean cancelled
          True if progress panel cancelled.
protected  java.awt.event.ActionListener cancelPressed
          Handle Cancel button pressed.
protected  int currentBarValue
          Current progress bar value.
protected static long defaultStartupDelay
          Default startup delay = 1.5 seconds.
protected  javax.swing.JLabel label
          Label for explanatory message.
protected  java.awt.Color labelColor
          The label color.
protected  java.lang.String labelText
          The current value of the explanatory message.
protected  int labelWidth
          Nice wide label size.
protected  int maxBar
          Maximum value for progress bar.
protected  int minBar
          Minimum value for progress bar.
protected  boolean nowIndeterminate
          True if the progress display is indeterminate.
protected  boolean nowVisible
          True if the progress display is visible.
static int ONE_SECOND
          One second in thousandths of a second.
protected  javax.swing.JLabel progressLabel
          Label displaying how far work has progressed.
protected static java.lang.String[] spinChars
          Display characters for indeterminate mode.
protected  int spinCount
          Spin count for indeterminate mode.
protected  long startupDelay
          How many milliseconds to wait before displaying dialog.
protected  long startupTime
          Startup time for dialog.
protected  javax.swing.Timer timer
          The timer used to update the display a one second intervals.
protected  javax.swing.JLabel titleLabel
          Title.
protected  java.lang.String titleText
          The current value of the title.
 
Constructor Summary
ProgressLabelAdapter(javax.swing.JLabel progressLabel, java.lang.String title, java.lang.String initLabel, int minBar, int maxBar, long startupDelay)
          Create progress label adapter.
 
Method Summary
 void close()
          Close.
protected  void doCancel()
          Action to take when cancel button pressed.
protected  void doClose()
          Action to take when panel closed.
 java.awt.event.ActionListener getCancelPressedAction()
          Return cancel action listener.
 int getCurrentBarValue()
          Get the current bar value.
 int getMaximumBarValue()
          Get the maximum bar value.
 boolean isCancelled()
          See if progress panel cancelled.
 void makeVisible(boolean visible)
          Make the dialog visible or invisble.
 void setIndeterminate(boolean isIndeterminate)
          Set tbe progress bar determinate/indeterminate state.
 void setLabelColor(java.awt.Color color)
          Set the progress label text color.
 void setMaximumBarValue(int maxBar)
          Set maximum bar value.
 void setStartupTime(long startupTime)
          Set the startup time.
 void setTitle(java.lang.String title)
          Set the title.
 void updateProgress(int newBarValue)
          Update progress display.
 void updateProgress(int newBarValue, java.lang.String newLabelText)
          Update progress display.
 void updateProgress(java.lang.String newLabelText)
          Update progress display.
protected  void updateProgressDisplay()
          Updates the progress display.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minBar

protected int minBar
Minimum value for progress bar.


maxBar

protected int maxBar
Maximum value for progress bar.


titleLabel

protected javax.swing.JLabel titleLabel
Title.


titleText

protected java.lang.String titleText
The current value of the title.


label

protected javax.swing.JLabel label
Label for explanatory message.


labelText

protected java.lang.String labelText
The current value of the explanatory message.


labelColor

protected java.awt.Color labelColor
The label color.


progressLabel

protected javax.swing.JLabel progressLabel
Label displaying how far work has progressed.


currentBarValue

protected int currentBarValue
Current progress bar value.


cancelled

protected boolean cancelled
True if progress panel cancelled.


defaultStartupDelay

protected static long defaultStartupDelay
Default startup delay = 1.5 seconds.


startupDelay

protected long startupDelay
How many milliseconds to wait before displaying dialog.


startupTime

protected long startupTime
Startup time for dialog.


labelWidth

protected int labelWidth
Nice wide label size.


nowVisible

protected boolean nowVisible
True if the progress display is visible.


nowIndeterminate

protected boolean nowIndeterminate
True if the progress display is indeterminate.


spinCount

protected int spinCount
Spin count for indeterminate mode.


spinChars

protected static final java.lang.String[] spinChars
Display characters for indeterminate mode.


timer

protected javax.swing.Timer timer
The timer used to update the display a one second intervals.


ONE_SECOND

public static final int ONE_SECOND
One second in thousandths of a second.

See Also:
Constant Field Values

cancelPressed

protected java.awt.event.ActionListener cancelPressed
Handle Cancel button pressed.

Constructor Detail

ProgressLabelAdapter

public ProgressLabelAdapter(javax.swing.JLabel progressLabel,
                            java.lang.String title,
                            java.lang.String initLabel,
                            int minBar,
                            int maxBar,
                            long startupDelay)
Create progress label adapter.

Parameters:
progressLabel - Label wrapped for displaying progress.
title - Title for progress display.
initLabel - Initial text of label.
minBar - Minimum value for progress bar.
maxBar - Maximum value for progress bar.
startupDelay - Startup delay. Dialog will not appear until this many milliseconds have passed since creation of dialog.
Method Detail

setTitle

public void setTitle(java.lang.String title)
Set the title.

Specified by:
setTitle in interface ProgressReporter
Parameters:
title - The title.

doCancel

protected void doCancel()
Action to take when cancel button pressed.

Override this in derived subclasses to take a specified action when the cancel button is pressed. The only required action is to set the class variable "cancelled" to true.


getCancelPressedAction

public java.awt.event.ActionListener getCancelPressedAction()
Return cancel action listener.

Returns:
Action listener for cancel button.

Use to create a cancel button externally.


doClose

protected void doClose()
Action to take when panel closed.

Override this in derived subclasses to take a specified action when the panel is closed.


isCancelled

public boolean isCancelled()
See if progress panel cancelled.

Specified by:
isCancelled in interface ProgressReporter
Returns:
True if cancelled, false otherwise.

setStartupTime

public void setStartupTime(long startupTime)
Set the startup time.

Specified by:
setStartupTime in interface ProgressReporter
Parameters:
startupTime - The startup time in milliseconds.

updateProgress

public void updateProgress(int newBarValue,
                           java.lang.String newLabelText)
Update progress display.

Specified by:
updateProgress in interface ProgressReporter
Parameters:
newBarValue - New value for progress bar. If negative, the current value remains unchanged.
newLabelText - New label text. If null, the current label text is unchanged.

updateProgress

public void updateProgress(int newBarValue)
Update progress display.

Specified by:
updateProgress in interface ProgressReporter
Parameters:
newBarValue - New value for progress bar.

updateProgress

public void updateProgress(java.lang.String newLabelText)
Update progress display.

Specified by:
updateProgress in interface ProgressReporter
Parameters:
newLabelText - New label text. If null, the current label text is unchanged.

setLabelColor

public void setLabelColor(java.awt.Color color)
Set the progress label text color.

Specified by:
setLabelColor in interface ProgressReporter
Parameters:
color - Text color for progress label.

setMaximumBarValue

public void setMaximumBarValue(int maxBar)
Set maximum bar value.

Specified by:
setMaximumBarValue in interface ProgressReporter
Parameters:
maxBar - The new maximum bar value.

getCurrentBarValue

public int getCurrentBarValue()
Get the current bar value.

Specified by:
getCurrentBarValue in interface ProgressReporter
Returns:
The current bar value.

getMaximumBarValue

public int getMaximumBarValue()
Get the maximum bar value.

Specified by:
getMaximumBarValue in interface ProgressReporter
Returns:
The maximum value.

setIndeterminate

public void setIndeterminate(boolean isIndeterminate)
Set tbe progress bar determinate/indeterminate state.

Specified by:
setIndeterminate in interface ProgressReporter
Parameters:
isIndeterminate - true if indeterminate, false otherwise.

makeVisible

public void makeVisible(boolean visible)
Make the dialog visible or invisble.

Specified by:
makeVisible in interface ProgressReporter
Parameters:
visible - true to show dialog, false to hide.

close

public void close()
Close.

Specified by:
close in interface ProgressReporter

updateProgressDisplay

protected void updateProgressDisplay()
Updates the progress display.

UpdateProgress is guaranteed to run on the AWT event thread since it is called from the timer's actionPerformed handler method.