Class InterfaceProgressBar

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
mgui.interfaces.gui.InterfaceProgressBar
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, ProgressUpdater

public class InterfaceProgressBar
extends javax.swing.JPanel
implements java.beans.PropertyChangeListener, ProgressUpdater, java.awt.event.ActionListener
Panel to be used as a progress bar for all operations which require one. All methods requiring such functionality should accept an instance of the ProgressUpdater interface as an argument, and if the updater is an instance of InterfaceProgressBar, should run a Foxtrot Job or Task thread.

To show in an InterfaceDisplayPanel, this progress bar must be registered using the register method. To remove it once a job is done, the deregister method must be called.

Policy: Utility classes will update progress bars, and register and deregister them. Registration must be done from the EDT; only those methods indicated are safe to call from a Worker Thread; including: update, setMinimum, setMaximum, and setMode.

Since:
1.0
Version:
1.0
Author:
Andrew Reid
See Also:
Serialized Form
  • Nested Class Summary

    Nested classes/interfaces inherited from class javax.swing.JPanel

    javax.swing.JPanel.AccessibleJPanel

    Nested classes/interfaces inherited from class javax.swing.JComponent

    javax.swing.JComponent.AccessibleJComponent

    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

    Nested classes/interfaces inherited from interface mgui.interfaces.ProgressUpdater

    ProgressUpdater.Mode
  • Field Summary

    Fields
    Modifier and Type Field Description
    boolean isDestroyed  
    javax.swing.JProgressBar progressBar  

    Fields inherited from class javax.swing.JComponent

    listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW

    Fields inherited from class java.awt.Component

    accessibleContext, 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
  • Constructor Summary

    Constructors
    Constructor Description
    InterfaceProgressBar()  
    InterfaceProgressBar​(java.lang.String message)  
    InterfaceProgressBar​(java.lang.String message, int min, int max)  
    InterfaceProgressBar​(java.lang.String message, int min, int max, boolean allow_changes)  
  • Method Summary

    Modifier and Type Method Description
    void actionPerformed​(java.awt.event.ActionEvent e)  
    boolean allowChanges()
    Allow processes to change the settings of this progress bar? Implementing classes can choose whether or not to enforce this.
    void cancel()
    Cancels execution of the process monitored by this updater.
    void deregister()
    Deregisters this progress bar with its display panel (i.e., by calling deregisterProgressBar()).
    int getMaximum()  
    int getMinimum()  
    javax.swing.JProgressBar getProgressBar()
    Returns the instance of JProgressBar used to render this panel.
    boolean isCancelled()
    Indicates whether the monitored process has been cancelled
    boolean isRegistered()  
    void iterate()
    Increment progress by 1
    void propertyChange​(java.beans.PropertyChangeEvent evt)  
    void register()
    Registers this progress bar with its display panel (i.e., by calling registerProgressBar().
    void reset()
    Resets the progress bar with its minimum and maximum values.
    void setIndeterminate​(boolean b)
    Sets whether this progress updater should be considered indeterminate; i.e., progress cannot be estimated.
    void setMaximum​(int max)
    Sets the maximum for this progress bar.
    void setMessage​(java.lang.String message)
    Sets this progress bar's message.
    void setMinimum​(int min)
    Sets the maximum for this progress bar.
    void setMode​(ProgressUpdater.Mode mode)
    Sets the mode of this progress bar; one of Mode.Determinate or Mode.Indeterminate.
    void setSize​(int width, int height)  
    void setValue​(int progress)
    Sets the current value of the progress bar
    void update​(int value)
    Uodates the value of this progress indicator

    Methods inherited from class javax.swing.JPanel

    getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI

    Methods inherited from class javax.swing.JComponent

    addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update

    Methods inherited from class java.awt.Container

    add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • progressBar

      public javax.swing.JProgressBar progressBar
    • isDestroyed

      public boolean isDestroyed
  • Constructor Details

    • InterfaceProgressBar

      public InterfaceProgressBar()
    • InterfaceProgressBar

      public InterfaceProgressBar​(java.lang.String message)
    • InterfaceProgressBar

      public InterfaceProgressBar​(java.lang.String message, int min, int max)
    • InterfaceProgressBar

      public InterfaceProgressBar​(java.lang.String message, int min, int max, boolean allow_changes)
  • Method Details

    • setIndeterminate

      public void setIndeterminate​(boolean b)
      Description copied from interface: ProgressUpdater
      Sets whether this progress updater should be considered indeterminate; i.e., progress cannot be estimated.
      Specified by:
      setIndeterminate in interface ProgressUpdater
    • allowChanges

      public boolean allowChanges()
      Description copied from interface: ProgressUpdater
      Allow processes to change the settings of this progress bar? Implementing classes can choose whether or not to enforce this.
      Specified by:
      allowChanges in interface ProgressUpdater
      Returns:
    • setMode

      public void setMode​(ProgressUpdater.Mode mode)
      Sets the mode of this progress bar; one of Mode.Determinate or Mode.Indeterminate. Calls SwingUtilities.invokeLater, so safe to call from a Thread.
      Specified by:
      setMode in interface ProgressUpdater
    • cancel

      public void cancel()
      Description copied from interface: ProgressUpdater
      Cancels execution of the process monitored by this updater. The process must respect the cancel notification for this call to have effect.
      Specified by:
      cancel in interface ProgressUpdater
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: ProgressUpdater
      Indicates whether the monitored process has been cancelled
      Specified by:
      isCancelled in interface ProgressUpdater
      Returns:
    • setMinimum

      public void setMinimum​(int min)
      Sets the maximum for this progress bar. Calls SwingUtilities.invokeLater, so safe to call from a Thread.
      Specified by:
      setMinimum in interface ProgressUpdater
    • setMaximum

      public void setMaximum​(int max)
      Sets the maximum for this progress bar. Calls SwingUtilities.invokeLater, so safe to call from a Thread.
      Specified by:
      setMaximum in interface ProgressUpdater
    • getMinimum

      public int getMinimum()
      Specified by:
      getMinimum in interface ProgressUpdater
    • getMaximum

      public int getMaximum()
      Specified by:
      getMaximum in interface ProgressUpdater
    • setMessage

      public void setMessage​(java.lang.String message)
      Sets this progress bar's message. Calls SwingUtilities.invokeLater, so safe to call from a Thread.
      Specified by:
      setMessage in interface ProgressUpdater
    • setSize

      public void setSize​(int width, int height)
      Overrides:
      setSize in class java.awt.Component
    • reset

      public void reset()
      Resets the progress bar with its minimum and maximum values.
      Specified by:
      reset in interface ProgressUpdater
    • setValue

      public void setValue​(int progress)
      Sets the current value of the progress bar
      Parameters:
      progress -
    • getProgressBar

      public javax.swing.JProgressBar getProgressBar()
      Returns the instance of JProgressBar used to render this panel.
      Returns:
    • register

      public void register()
      Registers this progress bar with its display panel (i.e., by calling registerProgressBar(). This effectively shows the progress bar in the display panel so the user can see it.

      Note: must be called from EDT

      Specified by:
      register in interface ProgressUpdater
      See Also:
      InterfaceDisplayPanel.registerProgressBar
    • deregister

      public void deregister()
      Deregisters this progress bar with its display panel (i.e., by calling deregisterProgressBar()). This effectively removes the progress bar from the panel.

      Note: must be called from EDT

      Specified by:
      deregister in interface ProgressUpdater
      See Also:
      InterfaceDisplayPanel.deregisterProgressBar
    • isRegistered

      public boolean isRegistered()
    • propertyChange

      public void propertyChange​(java.beans.PropertyChangeEvent evt)
      Specified by:
      propertyChange in interface java.beans.PropertyChangeListener
    • iterate

      public void iterate()
      Description copied from interface: ProgressUpdater
      Increment progress by 1
      Specified by:
      iterate in interface ProgressUpdater
    • update

      public void update​(int value)
      Description copied from interface: ProgressUpdater
      Uodates the value of this progress indicator
      Specified by:
      update in interface ProgressUpdater
    • actionPerformed

      public void actionPerformed​(java.awt.event.ActionEvent e)
      Specified by:
      actionPerformed in interface java.awt.event.ActionListener