|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--org.concord.util.BarGraph
Bar graph component. This component in its default form provides a simple bar graph. Setting a value at a particular index will show a graphic bar at that height at that offset. This component is built out of an array of gauges, each of which has it's own set of properties.
In addition, there is a more complicated use of this component that involves remapping the index values used in the updateValue, setColor and getColor methods. Since each gauge also has indexed values and color, updating the values of the bar graph with a single index requires some special setup. This setup is done with index mapping. Using the addMapEntry method, the developer can specify that the graph index 'i' will reference sub-bar 'k' in gauge 'j'. This would be done by calling 'addMapEntry(i, j, k)'. In the absence of mapping for a paticular index, the gauge at that index will be treated as a simple, single bar.
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 |
background
|
static int |
DEFAULT_GAUGE_WIDTH
|
static int |
DEFAULT_NUMBER_OF_GAUGES
|
protected boolean |
editable
|
protected Gauge[] |
gauges
|
protected int |
gaugeWidth
|
protected java.util.Vector |
indexMap
|
protected int |
numberOfGauges
|
static java.util.Vector |
oldGauges
|
protected java.awt.event.ComponentAdapter |
sizeChanged
|
protected javax.swing.JSlider |
slider
|
protected javax.swing.event.ChangeListener |
sliderChanged
|
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 | |
BarGraph()
Bar graph constructor. |
Method Summary | |
void |
addMapEntry(int index,
int i,
int j)
Add or replace an index map entry. |
void |
clearMap()
Resets the index mapping. |
java.awt.Color |
getBackground()
|
java.awt.Color |
getColor(int index)
Returns color associated with a particular index. |
Gauge |
getGauge(int index)
Returns the gauge component at a particular index. |
int |
getGaugeWidth()
Gets value that determines pixel spaceing between gauges. |
double |
getMax()
|
javax.swing.JSlider |
getSlider()
|
double |
getValue()
|
double |
getValue(int index)
Get value of graph element at index. |
boolean |
isEditable()
Returns editable state. |
protected double |
log10(double x)
|
static void |
main(java.lang.String[] args)
|
void |
paintComponent(java.awt.Graphics g)
|
void |
removeMapEntry(int index,
int i,
int j)
Removes an index map for a particular index. |
void |
setBackground(java.awt.Color color)
|
protected void |
setBarGraphSize(java.awt.Dimension size)
|
void |
setColor(java.awt.Color color,
int index)
Sets the color associated with a particular index. |
void |
setEditable(boolean value)
Make gauges editable. |
void |
setGaugeWidth(int width)
Sets value that determines pixel spaceing between gauges. |
void |
setMax(double value)
|
void |
setNumberOfGauges(int number)
Sets the number of gauges in this graph. |
void |
setScaleMax(int scale)
|
void |
setSlider(javax.swing.JSlider slider)
|
void |
setSliderValue()
|
void |
updateValue(double x)
|
void |
updateValue(double x,
int index)
Updates graph element at index with new value. |
void |
updateValue(float x)
|
void |
updateValue(float x,
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, 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, 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 |
public static java.util.Vector oldGauges
public static final int DEFAULT_GAUGE_WIDTH
public static final int DEFAULT_NUMBER_OF_GAUGES
protected int gaugeWidth
protected int numberOfGauges
protected java.awt.Color background
protected Gauge[] gauges
protected boolean editable
protected java.util.Vector indexMap
protected javax.swing.event.ChangeListener sliderChanged
protected javax.swing.JSlider slider
protected java.awt.event.ComponentAdapter sizeChanged
Constructor Detail |
public BarGraph()
Method Detail |
public void addMapEntry(int index, int i, int j)
index
- - int index of the graph to be associated with a value.i
- - index refers to the offset of a gauge within the graph.j
- - index refers to the sub-bar within a particular gauge.public void removeMapEntry(int index, int i, int j)
index
- - int index of the graph to be associated with a value.i
- - index refers to the offset of a gauge within the graph.j
- - index refers to the sub-bar within a particular gauge.public void clearMap()
public java.awt.Color getBackground()
getBackground
in class java.awt.Component
public void setBackground(java.awt.Color color)
setBackground
in class javax.swing.JComponent
public void setNumberOfGauges(int number)
number
- - int number of gauges.public void setMax(double value)
public void setScaleMax(int scale)
public double getMax()
protected double log10(double x)
public void setSliderValue()
public boolean isEditable()
public void setEditable(boolean value)
public javax.swing.JSlider getSlider()
public void setSlider(javax.swing.JSlider slider)
public java.awt.Color getColor(int index)
getColor
in interface ValueGraph
index
- - int index of graph element.public void setColor(java.awt.Color color, int index)
setColor
in interface ValueGraph
color
- - Color of graph element.index
- - int index of graph element.public void setGaugeWidth(int width)
gap
- - int gap between gauges.public int getGaugeWidth()
public Gauge getGauge(int index)
index
- - int index of gauge.protected void setBarGraphSize(java.awt.Dimension size)
public double getValue(int index)
index
- - int index of graph element.public double getValue()
public void updateValue(double x, int index)
updateValue
in interface ValueGraph
x
- - double value to update.index
- - int index of graph element.public void updateValue(double x)
updateValue
in interface ValueGraph
public void updateValue(float x, int index)
updateValue
in interface ValueGraph
public void updateValue(float x)
updateValue
in interface ValueGraph
public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |