lcarsbeans
Class LcarsGauge

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--lcarsbeans.LcarsGauge

public class LcarsGauge
extends java.awt.Canvas
implements java.io.Serializable

A gauge.

Version:
0.9b, January 2002 (March 2001)
Author:
Andrei Scheibner, www.buffalo-as.de, andrei@buffalo-as.de
See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
protected  java.awt.Color barColor
           
protected  java.awt.Color boundsColor
           
static int gdDown
          Direction of the gauge: down.
static int gdLeft
          Direction of the gauge: left.
static int gdRight
          Direction of the gauge: right.
static int gdUp
          Direction of the gauge: up.
static int ggFour
          Four grid rectangles.
static int ggOne
          One grid rectangle.
static int ggThree
          Three grid rectangles.
static int ggTwo
          Two grid rectangles.
static int gsGridded
          Gridded frame(s) around the gauge bar.
static int gsNormal
          No gridded frame(s) around the gauge bar.
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
LcarsGauge()
          Constructs a new instance.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener l)
          Adds an Action Listener.
 void addLcarsGaugeProgressChangeListener(LcarsGaugeProgressChangeListener l)
          Adds a listener for the LcarsGaugeProgressChangedEvent.
 void addProgress(int difference)
          Adds or subtracts the difference to/from the current progress.
protected  void fireLcarsGaugeProgressChange()
          Sends the Change-Event to all listeners.
 java.awt.Color getBarColor()
          Returns the color of the gauge bar.
 java.awt.Color getBoundsColor()
          Returns the color of the rectangle around the bar.
 java.awt.Color getFontColor()
          Returns the color used for drawing the text.
 int getGaugeDirection()
          Returns the direction of the gauge.
 int getGaugeGrids()
          Returns the number of grid rectangles.
 int getGaugeStyle()
          Returns the style of the gauge.
 int getGridFourAtPercent()
          Returns the percentage at which the fourth grid rectangle starts.
 java.awt.Color getGridFourColor()
          Returns the color of the fourth grid rectangle.
 int getGridLineEveryNPercent()
          Returns how much percent place is between the thin lines inside the grids.
 java.awt.Color getGridOneColor()
          Returns the color of the first grid rectangle.
 int getGridThreeAtPercent()
          Returns the percentage at which the third grid rectangle starts.
 java.awt.Color getGridThreeColor()
          Returns the color of the third grid rectangle.
 int getGridTwoAtPercent()
          Returns the percentage at which the second grid rectangle starts.
 java.awt.Color getGridTwoColor()
          Returns the color of the second grid rectangle.
 int getMaxValue()
          Returns the maximal progress.
 int getMinValue()
          Returns the minimal progress.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of the component.
 int getProgress()
          Returns the current progress.
 boolean isGaugeBounds()
          Returns whether there is a rectangle around the bar.
 boolean isShowText()
          Returns whether the current progress is shown beside the bar.
 void paint(java.awt.Graphics g)
          Paints the control.
 void removeActionListener(java.awt.event.ActionListener l)
          Removes an Action Listener.
 void removeLcarsGaugeProgressChangeListener(LcarsGaugeProgressChangeListener l)
          Removes a listener for the LcarsGaugeProgressChangedEvent.
 void setBarColor(java.awt.Color newBarColor)
          Sets the color of the the gauge bar.
 void setBoundsColor(java.awt.Color newBoundsColor)
          Sets the color of the rectangle around the bar.
 void setFontColor(java.awt.Color newFontColor)
          Sets the color used for drawing the text.
 void setGaugeBounds(boolean newGaugeBounds)
          Sets whether there is a rectangle around the bar.
 void setGaugeDirection(int newGaugeDirection)
          Sets the direction of the gauge.
Possible values: gdUp, gdRight, gdDown, gdLeft
If the new value is not in the range between 0 and 3 the property is set to gdUp.
 void setGaugeGrids(int newGaugeGrids)
          Sets the number of grid rectangles.
Possible values: ggOne, ggTwo, ggThree, ggFour
If the new value is not in the range between 0 and 4 the property is set to ggOne.
 void setGaugeStyle(int newGaugeStyle)
          Sets the style of the gauge.
Possible values: gsNormal, gsGridded
If the new value is not 0 or 1 the property is set to gsNormal.
 void setGridFourAtPercent(int newGridFourAtPercent)
          Sets the percentage at which the fourth grid rectangle starts.
The values of this property must be multiples of 5 (you can enter whatever you want, it will be rounded automatically).
 void setGridFourColor(java.awt.Color newGridFourColor)
          Sets the color of the fourth grid rectangle.
 void setGridLineEveryNPercent(int newGridLineEveryNPercent)
          Sets how much percent place is between the thin lines inside the grids.
Values of this property may be either 5 or 10 (you can enter whatever you want.
 void setGridOneColor(java.awt.Color newGridOneColor)
          Sets the color of the first grid rectangle.
 void setGridThreeAtPercent(int newGridThreeAtPercent)
          Sets the percentage at which the third grid rectangle starts.
The values of this property must be multiples of 5 (you can enter whatever you want, it will be rounded automatically).
 void setGridThreeColor(java.awt.Color newGridThreeColor)
          Sets the color of the third grid rectangle.
 void setGridTwoAtPercent(int newGridTwoAtPercent)
          Sets the percentage at which the second grid rectangle starts.
The values of this property must be multiples of 5 (you can enter whatever you want, it will be rounded automatically).
 void setGridTwoColor(java.awt.Color newGridTwoColor)
          Sets the color of the second grid rectangle.
 void setMaxValue(int newMaxValue)
          Sets the maximal progress.
Property should not be less than 0.
 void setMinValue(int newMinValue)
          Sets the minimal progress.
Property should not be less than 0.
 void setProgress(int newProgress)
          Sets the current progress.
 void setShowText(boolean newShowText)
          Sets whether the current progress is shown beside the bar.
 void update(java.awt.Graphics g)
          An overwritten and because of this almost flicker-free version of update().
 
Methods inherited from class java.awt.Canvas
, addNotify, constructComponentName, postsOldMouseEvents
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventEnabled, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, lightweightPrint, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

gsNormal

public static final int gsNormal
No gridded frame(s) around the gauge bar.

gsGridded

public static final int gsGridded
Gridded frame(s) around the gauge bar.

gdUp

public static final int gdUp
Direction of the gauge: up.

gdRight

public static final int gdRight
Direction of the gauge: right.

gdDown

public static final int gdDown
Direction of the gauge: down.

gdLeft

public static final int gdLeft
Direction of the gauge: left.

ggOne

public static final int ggOne
One grid rectangle.

ggTwo

public static final int ggTwo
Two grid rectangles.

ggThree

public static final int ggThree
Three grid rectangles.

ggFour

public static final int ggFour
Four grid rectangles.

boundsColor

protected java.awt.Color boundsColor

barColor

protected java.awt.Color barColor
Constructor Detail

LcarsGauge

public LcarsGauge()
Constructs a new instance.
Method Detail

paint

public void paint(java.awt.Graphics g)
Paints the control.
Overrides:
paint in class java.awt.Canvas

update

public void update(java.awt.Graphics g)
An overwritten and because of this almost flicker-free version of update().
Overrides:
update in class java.awt.Component

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of the component.
Overrides:
getPreferredSize in class java.awt.Component

getFontColor

public java.awt.Color getFontColor()
Returns the color used for drawing the text.

setFontColor

public void setFontColor(java.awt.Color newFontColor)
Sets the color used for drawing the text.

getGaugeStyle

public int getGaugeStyle()
Returns the style of the gauge.

setGaugeStyle

public void setGaugeStyle(int newGaugeStyle)
Sets the style of the gauge.
Possible values: gsNormal, gsGridded
If the new value is not 0 or 1 the property is set to gsNormal.

getGaugeGrids

public int getGaugeGrids()
Returns the number of grid rectangles.

setGaugeGrids

public void setGaugeGrids(int newGaugeGrids)
Sets the number of grid rectangles.
Possible values: ggOne, ggTwo, ggThree, ggFour
If the new value is not in the range between 0 and 4 the property is set to ggOne.

getGridTwoAtPercent

public int getGridTwoAtPercent()
Returns the percentage at which the second grid rectangle starts.

setGridTwoAtPercent

public void setGridTwoAtPercent(int newGridTwoAtPercent)
Sets the percentage at which the second grid rectangle starts.
The values of this property must be multiples of 5 (you can enter whatever you want, it will be rounded automatically).

getGridThreeAtPercent

public int getGridThreeAtPercent()
Returns the percentage at which the third grid rectangle starts.

setGridThreeAtPercent

public void setGridThreeAtPercent(int newGridThreeAtPercent)
Sets the percentage at which the third grid rectangle starts.
The values of this property must be multiples of 5 (you can enter whatever you want, it will be rounded automatically).

getGridFourAtPercent

public int getGridFourAtPercent()
Returns the percentage at which the fourth grid rectangle starts.

setGridFourAtPercent

public void setGridFourAtPercent(int newGridFourAtPercent)
Sets the percentage at which the fourth grid rectangle starts.
The values of this property must be multiples of 5 (you can enter whatever you want, it will be rounded automatically).

isShowText

public boolean isShowText()
Returns whether the current progress is shown beside the bar.

setShowText

public void setShowText(boolean newShowText)
Sets whether the current progress is shown beside the bar.

isGaugeBounds

public boolean isGaugeBounds()
Returns whether there is a rectangle around the bar.

setGaugeBounds

public void setGaugeBounds(boolean newGaugeBounds)
Sets whether there is a rectangle around the bar.

getBoundsColor

public java.awt.Color getBoundsColor()
Returns the color of the rectangle around the bar.

setBoundsColor

public void setBoundsColor(java.awt.Color newBoundsColor)
Sets the color of the rectangle around the bar.

getBarColor

public java.awt.Color getBarColor()
Returns the color of the gauge bar.

setBarColor

public void setBarColor(java.awt.Color newBarColor)
Sets the color of the the gauge bar.

getGridOneColor

public java.awt.Color getGridOneColor()
Returns the color of the first grid rectangle.

setGridOneColor

public void setGridOneColor(java.awt.Color newGridOneColor)
Sets the color of the first grid rectangle.

getGridTwoColor

public java.awt.Color getGridTwoColor()
Returns the color of the second grid rectangle.

setGridTwoColor

public void setGridTwoColor(java.awt.Color newGridTwoColor)
Sets the color of the second grid rectangle.

getGridThreeColor

public java.awt.Color getGridThreeColor()
Returns the color of the third grid rectangle.

setGridThreeColor

public void setGridThreeColor(java.awt.Color newGridThreeColor)
Sets the color of the third grid rectangle.

getGridFourColor

public java.awt.Color getGridFourColor()
Returns the color of the fourth grid rectangle.

setGridFourColor

public void setGridFourColor(java.awt.Color newGridFourColor)
Sets the color of the fourth grid rectangle.

getGaugeDirection

public int getGaugeDirection()
Returns the direction of the gauge.

setGaugeDirection

public void setGaugeDirection(int newGaugeDirection)
Sets the direction of the gauge.
Possible values: gdUp, gdRight, gdDown, gdLeft
If the new value is not in the range between 0 and 3 the property is set to gdUp.

getGridLineEveryNPercent

public int getGridLineEveryNPercent()
Returns how much percent place is between the thin lines inside the grids.

setGridLineEveryNPercent

public void setGridLineEveryNPercent(int newGridLineEveryNPercent)
Sets how much percent place is between the thin lines inside the grids.
Values of this property may be either 5 or 10 (you can enter whatever you want. If the new value is less than 10 the property will be set to 5 otherwise to 10).

getMinValue

public int getMinValue()
Returns the minimal progress.

setMinValue

public void setMinValue(int newMinValue)
Sets the minimal progress.
Property should not be less than 0.

getMaxValue

public int getMaxValue()
Returns the maximal progress.

setMaxValue

public void setMaxValue(int newMaxValue)
Sets the maximal progress.
Property should not be less than 0.

getProgress

public int getProgress()
Returns the current progress.

setProgress

public void setProgress(int newProgress)
Sets the current progress.

addProgress

public void addProgress(int difference)
Adds or subtracts the difference to/from the current progress.

fireLcarsGaugeProgressChange

protected void fireLcarsGaugeProgressChange()
Sends the Change-Event to all listeners.

addLcarsGaugeProgressChangeListener

public void addLcarsGaugeProgressChangeListener(LcarsGaugeProgressChangeListener l)
Adds a listener for the LcarsGaugeProgressChangedEvent.

removeLcarsGaugeProgressChangeListener

public void removeLcarsGaugeProgressChangeListener(LcarsGaugeProgressChangeListener l)
Removes a listener for the LcarsGaugeProgressChangedEvent.

addActionListener

public void addActionListener(java.awt.event.ActionListener l)
Adds an Action Listener.

removeActionListener

public void removeActionListener(java.awt.event.ActionListener l)
Removes an Action Listener.