Class LineChart

  • All Implemented Interfaces:
    java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener

    public class LineChart
    extends javax.swing.JComponent
    implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener
    Draws a nice pretty chart given a set of data.
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.BaselineResizeBehavior
    • Field Summary

      • Fields inherited from class javax.swing.JComponent

        TOOL_TIP_TEXT_KEY, 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

      Constructors 
      Constructor Description
      LineChart​(int lineSampleInterval, long sampleInterval, java.lang.String format, java.lang.String detailFormat, int averageWindow, boolean antialias)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      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, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • LineChart

        public LineChart​(int lineSampleInterval,
                         long sampleInterval,
                         java.lang.String format,
                         java.lang.String detailFormat,
                         int averageWindow,
                         boolean antialias)
        Parameters:
        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

      • setAntialias

        public void setAntialias​(boolean antialias)
        Sets the antialias flag to control whether or not antialiasing will be used when rendering the component.
        Parameters:
        antialias - True to use antialiasing.
      • setValues

        public void setValues​(int[] values,
                              long time)
        Sets the data samples to be displayed by the line chart.
        Parameters:
        values - Array of data samples.
        time - The time of the start of the last sample point.
      • paintComponent

        public void paintComponent​(java.awt.Graphics g)
        Paints the component.
        Parameters:
        g - Graphics to paint the chart onto.
      • mouseClicked

        public void mouseClicked​(java.awt.event.MouseEvent event)
        Called when the mouse is clicked ont the component.
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
        Parameters:
        event - Event which describes the action.
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent event)
        Called when the mouse is pressed ont the component.
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
        Parameters:
        event - Event which describes the action.
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent event)
        Called when the mouse is released ont the component.
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
        Parameters:
        event - Event which describes the action.
      • mouseEntered

        public void mouseEntered​(java.awt.event.MouseEvent event)
        Called when the mouse is enters the component.
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
        Parameters:
        event - Event which describes the action.
      • mouseExited

        public void mouseExited​(java.awt.event.MouseEvent event)
        Called when the mouse is exits the component.
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
        Parameters:
        event - Event which describes the action.
      • mouseDragged

        public void mouseDragged​(java.awt.event.MouseEvent event)
        Called when the mouse is dragged over the component.
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
        Parameters:
        event - Event which describes the motion.
      • mouseMoved

        public void mouseMoved​(java.awt.event.MouseEvent event)
        Called when the mouse is moved over the component.
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
        Parameters:
        event - Event which describes the motion.