net.shredzone.ifish.gui
Class StatusProgressBar

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JProgressBar
                  extended by net.shredzone.ifish.gui.StatusProgressBar
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Runnable, Accessible, SwingConstants, StatusCallback

public final class StatusProgressBar
extends JProgressBar
implements StatusCallback, Runnable

This is an extension of the NaviDb class to make it usable in JTables.

Version:
$Id: StatusProgressBar.java 291 2009-04-28 21:29:27Z shred $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JProgressBar
JProgressBar.AccessibleJProgressBar
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Nested classes/interfaces inherited from interface net.shredzone.ifish.db.StatusCallback
StatusCallback.DefaultStatusCallback
 
Field Summary
 
Fields inherited from class javax.swing.JProgressBar
changeEvent, changeListener, model, orientation, paintBorder, paintString, progressString
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
StatusProgressBar()
          Create a new StatusProgressBar.
 
Method Summary
 void done()
          Show that the process is finished.
 int estimateTime()
          When countdown is enabled, this method will try to estimate the time until index reaches maximum.
 boolean isCountdown()
          Check if countdown is enabled.
 void run()
          Runnable implementation.
 void setAction(String action)
          Set the current action that is being done.
 void setCountdown(boolean cntdown)
          Enable the countdown.
 void setCurrentDir(File base, File dir)
          Set the current directory being processed.
 void setCurrentEntry(Entry entry)
          Set the current entry that is being processed by the current action.
 void setCurrentIndex(int index)
          Set the current entry number that is being processed by the current action.
 void setMaxEntries(int max)
          Set the maximum number of entries to be processed by the current action.
 
Methods inherited from class javax.swing.JProgressBar
addChangeListener, createChangeListener, fireStateChanged, getAccessibleContext, getChangeListeners, getMaximum, getMinimum, getModel, getOrientation, getPercentComplete, getString, getUI, getUIClassID, getValue, isBorderPainted, isIndeterminate, isStringPainted, paintBorder, paramString, removeChangeListener, setBorderPainted, setIndeterminate, setMaximum, setMinimum, setModel, setOrientation, setString, setStringPainted, setUI, setValue, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, 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
 

Constructor Detail

StatusProgressBar

public StatusProgressBar()
Create a new StatusProgressBar.

Method Detail

setAction

public void setAction(String action)
Set the current action that is being done.

Parameters:
action - Action string

done

public void done()
Show that the process is finished. This will also disable the countdown mode automatically.


setCountdown

public void setCountdown(boolean cntdown)
Enable the countdown. The StatusProgressBar will now try to estimate the time until the index reaches the maximum.

If countdown is enabled, you must make sure to call setMaxEntries() only once at the beginning, and you must ensure that setCurrentIndex() is always only incrementing!

Parameters:
cntdown - true: activate countdown, false: disactivate

isCountdown

public boolean isCountdown()
Check if countdown is enabled.

Returns:
true: countdown activated, false: disactivated

setMaxEntries

public void setMaxEntries(int max)
Set the maximum number of entries to be processed by the current action. If max is negative, then the maximum number is not known. Anyhow, during the operation setMaxEntries could be invoked multiple times.

Specified by:
setMaxEntries in interface StatusCallback
Parameters:
max - Maximum number of entries.

setCurrentIndex

public void setCurrentIndex(int index)
Set the current entry number that is being processed by the current action. If the number is negative, then the current entry number is not known.

Specified by:
setCurrentIndex in interface StatusCallback
Parameters:
index - Current entry.

setCurrentEntry

public void setCurrentEntry(Entry entry)
Set the current entry that is being processed by the current action. If null is passed, then no Entry is currently processed, or there are no Entries being processed.

Specified by:
setCurrentEntry in interface StatusCallback
Parameters:
entry - Entry currently being processed, or null.

setCurrentDir

public void setCurrentDir(File base,
                          File dir)
Set the current directory being processed. If there are no directories to be processed, dir will be null. Note that this method might be invoked several times, even without any changes.

Specified by:
setCurrentDir in interface StatusCallback
Parameters:
base - Base directory
dir - Current directory

run

public void run()
Runnable implementation. All StatusCallback data is cached. The progress bar will only be updated every 500ms, to gain some performance. In this thread, all the text concatenations and countdown calculations are done as well, so the CPU does not need to bother too much with this time consuming calculations.

Specified by:
run in interface Runnable

estimateTime

public int estimateTime()
When countdown is enabled, this method will try to estimate the time until index reaches maximum. The estimated time in seconds will be returned. If an estimation is not possible yet, -1 will be returned.

Returns:
Estimated Time of Arrival


Copyright © 2007-2011 shredzone.org. All Rights Reserved.