org.openware.loadsim.plotting
Class BarChart

java.lang.Object
  |
  +--org.openware.loadsim.plotting.BarChart

public class BarChart
extends java.lang.Object

Create a bar chart for statistics produced by a LoadSim simulation. The resulting chart is saved to a JPEG file and is appropriate for use in a web page. The intent is to facilitate the creation of a web site that contains results and conclusions of a set of load tests.

Basically, the high level view of the bar chart is that you simply pass in 2 arrays. One array contains the labels for each bar and the other contains the values that determine the size of the bar.

This is intended to be a quick and dirty plotting specifically for LoadSim, not a general purpose plotting tool.

Author:
Vincent Sheffer

Constructor Summary
BarChart(java.lang.String[] labels, java.lang.Double[] values)
           
 
Method Summary
 java.io.ByteArrayOutputStream getImageBytes()
          Get a ByteArrayOutputStream representation of the image.
static void main(java.lang.String[] args)
          Unit test program for the BarChart class.
 void renderChart()
          Actually render the chart.
 void save(java.lang.String fileName)
          Save the chart to a JPEG file with the given name.
 void setNumDecimalPlaces(int places)
          Set the number of decimal places to display on the y-axis (horizontal axis) for labeling the tick marks.
 void setTitle(java.lang.String title)
           
 void setXAxisLegend(java.lang.String str)
          Set the x-axis legend.
 void setYAxisLegend(java.lang.String str)
          Set the y-axis legend.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BarChart

public BarChart(java.lang.String[] labels,
                java.lang.Double[] values)
         throws java.lang.IllegalArgumentException
Method Detail

setXAxisLegend

public void setXAxisLegend(java.lang.String str)
Set the x-axis legend. That is, the text that will describe the x-axis. NOTE:The whole plot has been rotated 90 degrees, so the x-axis is actually the vertical axis.
Parameters:
str - The title of the x-axis.

setYAxisLegend

public void setYAxisLegend(java.lang.String str)
Set the y-axis legend. That is, the text that will describe the y-axis. NOTE:The whole plot has been rotated 90 degrees, so the y-axis is actually the horizontal axis.
Parameters:
str - The title of the y-axis.

setTitle

public void setTitle(java.lang.String title)

setNumDecimalPlaces

public void setNumDecimalPlaces(int places)
Set the number of decimal places to display on the y-axis (horizontal axis) for labeling the tick marks. The number of decimal places is the number of digits to the right of the decimal point. 0 is an acceptable number.

NOTE:The default is 2.

Parameters:
places - The number of places to the right of the decimal point.

getImageBytes

public java.io.ByteArrayOutputStream getImageBytes()
                                            throws java.io.IOException
Get a ByteArrayOutputStream representation of the image.

save

public void save(java.lang.String fileName)
          throws java.io.IOException
Save the chart to a JPEG file with the given name.
Parameters:
fileName - The name of the JPEG file to save the chart to.

renderChart

public void renderChart()
Actually render the chart. The chart is a fairly simple chart and does not allow for very much customization. It does, however, try it's best to adjust the length and width of the overall chart to accomodate the data that was passed into the contructor.

It will, for instance, adjust the width of the chart to accomodate the longest label.

Currently, the width of the plotting area (the area that actually contains the bars) is always set to 300 pixels. The dimensions are scaled appropriately depending on the values passed into the constructor.


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Unit test program for the BarChart class.
Throws:
java.lang.Exception -  


Copyright © 2000, 2001 Openware, Spin Software. All Rights Reserved.