Class ViewJProgressBarMulti

All Implemented Interfaces:
ProgressBarInterface, ProgressChangeListener, ActionListener, MouseListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class ViewJProgressBarMulti extends ViewJProgressBar implements MouseListener
Extension of ViewJProgressBar, ViewJProgressBarMulti is used to keep track of multiple algorithms or threads at a single time. Each algorithm/thread must be registered to the multi-bar, or linked in AlgorithmBase. A progress bar will update as progress changes are fired. This class acts as like a bunch of different ViewJProgressBars, except in one frame instead of many. Unlike ViewJProgressBar, the frame will not automatically close. Even when all registered threads are completed, the frame will remain visible.
Author:
wangvg
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • barPanel

      private JPanel barPanel
      Panel containing all the progress bars as well as relevent text labels
    • algList

      private ArrayList<Runnable> algList
      List containing which runnables are registered to this listener
    • messageLocked

      private boolean messageLocked
    • actionListener

      private ActionListener actionListener
    • windowListener

      private WindowListener windowListener
    • cancelFlag

      private boolean cancelFlag
    • cancelButton

      private JButton cancelButton
    • emptyLabel

      private JLabel emptyLabel
      Label to display when there are no runnables to display or listen for.
    • emptyDisplayed

      private boolean emptyDisplayed
      Whether or not emptyLabel is currently displayed
    • gbc

      private GridBagConstraints gbc
    • hideList

      private ArrayList<JLabel> hideList
      List to determine which progress bar to hide/show
    • closeList

      private ArrayList<JLabel> closeList
      List to determine which progress bar to close
    • algCont

      List of containers that hold all the information to correctly draw each progress bar
  • Constructor Details

    • ViewJProgressBarMulti

      public ViewJProgressBarMulti(String _title, boolean _cancelFlag, ActionListener _actionListener, WindowListener _windowListener)
      Constructor to start building the frame. It mostly only needs the title for the frame. The other paramters are just being carried over from the single version.
      Parameters:
      _title - title of the frame
      _cancelFlag -
      _actionListener -
      _windowListener -
  • Method Details

    • addRunnable

      public void addRunnable(Runnable alg, String title, int min, int max)
      Basic method for registering an algorithm to the multi-bar. Should be called in conjunction with addPropertyChangeListener (in AlgorithmBase) if the algorithm is an instance of AlgorithmBase.
      Parameters:
      alg - the algorithm to register to the multi-bar
      title - the name to associate with this algorithm
      min - min progress value. Should be set to 0.
      max - max progress value. Should be set to 100.
    • addCollectionOfRunnable

      public void addCollectionOfRunnable(Collection<Runnable> algs, Collection<String> titles)
      Secondary method for registering algorithms to the multi-bar. The user can pass a collection of algorithms (which must be accompanied by a title) to register to the multi-bar. Each algorithm should already have added this as its property change listener.
      Parameters:
      algs - the collection of algorithms to register to the multi-bar
      titles - the collection of titles to assocaite with each algorithm
    • progressStateChanged

      public void progressStateChanged(ProgressChangeEvent e)
      Handle any progress changes by updating the correct progress bar attached to the throwing algorithm
      Specified by:
      progressStateChanged in interface ProgressChangeListener
      Overrides:
      progressStateChanged in class ViewJProgressBar
      Parameters:
      e - DOCUMENT ME!
    • removeAlgorithm

      public void removeAlgorithm(Runnable alg)
      Method for removing the algorithm from the frame displayed as well as removing the listener attached to it
      Parameters:
      alg - the algorithm to remove
    • setLink

      public void setLink(Runnable to, Runnable from, int min, int max)
      Create a link between two algorithms. Any progress in the child algorithm will cause updates in the given range in the parent algorithm
      Parameters:
      to - the parent algorighm
      from - the child algorithm
      min - the lower bound of where the child affects the parent
      max - the upper bound of where the child affects the parent
    • setMessage

      public void setMessage(int index, String msg)
      Updates the displayed message above a given progress bar
      Parameters:
      index - which algorithm to update
      msg - the message to display
    • updateValue

      public void updateValue(int index, int value)
      Update the specific algorithm's progress display
      Parameters:
      index - location of algorithm in the list
      value - progress value to display
    • init

      private void init()
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      This listens for when the buttons to hide or close a progress bar are clicked. It will automatically determine which bar to choose.
      Specified by:
      mouseClicked in interface MouseListener
    • mousePressed

      public void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener