org.concord.util
Class Gauge

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--org.concord.util.Gauge
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, ValueGraph

public class Gauge
extends javax.swing.JComponent
implements ValueGraph

Value gauge.

Graphic component that shows a simple scalar value as a vertical bar.

This component can also represent multiple scalar values additively with stacked vertical rectangles.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  java.awt.Color[] barColors
           
protected  java.awt.Rectangle[] bars
           
static double DEFAULT_MAX_VALUE
           
static double DEFAULT_MIN_VALUE
           
static double DEFAULT_VALUE
           
protected  java.awt.event.MouseMotionAdapter dragGauge
           
protected  boolean drawBoundary
           
protected  boolean editable
           
protected  int gaugeHeight
           
protected  int[] gaugeValues
           
protected  int gaugeWidth
           
protected  int majorTickLength
           
protected  int majorTicks
           
protected  int majorTickValue
           
protected  double max
           
protected  java.lang.String maxString
           
protected  double min
           
protected  int minorTickLength
           
protected  int minorTicks
           
protected  int minorTickValue
           
protected  java.lang.String minString
           
protected  int numberOfBars
           
protected  java.util.Vector oldBars
           
protected  double range
           
protected  java.awt.event.MouseAdapter setGauge
           
protected  java.awt.event.ComponentAdapter sizeChanged
           
protected  int tickSpace
           
protected  double[] values
           
protected  java.lang.String[] valueStrings
           
 
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 org.concord.util.ValueGraph
colors
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Gauge()
          Gauge constructor.
 
Method Summary
protected  int findBarIndex(int x, int y)
           
protected  double getBarValue(int index, int x, int y)
           
 java.awt.Color getColor()
          Returns color associated with a particular index.
 java.awt.Color getColor(int index)
          Returns color associated with a particular index.
 boolean getEditable()
          Returns editable state.
 double getMax()
          Get the maximum value of the gauge.
 double getMin()
          Get the minimum value of the gauge.
 double getRange()
          Returns the range of values shown by this gauge.
 double getValue()
          Get value of gauge sub-bar.
 double getValue(int index)
          Get value of gauge sub-bar at index.
static void main(java.lang.String[] args)
           
 void paintComponent(java.awt.Graphics g)
           
 void setColor(java.awt.Color color)
          Sets the color.
 void setColor(java.awt.Color color, int index)
          Sets the color associated with a particular index.
 void setEditable(boolean value)
          Make gauges editable.
protected  void setGaugeSize(java.awt.Dimension size)
           
 void setMajorTickMarks(int ticks)
           
 void setMax(double value)
          Set the maximum value of the gauge.
 void setMin(double value)
          Set the minimum value of the gauge.
 void setMinorTickMarks(int ticks)
           
 void setNumberOfBars(int number)
           
 void setScaleMax(int scale)
           
protected  void setValueFromMouseEvent(java.awt.event.MouseEvent event)
           
 void updateValue(double value)
           
 void updateValue(double value, int index)
          Updates gauge sub-bar at index with new value.
 void updateValue(float value)
           
 void updateValue(float value, int index)
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_MIN_VALUE

public static final double DEFAULT_MIN_VALUE

DEFAULT_MAX_VALUE

public static final double DEFAULT_MAX_VALUE

DEFAULT_VALUE

public static final double DEFAULT_VALUE

min

protected double min

max

protected double max

values

protected double[] values

range

protected double range

gaugeWidth

protected int gaugeWidth

gaugeHeight

protected int gaugeHeight

majorTicks

protected int majorTicks

minorTicks

protected int minorTicks

tickSpace

protected int tickSpace

majorTickLength

protected int majorTickLength

minorTickLength

protected int minorTickLength

majorTickValue

protected int majorTickValue

minorTickValue

protected int minorTickValue

valueStrings

protected java.lang.String[] valueStrings

minString

protected java.lang.String minString

maxString

protected java.lang.String maxString

editable

protected boolean editable

drawBoundary

protected boolean drawBoundary

oldBars

protected java.util.Vector oldBars

bars

protected java.awt.Rectangle[] bars

barColors

protected java.awt.Color[] barColors

numberOfBars

protected int numberOfBars

gaugeValues

protected int[] gaugeValues

sizeChanged

protected java.awt.event.ComponentAdapter sizeChanged

dragGauge

protected java.awt.event.MouseMotionAdapter dragGauge

setGauge

protected java.awt.event.MouseAdapter setGauge
Constructor Detail

Gauge

public Gauge()
Gauge constructor.
Method Detail

findBarIndex

protected int findBarIndex(int x,
                           int y)

getBarValue

protected double getBarValue(int index,
                             int x,
                             int y)

setValueFromMouseEvent

protected void setValueFromMouseEvent(java.awt.event.MouseEvent event)

setGaugeSize

protected void setGaugeSize(java.awt.Dimension size)

setNumberOfBars

public void setNumberOfBars(int number)

getEditable

public boolean getEditable()
Returns editable state. Gauge value can be set with pointer device interaction. This method returns whether or not that feature is enabled.


setEditable

public void setEditable(boolean value)
Make gauges editable. Gauge value can be set with pointer device interaction. This method enables and disables that feature.


getRange

public double getRange()
Returns the range of values shown by this gauge.

Returns:
- double range of values.

setMin

public void setMin(double value)
Set the minimum value of the gauge.

Parameters:
value - - double minumum value.

getMin

public double getMin()
Get the minimum value of the gauge.

Returns:
- double minimum value.

setMax

public void setMax(double value)
Set the maximum value of the gauge.

Parameters:
value - - double maxumum value.

getMax

public double getMax()
Get the maximum value of the gauge.

Returns:
double maximum value.

setScaleMax

public void setScaleMax(int scale)

updateValue

public void updateValue(double value,
                        int index)
Updates gauge sub-bar at index with new value.

Specified by:
updateValue in interface ValueGraph
Parameters:
x - double value to update.
index - int index of sub-bar.

updateValue

public void updateValue(double value)
Specified by:
updateValue in interface ValueGraph

updateValue

public void updateValue(float value,
                        int index)
Specified by:
updateValue in interface ValueGraph

updateValue

public void updateValue(float value)
Specified by:
updateValue in interface ValueGraph

getValue

public double getValue(int index)
Get value of gauge sub-bar at index.

Parameters:
index - int index of sub-bar.
Returns:
double sub-bar value.

getValue

public double getValue()
Get value of gauge sub-bar.

Returns:
double gauge value.

getColor

public java.awt.Color getColor(int index)
Returns color associated with a particular index.

Specified by:
getColor in interface ValueGraph
Parameters:
index - int index of sub-bar.
Returns:
Color color of sub-bar.

setColor

public void setColor(java.awt.Color color,
                     int index)
Sets the color associated with a particular index.

Specified by:
setColor in interface ValueGraph
Parameters:
color - Color of sub-bar.
index - int index of sub-bar.

getColor

public java.awt.Color getColor()
Returns color associated with a particular index.

Returns:
Color color of gauge.

setColor

public void setColor(java.awt.Color color)
Sets the color.

Parameters:
color - Color of gauge.

setMajorTickMarks

public void setMajorTickMarks(int ticks)

setMinorTickMarks

public void setMinorTickMarks(int ticks)

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

main

public static void main(java.lang.String[] args)