Class ViewJProgressBarMulti

  • All Implemented Interfaces:
    ProgressBarInterface, ProgressChangeListener, java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

    public class ViewJProgressBarMulti
    extends ViewJProgressBar
    implements java.awt.event.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:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private class  ViewJProgressBarMulti.AlgoContainer
      A container class that holds all the information to correctly draw each progress bar.
      private class  ViewJProgressBarMulti.Linking
      Very basic structure to update determine which algorithm is linked, and over what range.
      • Nested classes/interfaces inherited from class javax.swing.JFrame

        javax.swing.JFrame.AccessibleJFrame
      • Nested classes/interfaces inherited from class java.awt.Frame

        java.awt.Frame.AccessibleAWTFrame
      • Nested classes/interfaces inherited from class java.awt.Window

        java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.awt.event.ActionListener actionListener  
      private java.util.ArrayList<ViewJProgressBarMulti.AlgoContainer> algCont
      List of containers that hold all the information to correctly draw each progress bar
      private java.util.ArrayList<java.lang.Runnable> algList
      List containing which runnables are registered to this listener
      private javax.swing.JPanel barPanel
      Panel containing all the progress bars as well as relevent text labels
      private javax.swing.JButton cancelButton  
      private boolean cancelFlag  
      private java.util.ArrayList<javax.swing.JLabel> closeList
      List to determine which progress bar to close
      private boolean emptyDisplayed
      Whether or not emptyLabel is currently displayed
      private javax.swing.JLabel emptyLabel
      Label to display when there are no runnables to display or listen for.
      private java.awt.GridBagConstraints gbc  
      private java.util.ArrayList<javax.swing.JLabel> hideList
      List to determine which progress bar to hide/show
      private boolean messageLocked  
      private static long serialVersionUID  
      private java.awt.event.WindowListener windowListener  
      • Fields inherited from class javax.swing.JFrame

        accessibleContext, rootPane, rootPaneCheckingEnabled
      • Fields inherited from class java.awt.Frame

        CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
      • Fields inherited from class java.awt.Component

        BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
      • Fields inherited from interface javax.swing.WindowConstants

        DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
    • Constructor Summary

      Constructors 
      Constructor Description
      ViewJProgressBarMulti​(java.lang.String _title, boolean _cancelFlag, java.awt.event.ActionListener _actionListener, java.awt.event.WindowListener _windowListener)
      Constructor to start building the frame.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCollectionOfRunnable​(java.util.Collection<java.lang.Runnable> algs, java.util.Collection<java.lang.String> titles)
      Secondary method for registering algorithms to the multi-bar.
      void addRunnable​(java.lang.Runnable alg, java.lang.String title, int min, int max)
      Basic method for registering an algorithm to the multi-bar.
      private void init()  
      void mouseClicked​(java.awt.event.MouseEvent e)
      This listens for when the buttons to hide or close a progress bar are clicked.
      void mouseEntered​(java.awt.event.MouseEvent e)  
      void mouseExited​(java.awt.event.MouseEvent e)  
      void mousePressed​(java.awt.event.MouseEvent e)  
      void mouseReleased​(java.awt.event.MouseEvent e)  
      void progressStateChanged​(ProgressChangeEvent e)
      Handle any progress changes by updating the correct progress bar attached to the throwing algorithm
      void removeAlgorithm​(java.lang.Runnable alg)
      Method for removing the algorithm from the frame displayed as well as removing the listener attached to it
      void setLink​(java.lang.Runnable to, java.lang.Runnable from, int min, int max)
      Create a link between two algorithms.
      void setMessage​(int index, java.lang.String msg)
      Updates the displayed message above a given progress bar
      void updateValue​(int index, int value)
      Update the specific algorithm's progress display
      • Methods inherited from class javax.swing.JFrame

        addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
      • Methods inherited from class java.awt.Frame

        addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setUndecorated
      • Methods inherited from class java.awt.Window

        addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, show, toBack, toFront
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.awt.MenuContainer

        getFont, postEvent
    • Field Detail

      • barPanel

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

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

        private boolean messageLocked
      • actionListener

        private java.awt.event.ActionListener actionListener
      • windowListener

        private java.awt.event.WindowListener windowListener
      • cancelFlag

        private boolean cancelFlag
      • cancelButton

        private javax.swing.JButton cancelButton
      • emptyLabel

        private javax.swing.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 java.awt.GridBagConstraints gbc
      • hideList

        private java.util.ArrayList<javax.swing.JLabel> hideList
        List to determine which progress bar to hide/show
      • closeList

        private java.util.ArrayList<javax.swing.JLabel> closeList
        List to determine which progress bar to close
    • Constructor Detail

      • ViewJProgressBarMulti

        public ViewJProgressBarMulti​(java.lang.String _title,
                                     boolean _cancelFlag,
                                     java.awt.event.ActionListener _actionListener,
                                     java.awt.event.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 Detail

      • addRunnable

        public void addRunnable​(java.lang.Runnable alg,
                                java.lang.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​(java.util.Collection<java.lang.Runnable> algs,
                                            java.util.Collection<java.lang.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
      • removeAlgorithm

        public void removeAlgorithm​(java.lang.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​(java.lang.Runnable to,
                            java.lang.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,
                               java.lang.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​(java.awt.event.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 java.awt.event.MouseListener
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent e)
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent e)
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
      • mouseEntered

        public void mouseEntered​(java.awt.event.MouseEvent e)
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
      • mouseExited

        public void mouseExited​(java.awt.event.MouseEvent e)
        Specified by:
        mouseExited in interface java.awt.event.MouseListener