www.sdmetrics.com

sdmetrics.app
Class DiagHistogram

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--sdmetrics.app.DiagPanel
                                |
                                +--sdmetrics.app.DiagHistogram
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class DiagHistogram
extends sdmetrics.app.DiagPanel

Class to draw a histogram or cumulative distribution for a metric.

See Also:
Serialized Form

Field Summary
protected  boolean dataAvailable
          Flag indicating if metric data is available to draw.
protected  java.awt.Color drawColor
          Color for lines and text.
protected  java.awt.Color fillColor
          Colors to fill histgram bars / cumulative graph.
protected  boolean graphAvailable
          Flag indicating if the available metric data is suitable to draw a graph.
protected  boolean labelAxis
          Flag indicating if the metric/element name should be written on the graph.
protected  int LABELHEIGHT
          Height of label.
 
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
DiagHistogram()
           
 
Method Summary
 void drawImage(java.awt.image.BufferedImage bufferedImage)
          Draws the current graph into a specified image.
 java.lang.String drawSVG(int width, int height)
          Get the SVG code to draw the current graph.
protected  java.lang.StringBuffer genSVGCode(int width, int height)
          Create the contents of the SVG file.
 boolean isGraphAvailable()
          Test if the component currently has data available from which it can draw a graph.
 void newData(DescStats ds, int table, int met)
          Register new data with this graph display.
protected  void paintComponent(java.awt.Graphics g)
          Draw the histogram or cumulative distribution based on the current data.
 void setCumulative(boolean b)
          Determine whether to draw the cumulative distribution or histogram.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
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, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

drawColor

protected java.awt.Color drawColor
Color for lines and text.


fillColor

protected java.awt.Color fillColor
Colors to fill histgram bars / cumulative graph.


dataAvailable

protected boolean dataAvailable
Flag indicating if metric data is available to draw.


graphAvailable

protected boolean graphAvailable
Flag indicating if the available metric data is suitable to draw a graph.


labelAxis

protected boolean labelAxis
Flag indicating if the metric/element name should be written on the graph.


LABELHEIGHT

protected final int LABELHEIGHT
Height of label.

See Also:
Constant Field Values
Constructor Detail

DiagHistogram

public DiagHistogram()
Method Detail

paintComponent

protected void paintComponent(java.awt.Graphics g)
Draw the histogram or cumulative distribution based on the current data. This method is called by Swing whenever Swing feels the diagram needs repainting.

Overrides:
paintComponent in class javax.swing.JComponent

genSVGCode

protected java.lang.StringBuffer genSVGCode(int width,
                                            int height)
Description copied from class: sdmetrics.app.DiagPanel
Create the contents of the SVG file.

Specified by:
genSVGCode in class sdmetrics.app.DiagPanel
Parameters:
width - Width of the graph to generate.
height - Height of the graph to generate.
Returns:
The SVG code to go between the /lt;svg> tags of the resulting SVG file.

newData

public void newData(DescStats ds,
                    int table,
                    int met)
Register new data with this graph display. The method retrieves the metric data sorted in ascending order from a DescStats object.

Parameters:
ds - Object from which to obtain the metric data.
table - Index of the table that contains the metric to display.
met - Index of the metric to display.

setCumulative

public void setCumulative(boolean b)
Determine whether to draw the cumulative distribution or histogram. The graph will instantly be redrawn as per the new setting.

Parameters:
b - true if the cumulative graph is to be drawn, else false

isGraphAvailable

public boolean isGraphAvailable()
Test if the component currently has data available from which it can draw a graph.

Returns:
true if a graph can be drawn based on the current data, else false.

drawSVG

public java.lang.String drawSVG(int width,
                                int height)
Get the SVG code to draw the current graph.

Parameters:
width - Width of the graph to generate.
height - Height of the graph to generate.
Returns:
String with the SVG code (<svg>...</svg>) for the graph.

drawImage

public void drawImage(java.awt.image.BufferedImage bufferedImage)
Draws the current graph into a specified image.

Parameters:
bufferedImage - Image to draw into.

www.sdmetrics.com