Package gov.nih.mipav.view
Class ViewJProgressBar
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
gov.nih.mipav.view.ViewJProgressBar
- All Implemented Interfaces:
ProgressBarInterface,ProgressChangeListener,ActionListener,WindowListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible,RootPaneContainer,WindowConstants
- Direct Known Subclasses:
ViewJProgressBarMulti,ViewJSimpleProgressBar
public class ViewJProgressBar
extends JFrame
implements ActionListener, ProgressBarInterface, ProgressChangeListener, WindowListener
Progress bar used everywhere for displaying to the user how long the current process is going to take. The progress
bar looks like this:
+-Title------------------------+
| Message |
| |--------Bar--------| percent|
| Cancel |
+------------------------------+
The cancel button is not always present; that option is set in the constructor.
- Version:
- 0.1 Oct 19, 1998
- Author:
- Matthew J. McAuliffe, Ph.D.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrameNested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrameNested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.TypeNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate JButtonCancel button, if applicable.static final StringConstant indicating whether to lock the message string so that other algorithms will not change this (sub-algorithms)private booleanindicates if the message string (in the progress bar) is locked so that it wont be updatedprivate JLabelLabel directly above the bar that is updated during operation if necessary.private JProgressBarActual bar which fills with color as the percentage of completion increases.private JLabelPercentage label, puts a number next to the bar with the actual percent completed.static final intDOCUMENT ME!static final intDOCUMENT ME!private booleanFor users wanting to override the automatic closing option when progress reaches 100.private booleanDOCUMENT ME!private static final longUse serialVersionUID for interoperability.private StringTitle of the frame for the progress bar.static final StringWith the above variable, unlocks the message updatingFields inherited from class javax.swing.JFrame
accessibleContext, rootPane, rootPaneCheckingEnabledFields 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_CURSORFields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE -
Constructor Summary
ConstructorsConstructorDescriptionViewJProgressBar(String _title, String msg, int min, int max, boolean cancelFlag) Creates a new ViewJProgressBar object.ViewJProgressBar(String _title, String msg, int min, int max, boolean cancelFlag, ActionListener actionListener, WindowListener windowListener) Creates a new progress bar with the given title, message, and min and max.ViewJProgressBar(String _title, String msg, int min, int max, boolean cancelFlag, ActionListener actionListener, WindowListener windowListener, boolean isVisible) Creates a new progress bar with the given title, message, and min and max. -
Method Summary
Modifier and TypeMethodDescriptionvoidCloses this progress bar when the cancel button is clicked.voidDOCUMENT ME!voidappendMessage(String msg) Concatenates a message to the message area of the progress bar.Get the cancel buttonGet the message label.Get the percentage label.Get the progress bar.static intgetProgressFromFloat(int minProgressValue, int maxProgressValue, float percentage) DOCUMENT ME!static intgetProgressFromInt(int minProgressValue, int maxProgressValue, int percentage) DOCUMENT ME!intgetValue()Used to get the present value of the progress bar.booleanUsed to determine if the progress bar is at 100%.voidImplementation of the ProgressChangeListener interface.voidDOCUMENT ME!voidsetIndeterminate(boolean flag) Enable or disable the progress bar indeterminate mode.voidsetMessage(String msg) Sets the message area of the progress bar.voidsetReadyToDispose(boolean isReady) accessor to allow user to override the automatic closing (until they set this flag to true);voidsetSeparateThread(boolean flag) Changes whether the algorithm which is using this progress bar is running in its own thread.voidSets the title of the frame of the progress bar.voidsetVisible(boolean visible) DOCUMENT ME!voidupdateValue(int value) Use this method if you are not running in a separate thread, or, you have already set the value of separateThread through the setSeparateThread method.voidupdateValue(int value, boolean sepThread) Used to set the present value of the progress bar.voidupdateValueImmed(int value) Used to set the present value of the progress bar.voidwindowActivated(WindowEvent event) Do nothing.voidwindowClosed(WindowEvent event) Do nothing.voidwindowClosing(WindowEvent event) Dispose the progress window.voidwindowDeactivated(WindowEvent event) Do nothing.voidwindowDeiconified(WindowEvent event) Do nothing.voidwindowIconified(WindowEvent event) Do nothing.voidwindowOpened(WindowEvent event) Do nothing.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, updateMethods 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, setUndecoratedMethods 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, toFrontMethods 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, validateTreeMethods 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, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.awt.MenuContainer
getFont, postEventMethods inherited from interface gov.nih.mipav.view.ProgressBarInterface
dispose, setLocation
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDUse serialVersionUID for interoperability.- See Also:
-
PROGRESS_VALUE_UNCHANGED
public static final int PROGRESS_VALUE_UNCHANGEDDOCUMENT ME!- See Also:
-
PROGRESS_WINDOW_CLOSING
public static final int PROGRESS_WINDOW_CLOSINGDOCUMENT ME!- See Also:
-
LOCK_PROGRESS_MESSAGE
Constant indicating whether to lock the message string so that other algorithms will not change this (sub-algorithms)- See Also:
-
UNLOCK_PROGRESS_MESSAGE
With the above variable, unlocks the message updating- See Also:
-
cancelButton
Cancel button, if applicable. -
messagePBar
Label directly above the bar that is updated during operation if necessary. -
pBar
Actual bar which fills with color as the percentage of completion increases. -
percentage
Percentage label, puts a number next to the bar with the actual percent completed. -
readyToDispose
private boolean readyToDisposeFor users wanting to override the automatic closing option when progress reaches 100. -
separateThread
private boolean separateThreadDOCUMENT ME! -
title
Title of the frame for the progress bar. -
messageLocked
private boolean messageLockedindicates if the message string (in the progress bar) is locked so that it wont be updated
-
-
Constructor Details
-
ViewJProgressBar
Creates a new ViewJProgressBar object.- Parameters:
_title- DOCUMENT ME!msg- DOCUMENT ME!min- DOCUMENT ME!max- DOCUMENT ME!cancelFlag- DOCUMENT ME!
-
ViewJProgressBar
public ViewJProgressBar(String _title, String msg, int min, int max, boolean cancelFlag, ActionListener actionListener, WindowListener windowListener) Creates a new progress bar with the given title, message, and min and max. The percentage is initially set to "0%". ThecancelFlagindicates if there should be a cancel button - usually this is used for algorithms, which can be stopped, but not loading images.- Parameters:
_title- Title for the frame of the progress bar.msg- Message directly above the actual progress bar.min- Minimum value progress bar takes.max- Maximum value progress bar takes.cancelFlag-trueindicates that the user can stop the process by clicking on the cancel button, and so the button should be added to the frame.actionListener- Listener to tie to cancel button.windowListener- Listener to tie to this frame.
-
ViewJProgressBar
public ViewJProgressBar(String _title, String msg, int min, int max, boolean cancelFlag, ActionListener actionListener, WindowListener windowListener, boolean isVisible) Creates a new progress bar with the given title, message, and min and max. The percentage is initially set to "0%". ThecancelFlagindicates if there should be a cancel button - usually this is used for algorithms, which can be stopped, but not loading images.- Parameters:
_title- Title for the frame of the progress bar.msg- Message directly above the actual progress bar.min- Minimum value progress bar takes.max- Maximum value progress bar takes.cancelFlag-trueindicates that the user can stop the process by clicking on the cancel button, and so the button should be added to the frame.actionListener- Listener to tie to cancel button.windowListener- Listener to tie to this frame.isVisible- Whether to display the progress bar after it is first constructed. Note that the progress bar is never displayed if the -hide option was chosen by the user.
-
-
Method Details
-
getProgressFromFloat
public static int getProgressFromFloat(int minProgressValue, int maxProgressValue, float percentage) DOCUMENT ME!- Parameters:
minProgressValue- DOCUMENT ME!maxProgressValue- DOCUMENT ME!percentage- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
getProgressFromInt
public static int getProgressFromInt(int minProgressValue, int maxProgressValue, int percentage) DOCUMENT ME!- Parameters:
minProgressValue- DOCUMENT ME!maxProgressValue- DOCUMENT ME!percentage- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
actionPerformed
Closes this progress bar when the cancel button is clicked. This doesn't actually get called when the progress bar is running in the same thread.- Specified by:
actionPerformedin interfaceActionListener- Parameters:
e- Event that triggered this method.
-
addActionListener
DOCUMENT ME!- Parameters:
l- DOCUMENT ME!
-
appendMessage
Concatenates a message to the message area of the progress bar. Be sure to provide appropriate leading spacing.- Specified by:
appendMessagein interfaceProgressBarInterface- Parameters:
msg- Message to be displayed.
-
getCancelButton
Get the cancel button- Returns:
- canelButton cancel button
-
getMessageBar
Get the message label.- Returns:
- messagePBar message label.
-
getPercentageLabel
Get the percentage label.- Returns:
- percentage percentage label.
-
getProgressBar
Get the progress bar.- Specified by:
getProgressBarin interfaceProgressBarInterface- Returns:
- pBar the progress bar.
-
getValue
public int getValue()Used to get the present value of the progress bar.- Specified by:
getValuein interfaceProgressBarInterface- Returns:
- Value of progress bar.
-
isComplete
public boolean isComplete()Used to determine if the progress bar is at 100%.- Specified by:
isCompletein interfaceProgressBarInterface- Returns:
trueif progress bar is at 100%,falseif not.
-
progressStateChanged
Implementation of the ProgressChangeListener interface.- Specified by:
progressStateChangedin interfaceProgressChangeListener- Parameters:
e- DOCUMENT ME!
-
removeActionListener
DOCUMENT ME!- Parameters:
l- DOCUMENT ME!
-
setIndeterminate
public void setIndeterminate(boolean flag) Enable or disable the progress bar indeterminate mode.- Parameters:
flag- boolean
-
setMessage
Sets the message area of the progress bar.- Specified by:
setMessagein interfaceProgressBarInterface- Parameters:
msg- Message to be displayed.
-
setReadyToDispose
public void setReadyToDispose(boolean isReady) accessor to allow user to override the automatic closing (until they set this flag to true);- Parameters:
isReady- DOCUMENT ME!
-
setSeparateThread
public void setSeparateThread(boolean flag) Changes whether the algorithm which is using this progress bar is running in its own thread.- Parameters:
flag- whether the progress bar's algorithm is running is a separate thread
-
setTitle
Sets the title of the frame of the progress bar.- Specified by:
setTitlein interfaceProgressBarInterface- Overrides:
setTitlein classFrame- Parameters:
_title- Title of the frame.
-
setVisible
public void setVisible(boolean visible) DOCUMENT ME!- Specified by:
setVisiblein interfaceProgressBarInterface- Overrides:
setVisiblein classWindow- Parameters:
visible- DOCUMENT ME!
-
updateValue
public void updateValue(int value) Use this method if you are not running in a separate thread, or, you have already set the value of separateThread through the setSeparateThread method. Otherwise, use updateValue(int, boolean);- Parameters:
value- new progress bar value
-
updateValue
public void updateValue(int value, boolean sepThread) Used to set the present value of the progress bar. Changes the percentage label and title of the frame as well.- Specified by:
updateValuein interfaceProgressBarInterface- Parameters:
value- Set the progress bar to the given value.sepThread- Whether the calling algorithm is running in a separate thread
-
updateValueImmed
public void updateValueImmed(int value) Used to set the present value of the progress bar. Changes the percentage label and title of the frame as well. It also forces an immediate update of the frame. Typically used when using IO functions.- Parameters:
value- Set the progress bar to the given value.
-
windowActivated
Do nothing.- Specified by:
windowActivatedin interfaceWindowListener- Parameters:
event- the window activated event
-
windowClosed
Do nothing.- Specified by:
windowClosedin interfaceWindowListener- Parameters:
event- the window closed event
-
windowClosing
Dispose the progress window.- Specified by:
windowClosingin interfaceWindowListener- Parameters:
event- event that triggered function
-
windowDeactivated
Do nothing.- Specified by:
windowDeactivatedin interfaceWindowListener- Parameters:
event- the window deactivated event
-
windowDeiconified
Do nothing.- Specified by:
windowDeiconifiedin interfaceWindowListener- Parameters:
event- the window deiconified event
-
windowIconified
Do nothing.- Specified by:
windowIconifiedin interfaceWindowListener- Parameters:
event- the window iconified event
-
windowOpened
Do nothing.- Specified by:
windowOpenedin interfaceWindowListener- Parameters:
event- the window opened event
-