www.sdmetrics.com

sdmetrics.app
Class DiagKiviat

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

public class DiagKiviat
extends sdmetrics.app.DiagPanel

Class to draw a kiviat diagram for a model element.

See Also:
Serialized Form

Nested Class Summary
static interface DiagKiviat.Listener
          Listener for mouse events in the diagram.
 
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
DiagKiviat()
           
 
Method Summary
 void addListener(DiagKiviat.Listener l)
          Add a listener for mouse click events on the diagram.
 void drawImage(java.awt.image.BufferedImage bufferedImage)
          Draws the current graph into a specified image.
 void drawPercentiles(java.lang.Boolean[] percentiles)
          Change the settings which percentiles to display on the kiviat diagram, and repain the graph accordingly.
 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.
static java.awt.Color[] initGrayShades(int numel)
          Calculate a set of increasingly lighter shades of gray.
 boolean isGraphAvailable()
          Test if the component currently has data available from which it can draw a graph.
protected  void paintComponent(java.awt.Graphics g)
          Draw the kiviat diagram based on the current data.
 void showElement(DescStats dstats, DataTable tview, int table, int elem, java.lang.Boolean[] percentiles)
          Draw the kiviat diagram for a model element.
 
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

DiagKiviat

public DiagKiviat()
Method Detail

paintComponent

protected void paintComponent(java.awt.Graphics g)
Draw the kiviat diagram 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

initGrayShades

public static java.awt.Color[] initGrayShades(int numel)
Calculate a set of increasingly lighter shades of gray. Used to display percentiles.

Parameters:
numel - The number of gray shades needed.
Returns:
Array of color objects with the requested number of gray shades, higher indices have lighter color.

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.

showElement

public void showElement(DescStats dstats,
                        DataTable tview,
                        int table,
                        int elem,
                        java.lang.Boolean[] percentiles)
Draw the kiviat diagram for a model element.

Parameters:
dstats - Object from which to obtain the descriptive statistics.
tview - Object from which to obtain the metric names and metric data.
table - Index of the table that contains the model element to draw.
elem - Index (column number) of the model element to draw.
percentiles - Array of booleans indicating which percentiles to draw.

drawPercentiles

public void drawPercentiles(java.lang.Boolean[] percentiles)
Change the settings which percentiles to display on the kiviat diagram, and repain the graph accordingly.

Parameters:
percentiles - Array of boolean indicating which percentiles to draw.

addListener

public void addListener(DiagKiviat.Listener l)
Add a listener for mouse click events on the diagram.

Parameters:
l - Listener to add.

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