com.partnersoft.gui
Class ProgressBar

java.lang.Object
  extended by javax.swing.SwingWorker
      extended by com.partnersoft.gui.ProgressBar
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.lang.Runnable, java.util.concurrent.Future, java.util.concurrent.RunnableFuture, java.util.EventListener

public abstract class ProgressBar
extends javax.swing.SwingWorker
implements java.beans.PropertyChangeListener

Simpler Progress Bar. Extend this class, putting all work to monitor in doInBackground(). Remember to call setProgress() as work is completed. showBar() and hideBar() are helpers to display a JFrame with this progress bar in it. They can be called from within doInBackground().

Copyright 2008 Partner Software, Inc.

Version:
$Id$
Author:
Rich Stepanski

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.SwingWorker
javax.swing.SwingWorker.StateValue
 
Constructor Summary
ProgressBar()
          Creates a new InspectionProgressBar.
ProgressBar(int min, int max, boolean paintStrings)
          Creates a new InspectionProgressBar.
 
Method Summary
protected abstract  java.lang.Object doInBackground()
          This method must contain the work this progress bar will monitor.
 javax.swing.JFrame getBarDialog()
          Returns the JFrame used to display JProgressBar by this class.
 javax.swing.JProgressBar getGui()
          Returns the progress bar.
 void hideBar()
          Hides the internal JFrame containing our progress bar.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          Updates the progress bar from our doInBackground()
 void runTask()
          Starts the task that is being monitored.
 void setIndeterminate(boolean isIndeterminate)
          Sets indeterminate mode.
 void showBar(java.lang.String title)
          Displays a JFrame with the specified title containing our JProgressBar.
 void showBar(java.lang.String title, javax.swing.JComponent gui)
          Displays a JFrame with the specified title and gui contents.
 void showBar(java.lang.String title, javax.swing.JComponent gui, int x, int y)
          Displays a JFrame with the specified title and gui contents.
 void showBar(java.lang.String title, javax.swing.JComponent gui, int x, int y, int width, int height)
          Displays a JFrame with the specified title and gui contents.
 void showBar(java.lang.String title, javax.swing.JComponent gui, MapApp centerOnApp, int width, int height)
          Displays a JFrame with the specified title, centered on the passed MapApp's gui window center.
 
Methods inherited from class javax.swing.SwingWorker
addPropertyChangeListener, cancel, done, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, process, publish, removePropertyChangeListener, run, setProgress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgressBar

public ProgressBar(int min,
                   int max,
                   boolean paintStrings)
Creates a new InspectionProgressBar.

Parameters:
min - - value to start progress at.
max - - max value for progress.
paintStrings - - if true, % complete is drawn on bar.

ProgressBar

public ProgressBar()
Creates a new InspectionProgressBar. Progress begins at 0, max progress is 100, and % complete is shown on the progress bar.

Method Detail

doInBackground

protected abstract java.lang.Object doInBackground()
                                            throws java.lang.Exception
This method must contain the work this progress bar will monitor. Don't forget to call setProgress(x). Where min <= x <= max. Note: DO NOT CALL THIS METHOD DIRECTLY

Specified by:
doInBackground in class javax.swing.SwingWorker
Throws:
java.lang.Exception

runTask

public final void runTask()
Starts the task that is being monitored.


propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Updates the progress bar from our doInBackground()

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

getGui

public javax.swing.JProgressBar getGui()
Returns the progress bar.

Returns:
- the JProgressBar

hideBar

public void hideBar()
Hides the internal JFrame containing our progress bar. Only works in conjunction with showBar().


setIndeterminate

public void setIndeterminate(boolean isIndeterminate)
Sets indeterminate mode.

Parameters:
isIndeterminate - - if true, sets progress bar to indeterminate, determinate mode otherwise.

showBar

public void showBar(java.lang.String title,
                    javax.swing.JComponent gui)
Displays a JFrame with the specified title and gui contents.

Parameters:
title - - Title for JFrame
gui - - Contents for JFrame

showBar

public void showBar(java.lang.String title)
Displays a JFrame with the specified title containing our JProgressBar.

Parameters:
title - - title for JFrame.

getBarDialog

public javax.swing.JFrame getBarDialog()
Returns the JFrame used to display JProgressBar by this class. JFrame is only setup if showFrame() was called.

Returns:
- JFrame containing JProgressBar.

showBar

public void showBar(java.lang.String title,
                    javax.swing.JComponent gui,
                    int x,
                    int y)
Displays a JFrame with the specified title and gui contents. Frame is opened at the passed screen location.

Parameters:
title - - title of JFrame
gui - - gui contents for JFrame
x - - screen x location for JFrame
y - - screen y location for JFrame

showBar

public void showBar(java.lang.String title,
                    javax.swing.JComponent gui,
                    int x,
                    int y,
                    int width,
                    int height)
Displays a JFrame with the specified title and gui contents. Frame is opened at the passed screen location with passed dimensions.

Parameters:
title - - title of JFrame
gui - - gui contents for JFrame
x - - screen x location for JFrame
y - - screen y location for JFrame
width - - width in pixels
height - - height in pixels

showBar

public void showBar(java.lang.String title,
                    javax.swing.JComponent gui,
                    MapApp centerOnApp,
                    int width,
                    int height)
Displays a JFrame with the specified title, centered on the passed MapApp's gui window center. Uses specified width and height to set the JFrame's dimensions.

Parameters:
title - - title of JFrame
gui - - gui contents for JFrame
centerOnApp - - MapApp of the viewer instance to center on.
width - - width in pixels
height - - height in pixels