Package gov.nih.mipav.view
Class ViewJProgressBarMulti
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Window
-
- java.awt.Frame
-
- javax.swing.JFrame
-
- gov.nih.mipav.view.ViewJProgressBar
-
- gov.nih.mipav.view.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 classViewJProgressBarMulti.AlgoContainerA container class that holds all the information to correctly draw each progress bar.private classViewJProgressBarMulti.LinkingVery 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.Window
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.event.ActionListeneractionListenerprivate java.util.ArrayList<ViewJProgressBarMulti.AlgoContainer>algContList of containers that hold all the information to correctly draw each progress barprivate java.util.ArrayList<java.lang.Runnable>algListList containing which runnables are registered to this listenerprivate javax.swing.JPanelbarPanelPanel containing all the progress bars as well as relevent text labelsprivate javax.swing.JButtoncancelButtonprivate booleancancelFlagprivate java.util.ArrayList<javax.swing.JLabel>closeListList to determine which progress bar to closeprivate booleanemptyDisplayedWhether or not emptyLabel is currently displayedprivate javax.swing.JLabelemptyLabelLabel to display when there are no runnables to display or listen for.private java.awt.GridBagConstraintsgbcprivate java.util.ArrayList<javax.swing.JLabel>hideListList to determine which progress bar to hide/showprivate booleanmessageLockedprivate static longserialVersionUIDprivate java.awt.event.WindowListenerwindowListener-
Fields inherited from class gov.nih.mipav.view.ViewJProgressBar
LOCK_PROGRESS_MESSAGE, PROGRESS_VALUE_UNCHANGED, PROGRESS_WINDOW_CLOSING, UNLOCK_PROGRESS_MESSAGE
-
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
-
-
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 voidaddCollectionOfRunnable(java.util.Collection<java.lang.Runnable> algs, java.util.Collection<java.lang.String> titles)Secondary method for registering algorithms to the multi-bar.voidaddRunnable(java.lang.Runnable alg, java.lang.String title, int min, int max)Basic method for registering an algorithm to the multi-bar.private voidinit()voidmouseClicked(java.awt.event.MouseEvent e)This listens for when the buttons to hide or close a progress bar are clicked.voidmouseEntered(java.awt.event.MouseEvent e)voidmouseExited(java.awt.event.MouseEvent e)voidmousePressed(java.awt.event.MouseEvent e)voidmouseReleased(java.awt.event.MouseEvent e)voidprogressStateChanged(ProgressChangeEvent e)Handle any progress changes by updating the correct progress bar attached to the throwing algorithmvoidremoveAlgorithm(java.lang.Runnable alg)Method for removing the algorithm from the frame displayed as well as removing the listener attached to itvoidsetLink(java.lang.Runnable to, java.lang.Runnable from, int min, int max)Create a link between two algorithms.voidsetMessage(int index, java.lang.String msg)Updates the displayed message above a given progress barvoidupdateValue(int index, int value)Update the specific algorithm's progress display-
Methods inherited from class gov.nih.mipav.view.ViewJProgressBar
actionPerformed, addActionListener, appendMessage, getCancelButton, getMessageBar, getPercentageLabel, getProgressBar, getProgressFromFloat, getProgressFromInt, getValue, isComplete, removeActionListener, setIndeterminate, setMessage, setReadyToDispose, setSeparateThread, setTitle, setVisible, updateValue, updateValue, updateValueImmed, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
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 gov.nih.mipav.view.ProgressBarInterface
dispose, setLocation
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
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
-
algCont
private java.util.ArrayList<ViewJProgressBarMulti.AlgoContainer> algCont
List of containers that hold all the information to correctly draw each progress bar
-
-
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-bartitle- the name to associate with this algorithmmin- 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-bartitles- 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:
progressStateChangedin interfaceProgressChangeListener- Overrides:
progressStateChangedin classViewJProgressBar- Parameters:
e- DOCUMENT ME!
-
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 algorighmfrom- the child algorithmmin- the lower bound of where the child affects the parentmax- 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 updatemsg- 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 listvalue- 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:
mouseClickedin interfacejava.awt.event.MouseListener
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressedin interfacejava.awt.event.MouseListener
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)
- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener
-
-