com.boylesoftware.cb2.util
Class StatsGraph

java.lang.Object
  extended bycom.boylesoftware.cb2.util.StatsGraph

public class StatsGraph
extends java.lang.Object

Works with EventHistory objects and generates nice images with event statistics.

Version:
$Id: StatsGraph.java,v 1.2 2003/07/20 16:04:19 levahim Exp $
Author:
Lev Himmelfarb

Nested Class Summary
protected static class StatsGraph.ScaleDescriptor
          Descriptor of a horizontal scale.
 
Field Summary
static java.lang.String DATA_BG_COLOR
           
static java.lang.String DATA_BORDER_COLOR
           
static java.lang.String DATA_COLOR
           
static java.lang.String DATA_STROKE
           
static java.lang.String GRID_COLOR
           
static java.lang.String GRID_STROKE
           
static java.lang.String LEVEL_AVG_COLOR
           
static java.lang.String LEVEL_AVG_STROKE
           
static java.lang.String LEVEL_MAX_COLOR
           
static java.lang.String LEVEL_MAX_STROKE
           
static java.lang.String LEVEL_MIN_COLOR
           
static java.lang.String LEVEL_MIN_STROKE
           
static java.lang.String MAIN_BG_COLOR
           
protected static int MAIN_MARGIN_BOTTOM
          Width of the field at the bottom of the "data" area.
protected static int MAIN_MARGIN_LEFT
          Width of the field to the left of the "data" area.
protected static int MAIN_MARGIN_RIGHT
          Width of the field to the right of the "data" area.
protected static int MAIN_MARGIN_TOP
          Width of the field at the top of the "data" area.
protected static int MIN_STEPX
          Minimum allowed distance in pixels between two vertical net-lines.
static java.lang.String SCALE_LABEL_COLOR
           
static java.lang.String SCALE_LABEL_FONT
           
protected static StatsGraph.ScaleDescriptor[] SCALES
          Scales.
 
Constructor Summary
StatsGraph()
           
 
Method Summary
static java.awt.image.BufferedImage generateImage(EventHistory eventHistory, int width, int height)
          Calls generateImage with default decoration.
static java.awt.image.BufferedImage generateImage(EventHistory eventHistory, int width, int height, java.util.Map decor)
          Generates a graph image from the samples in the specified EventHistory object.
static java.awt.image.BufferedImage generateTinyImage(EventHistory eventHistory, int width, int height, long maxSample)
          Calls generateTinyImage with default decoration.
static java.awt.image.BufferedImage generateTinyImage(EventHistory eventHistory, int width, int height, long maxSample, java.util.Map decor)
          Analogue of the generateImage method, but the output image contains only the samples data and no scales, fields and other decorations.
protected static java.lang.Object getDecorElement(java.lang.String name, java.util.Map elements)
          Returns the named decoration element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAIN_MARGIN_LEFT

protected static final int MAIN_MARGIN_LEFT
Width of the field to the left of the "data" area.

See Also:
Constant Field Values

MAIN_MARGIN_RIGHT

protected static final int MAIN_MARGIN_RIGHT
Width of the field to the right of the "data" area.

See Also:
Constant Field Values

MAIN_MARGIN_TOP

protected static final int MAIN_MARGIN_TOP
Width of the field at the top of the "data" area.

See Also:
Constant Field Values

MAIN_MARGIN_BOTTOM

protected static final int MAIN_MARGIN_BOTTOM
Width of the field at the bottom of the "data" area.

See Also:
Constant Field Values

MIN_STEPX

protected static final int MIN_STEPX
Minimum allowed distance in pixels between two vertical net-lines.

See Also:
Constant Field Values

MAIN_BG_COLOR

public static final java.lang.String MAIN_BG_COLOR
See Also:
Constant Field Values

DATA_BG_COLOR

public static final java.lang.String DATA_BG_COLOR
See Also:
Constant Field Values

DATA_BORDER_COLOR

public static final java.lang.String DATA_BORDER_COLOR
See Also:
Constant Field Values

DATA_STROKE

public static final java.lang.String DATA_STROKE
See Also:
Constant Field Values

DATA_COLOR

public static final java.lang.String DATA_COLOR
See Also:
Constant Field Values

GRID_STROKE

public static final java.lang.String GRID_STROKE
See Also:
Constant Field Values

GRID_COLOR

public static final java.lang.String GRID_COLOR
See Also:
Constant Field Values

SCALE_LABEL_FONT

public static final java.lang.String SCALE_LABEL_FONT
See Also:
Constant Field Values

SCALE_LABEL_COLOR

public static final java.lang.String SCALE_LABEL_COLOR
See Also:
Constant Field Values

LEVEL_MAX_COLOR

public static final java.lang.String LEVEL_MAX_COLOR
See Also:
Constant Field Values

LEVEL_MAX_STROKE

public static final java.lang.String LEVEL_MAX_STROKE
See Also:
Constant Field Values

LEVEL_MIN_COLOR

public static final java.lang.String LEVEL_MIN_COLOR
See Also:
Constant Field Values

LEVEL_MIN_STROKE

public static final java.lang.String LEVEL_MIN_STROKE
See Also:
Constant Field Values

LEVEL_AVG_COLOR

public static final java.lang.String LEVEL_AVG_COLOR
See Also:
Constant Field Values

LEVEL_AVG_STROKE

public static final java.lang.String LEVEL_AVG_STROKE
See Also:
Constant Field Values

SCALES

protected static final StatsGraph.ScaleDescriptor[] SCALES
Scales.

Constructor Detail

StatsGraph

public StatsGraph()
Method Detail

generateImage

public static java.awt.image.BufferedImage generateImage(EventHistory eventHistory,
                                                         int width,
                                                         int height)
Calls generateImage with default decoration.


generateImage

public static java.awt.image.BufferedImage generateImage(EventHistory eventHistory,
                                                         int width,
                                                         int height,
                                                         java.util.Map decor)
Generates a graph image from the samples in the specified EventHistory object.

Parameters:
eventHistory - the samples data.
width - width in pixels of the data field of the generated image. The overall width of the generated image will be greater, because we add special fields around the graph itself with various information.
height - height in pixels of the data field of the generated image. The overall height of the generated image will be greater, because we add special fields around the graph itself with various information.
decor - collection of decoration elements that override the default ones. Keys in the map are names of the elements and values are decoration elements.
Returns:
the generated image.

generateTinyImage

public static java.awt.image.BufferedImage generateTinyImage(EventHistory eventHistory,
                                                             int width,
                                                             int height,
                                                             long maxSample)
Calls generateTinyImage with default decoration.


generateTinyImage

public static java.awt.image.BufferedImage generateTinyImage(EventHistory eventHistory,
                                                             int width,
                                                             int height,
                                                             long maxSample,
                                                             java.util.Map decor)
Analogue of the generateImage method, but the output image contains only the samples data and no scales, fields and other decorations.

Parameters:
eventHistory - the samples data.
width - the output image width.
height - the output image height.
maxSample - assumed value of maximum sample. If this parameter is less than zero the "real" maximum is taken from the event history data.
decor - collection of decoration elements that override the default ones. Keys in the map are names of the elements and values are decoration elements.
Returns:
the resulting image.

getDecorElement

protected static final java.lang.Object getDecorElement(java.lang.String name,
                                                        java.util.Map elements)
Returns the named decoration element.

Parameters:
name - name of the element requested.
elements - collection of elements, may be null.
Returns:
the requested element.


Copyright © 2002,2003,2004 - Boyle Software, Inc.