|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
org.apache.excalibur.instrument.manager.http.LineChart
public class LineChart
Draws a nice pretty chart given a set of data.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
private boolean |
m_antialias
True if Antialiasing should be used when rendering the chart. |
private int |
m_averageWindow
Number of sample points to use when calculating the moving average. |
private float[] |
m_averageWindowValues
Moving average of the sample point data. |
private java.awt.Color |
m_crossColor
|
private java.awt.Color |
m_darkGridColor
|
private java.lang.String |
m_dFormat
Format of the text which is displayed over the component as the user moves the mouse over the line chart. |
private java.text.DecimalFormat |
m_floatFormat
Decimal number format. |
private java.lang.String |
m_format
Format of the text which is displayed along the x (time) axis of the chart. |
private java.awt.Color |
m_frameColor
|
private java.text.DecimalFormat |
m_intFormat
Integer number format. |
private java.awt.Color |
m_lightGridColor
|
private java.awt.Color |
m_lightLineColor
|
private java.awt.Color |
m_lineColor
|
private int |
m_lineSampleInterval
Number of sample points between vertical lines. |
private java.awt.Color |
m_maskColor
|
private java.awt.Color |
m_maskFrameColor
|
private int |
m_max
Maximum value in m_values. |
private int |
m_min
Minimum value in m_values. |
private boolean |
m_mouseOver
|
private boolean |
m_mousePressed
|
private int |
m_mouseX
|
private int |
m_mouseY
|
private long |
m_sampleInterval
The number of milliseconds represented by each data sample. |
private long |
m_time
Time of the last sample point. |
private int[] |
m_values
Sample point data. |
private static long |
m_zoneOffset
Stores the time-zone offset for this JVM. |
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 java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
LineChart(int lineSampleInterval,
long sampleInterval,
java.lang.String format,
java.lang.String detailFormat,
int averageWindow,
boolean antialias)
|
Method Summary | |
---|---|
private java.lang.String |
getFormattedTime(java.util.Date dTime,
boolean detailed)
|
void |
mouseClicked(java.awt.event.MouseEvent event)
Called when the mouse is clicked ont the component. |
void |
mouseDragged(java.awt.event.MouseEvent event)
Called when the mouse is dragged over the component. |
void |
mouseEntered(java.awt.event.MouseEvent event)
Called when the mouse is enters the component. |
void |
mouseExited(java.awt.event.MouseEvent event)
Called when the mouse is exits the component. |
void |
mouseMoved(java.awt.event.MouseEvent event)
Called when the mouse is moved over the component. |
void |
mousePressed(java.awt.event.MouseEvent event)
Called when the mouse is pressed ont the component. |
void |
mouseReleased(java.awt.event.MouseEvent event)
Called when the mouse is released ont the component. |
void |
paintComponent(java.awt.Graphics g)
Paints the component. |
private void |
paintFrame(java.awt.Graphics g,
int chartLeft,
int chartTop,
int chartWidth,
int chartHeight)
Draws the frame around the whole chart. |
private void |
paintHorizontalGrid(java.awt.Graphics g,
int yLabelInterval,
int fontHeight,
int chartLeft,
int chartTop,
int chartWidth,
int chartHeight)
Draws the horizontal lines which make up the background of the chart. |
private void |
paintOverlay(java.awt.Graphics g,
int fontHeight,
int chartLeft,
int chartTop,
int chartWidth,
int chartHeight)
Draws the overlay label at the mouse location. |
private void |
paintOverlayAt(java.awt.Graphics g,
int fontHeight,
int chartLeft,
int chartTop,
int chartWidth,
int chartHeight,
int mouseDataPointX,
int mouseDataPointY,
java.lang.String mouseDataPointValue,
long mouseDataPointTime)
Draws the overlay label at the specified location. |
private void |
paintValues(java.awt.Graphics g,
int chartLeft,
int chartTop,
int chartWidth,
int chartHeight)
Draws the data values which to be displayed in the chart. |
private void |
paintVerticalGrid(java.awt.Graphics g,
int fontHeight,
int chartLeft,
int chartTop,
int chartWidth,
int chartHeight)
Draws the vertical lines which make up the background of the chart. |
void |
setAntialias(boolean antialias)
Sets the antialias flag to control whether or not antialiasing will be used when rendering the component. |
void |
setValues(int[] values,
long time)
Sets the data samples to be displayed by the line chart. |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, updateUI |
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 |
Field Detail |
---|
private static long m_zoneOffset
private java.awt.Color m_lineColor
private java.awt.Color m_lightLineColor
private java.awt.Color m_lightGridColor
private java.awt.Color m_darkGridColor
private java.awt.Color m_frameColor
private java.awt.Color m_crossColor
private java.awt.Color m_maskFrameColor
private java.awt.Color m_maskColor
private int m_lineSampleInterval
private long m_sampleInterval
private java.lang.String m_format
private java.lang.String m_dFormat
private int m_averageWindow
private boolean m_antialias
private long m_time
private int[] m_values
private float[] m_averageWindowValues
private int m_min
private int m_max
private java.text.DecimalFormat m_intFormat
private java.text.DecimalFormat m_floatFormat
private boolean m_mouseOver
private boolean m_mousePressed
private int m_mouseX
private int m_mouseY
Constructor Detail |
---|
public LineChart(int lineSampleInterval, long sampleInterval, java.lang.String format, java.lang.String detailFormat, int averageWindow, boolean antialias)
lineSampleInterval
- The interval in data points at which to place vertical
lines and labels along the x (time) axis.sampleInterval
- The number of milliseconds represented by each data sample.format
- Format of the text which is displayed along the x (time) axis of
the chart. The text will display the time of the line chart at a particular
interval. The text should take the format "{0}/{1}/{2} {3}:{4}:{5}.{6}" where
{0} is replaced by the year, {1} by the month, {2} by the day, {3} by the hour,
{4} by the minute, {5} by the second, and {6} by the hundereths of a second.detailFormat
- Format of the text which is displayed over the component as
the user moves the mouse over the line chart. The text will display the exact
value of the line chart at a particular point. The text should take the format
"{0}/{1}/{2} {3}:{4}:{5}.{6}" where {0} is replaced by the year, {1} by the
month, {2} by the day, {3} by the hour, {4} by the minute, {5} by the second,
and {6} by the hundereths of a second.averageWindow
- Number of data points to do a moving average over when the
mouse is pressed on the component.antialias
- True if Antialiasing should be used when rendering the chart.Method Detail |
---|
public void setAntialias(boolean antialias)
antialias
- True to use antialiasing.public void setValues(int[] values, long time)
values
- Array of data samples.time
- The time of the start of the last sample point.private java.lang.String getFormattedTime(java.util.Date dTime, boolean detailed)
private void paintHorizontalGrid(java.awt.Graphics g, int yLabelInterval, int fontHeight, int chartLeft, int chartTop, int chartWidth, int chartHeight)
g
- Graphics object to paint with.yLabelInterval
- Interval at which the lines should be labeled.fontHeight
- The height of the current font.chartLeft
- Left edge of the chart.chartTop
- Top edge of the chart.chartWidth
- Width of the chart.chartHeight
- Height of the chart.private void paintVerticalGrid(java.awt.Graphics g, int fontHeight, int chartLeft, int chartTop, int chartWidth, int chartHeight)
g
- Graphics object to paint with.fontHeight
- The height of the current font.chartLeft
- Left edge of the chart.chartTop
- Top edge of the chart.chartWidth
- Width of the chart.chartHeight
- Height of the chart.private void paintFrame(java.awt.Graphics g, int chartLeft, int chartTop, int chartWidth, int chartHeight)
g
- Graphics object to paint with.chartLeft
- Left edge of the chart.chartTop
- Top edge of the chart.chartWidth
- Width of the chart.chartHeight
- Height of the chart.private void paintValues(java.awt.Graphics g, int chartLeft, int chartTop, int chartWidth, int chartHeight)
g
- Graphics object to paint with.chartLeft
- Left edge of the chart.chartTop
- Top edge of the chart.chartWidth
- Width of the chart.chartHeight
- Height of the chart.private void paintOverlayAt(java.awt.Graphics g, int fontHeight, int chartLeft, int chartTop, int chartWidth, int chartHeight, int mouseDataPointX, int mouseDataPointY, java.lang.String mouseDataPointValue, long mouseDataPointTime)
g
- Graphics object to paint with.fontHeight
- The height of the current font.chartLeft
- Left edge of the chart.chartTop
- Top edge of the chart.chartWidth
- Width of the chart.chartHeight
- Height of the chart.private void paintOverlay(java.awt.Graphics g, int fontHeight, int chartLeft, int chartTop, int chartWidth, int chartHeight)
g
- Graphics object to paint with.fontHeight
- The height of the current font.chartLeft
- Left edge of the chart.chartTop
- Top edge of the chart.chartWidth
- Width of the chart.chartHeight
- Height of the chart.public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
g
- Graphics to paint the chart onto.public void mouseClicked(java.awt.event.MouseEvent event)
mouseClicked
in interface java.awt.event.MouseListener
event
- Event which describes the action.public void mousePressed(java.awt.event.MouseEvent event)
mousePressed
in interface java.awt.event.MouseListener
event
- Event which describes the action.public void mouseReleased(java.awt.event.MouseEvent event)
mouseReleased
in interface java.awt.event.MouseListener
event
- Event which describes the action.public void mouseEntered(java.awt.event.MouseEvent event)
mouseEntered
in interface java.awt.event.MouseListener
event
- Event which describes the action.public void mouseExited(java.awt.event.MouseEvent event)
mouseExited
in interface java.awt.event.MouseListener
event
- Event which describes the action.public void mouseDragged(java.awt.event.MouseEvent event)
mouseDragged
in interface java.awt.event.MouseMotionListener
event
- Event which describes the motion.public void mouseMoved(java.awt.event.MouseEvent event)
mouseMoved
in interface java.awt.event.MouseMotionListener
event
- Event which describes the motion.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |