rcx.rcxtools.share.gui
Class ProgressBar

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by rcx.rcxtools.share.gui.ProgressBar
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class ProgressBar
extends java.awt.Canvas

The progress bar component is a lightweight component that can be easily incorporated into most Java programs. A progress bar is made up of a rectangle boarder, background color, a foreground color, and a percentage displayed in the center of the rectangle. The foreground color expands or contracts to fill the rectangle depending on the percentage passed in the updatebar method (for example if 50% is passed the progress bar will show the left half as the foreground color and the right half as the background color). The string percentage displayed inside the progress bar will change colors when the foreground color of the progress bar paints over it.

Version:
1.0, 31 Jan 1998
Author:
Lou Schiano
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 
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
 
Constructor Summary
ProgressBar(int progrWidth, int progrHeight)
          Creates a progress bar using the passed width and height.
ProgressBar(int progrWidth, int progrHeight, java.awt.Color canvasColor, java.awt.Color progrColor, java.awt.Color progrBackground)
          Creates a progress bar using the passed width, height, canvas color, progress bar foreground color, and progress bar background color.
 
Method Summary
 void paint(java.awt.Graphics g)
          Paints the progress bar on the canvas.
 void paintNow()
           
 void setBackground(java.awt.Color progressBackground)
           
 void setBackGroundColor(java.awt.Color progressBackground)
          Sets the background color of the progress bar.
 void setCanvasColor(java.awt.Color color)
          Sets the background color of the canvas the progress bar is drawn on.
 void setForeground(java.awt.Color progressForeground)
           
 void setProgressColor(java.awt.Color progressColor)
          Sets the foreground color of the progress bar.
 void update(java.awt.Graphics g)
           
 void updateBar(float percentage)
          This method is called when another component wants to update the progress bar.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProgressBar

public ProgressBar(int progrWidth,
                   int progrHeight)
Creates a progress bar using the passed width and height.


ProgressBar

public ProgressBar(int progrWidth,
                   int progrHeight,
                   java.awt.Color canvasColor,
                   java.awt.Color progrColor,
                   java.awt.Color progrBackground)
Creates a progress bar using the passed width, height, canvas color, progress bar foreground color, and progress bar background color.

Method Detail

updateBar

public void updateBar(float percentage)
This method is called when another component wants to update the progress bar. A percentage in the form of a float between 0 and 1 is accepted, then the progress bars repaint method is called to paint the progress bar on its Canvas. The foreground of the progress bar will be repainted, plus the float will be displayed in the center of the progress bar. Never pass this method a float greater than 1.


setCanvasColor

public void setCanvasColor(java.awt.Color color)
Sets the background color of the canvas the progress bar is drawn on.


setProgressColor

public void setProgressColor(java.awt.Color progressColor)
Sets the foreground color of the progress bar.


setBackGroundColor

public void setBackGroundColor(java.awt.Color progressBackground)
Sets the background color of the progress bar.


setForeground

public void setForeground(java.awt.Color progressForeground)
Overrides:
setForeground in class java.awt.Component

setBackground

public void setBackground(java.awt.Color progressBackground)
Overrides:
setBackground in class java.awt.Component

paint

public void paint(java.awt.Graphics g)
Paints the progress bar on the canvas. The string percentage displayed inside the progress bar will change colors when the foreground color of the progress bar paints over it. This is accomplished by first painting the the string percentage in the same color as the foreground, then setting the clipping rectange to the same size as the foreground and repainting the percentage in the background color in the same spot. When the forground is not overlaying the string percentage, the second string percentage will not paint because the clipping rectangle does not cover that area.

Overrides:
paint in class java.awt.Canvas

update

public void update(java.awt.Graphics g)
Overrides:
update in class java.awt.Canvas

paintNow

public void paintNow()