org.corpstein.image
Class TestChartFactory

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.corpstein.image.TestChartFactory
All Implemented Interfaces:
junit.framework.Test

public class TestChartFactory
extends junit.framework.TestCase

Unit tests for the org.corpstein.image.ChartFactory class. As a side effect of exercising the ChartFactory features, this class provides pretty good code examples for creating various kinds of charts.

Version:
$Revision: 1.4 $ $Date: 2005/04/24 21:00:47 $
Author:
David Corpstein

Constructor Summary
TestChartFactory()
           
 
Method Summary
static void main(java.lang.String[] args)
          Added so that the test can be run directly
protected  void setUp()
          Automatically called by JUnit before execution of each test case
 void testBar01()
          Create a simple bar chart with 18 bars using default style and metrics.
 void testBar02()
          Create a bar chart, replacing the default style with different colors, enabling the chart border, and adding an ImageLayer to place a logo under the first bar.
 void testBar03()
          Create a bar chart with custom style and metrics, using a bar color association key and a TextLayer to add a source reference in the background of the chart image.
 void testBar04()
          Create a bar chart with a gradient background, using diagonal bar labels and a transparent gif image defined by a URI to display a tornado graphic in the chart.
 void testBar05()
          Create a bar chart with custom style, horizontal bar labels, a transparent PNG ImageLayer, and a TextLayer.
 void testBar06()
          Create a bar chart with GradientPaint bar colors, a TextLayer, and a bar color association key (despite the relatively few bars).
 void testBar07()
          Create a bar chart with custom style and using diagonal bar labels and a large JPEG ImageLayer.
 void testBar08()
          Create a custom-styled chart that is intended to stress title and label width limits as well as the overall bar limit ChartStyle.MAX_BARS.
 void testCanReadFormat()
          A unit test to verify ChartFactory.canReadFormat returns the correct value with several parameters
 void testCanWriteFormat()
          A unit test to verify ChartFactory.canWriteFormat returns the correct value with several parameters
 void testLine01()
          Create a simple line chart with custom colors and 2 series.
 void testLine02()
          Create a line chart with 8 lines, a gradient background, and point marks enabled.
 void testLine03()
          Create a line chart with 8 lines and custom-sized point marks.
 void testLine04()
          Create a line chart with 5 lines, a gradient backdrop, and a TextLayer source reference in the corner of the image.
 void testLine05()
          Create a line chart of sine waves with custom fonts and colors.
 void testLine06()
          Create a line chart with partially transparent walls and a fancy, PNG ImageLayer that shows through the walls.
 void testMultiRow01()
          Create a multi-row bar chart with 2 rows of data and custom bar Paint.
 void testMultiRow02()
          Create a multirow bar chart with 3 rows of data, a transparent backdrop and a PNG ImageLayer showing through the transparency.
 void testMultiRow03()
          Create a multirow bar chart with 3 rows of data and a fancy transparent PNG title ImageLayer.
 void testMultiRow04()
          Create a multirow bar chart with 3 rows of data and a GradientPaint on the back row.
 void testMultiRow05()
          Create a multirow bar chart with 3 rows of data, a custom ImageLayer, and transparent bars.
 void testMultiRow06()
          Create a custom-styled, multirow bar chart with 3 rows of data and Unicode text for title and labels.
 void testMultiRow07()
          Create a multirow bar chart with 4 rows of data.
 void testMultiRow08()
          Create a multirow bar chart with 4 rows of data and a fancy transparent PNG title ImageLayer.
 void testMultiRow09()
          Create a multirow bar chart with 2 rows of data, transparent bars with value labels, and a PNG watermark.
 void testPie01()
          Create a simple pie chart with one dominant category and 3 smaller categories using two ImageLayers.
 void testPie02()
          Create a pie chart with GradientPaints, 5 categories that are not sorted according to value and a TextLayer source reference.
 void testPie03()
          Create a pie chart with 18 categories.
 void testPie04()
          Create a pie chart with 30 categories and custom fonts.
 void testPie05()
          Create a pie chart with a custom GradientPaint and some categories that are less than 2% of the total pie.
 void testPie06()
          Create a pie chart with 30 sorted categories.
 void testPie07()
          Create a pie chart with transparent slices and a watermark behind the pie.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestChartFactory

public TestChartFactory()
Method Detail

setUp

protected void setUp()
Automatically called by JUnit before execution of each test case

Overrides:
setUp in class junit.framework.TestCase

testCanReadFormat

public void testCanReadFormat()
A unit test to verify ChartFactory.canReadFormat returns the correct value with several parameters


testCanWriteFormat

public void testCanWriteFormat()
A unit test to verify ChartFactory.canWriteFormat returns the correct value with several parameters


testBar01

public void testBar01()
Create a simple bar chart with 18 bars using default style and metrics. This chart is based on one published at http://www.scotland.gov.uk/library/sas/sa09-22.htm.


testBar02

public void testBar02()
Create a bar chart, replacing the default style with different colors, enabling the chart border, and adding an ImageLayer to place a logo under the first bar. This chart is based on data published by Netcraft (http://www.netcraft.com).


testBar03

public void testBar03()
Create a bar chart with custom style and metrics, using a bar color association key and a TextLayer to add a source reference in the background of the chart image. This chart is based on data published by Netcraft (http://www.netcraft.com).


testBar04

public void testBar04()
Create a bar chart with a gradient background, using diagonal bar labels and a transparent gif image defined by a URI to display a tornado graphic in the chart. This image also contains two text layers - one in the background of the chart and one at the bottom. This chart is based on data published by NASA at http://thunder.msfc.nasa.gov/bookshelf/docs/white_paper_driscoll.html


testBar05

public void testBar05()
Create a bar chart with custom style, horizontal bar labels, a transparent PNG ImageLayer, and a TextLayer. The data for this chart was published by Netcraft (http://www.netcraft.com).


testBar06

public void testBar06()
Create a bar chart with GradientPaint bar colors, a TextLayer, and a bar color association key (despite the relatively few bars). Data for this chart is published by TechRepublic.


testBar07

public void testBar07()
Create a bar chart with custom style and using diagonal bar labels and a large JPEG ImageLayer. This chart is based on data published at http://wlapwww.gov.bc.ca/soerpt/995wildlife/gheron.html


testBar08

public void testBar08()
Create a custom-styled chart that is intended to stress title and label width limits as well as the overall bar limit ChartStyle.MAX_BARS. It also demonstrates a bug that although only ChartStyle.MAX_BARS bars will be displayed, all data points are taken into consideration when preparing the pixel interval.


testLine01

public void testLine01()
Create a simple line chart with custom colors and 2 series.


testLine02

public void testLine02()
Create a line chart with 8 lines, a gradient background, and point marks enabled.


testLine03

public void testLine03()
Create a line chart with 8 lines and custom-sized point marks.


testLine04

public void testLine04()
Create a line chart with 5 lines, a gradient backdrop, and a TextLayer source reference in the corner of the image. This chart is based on data published by Netcraft (http://www.netcraft.com)


testLine05

public void testLine05()
Create a line chart of sine waves with custom fonts and colors. Use a UNICODE character in data labels.


testLine06

public void testLine06()
Create a line chart with partially transparent walls and a fancy, PNG ImageLayer that shows through the walls. Use a loop to populate the data with parabola lines.


testMultiRow01

public void testMultiRow01()
Create a multi-row bar chart with 2 rows of data and custom bar Paint. This chart is based on data published at http://wlapwww.gov.bc.ca/soerpt/995wildlife/gheron.html


testMultiRow02

public void testMultiRow02()
Create a multirow bar chart with 3 rows of data, a transparent backdrop and a PNG ImageLayer showing through the transparency.


testMultiRow03

public void testMultiRow03()
Create a multirow bar chart with 3 rows of data and a fancy transparent PNG title ImageLayer. This chart illustrates the visibility of back rows that are overshadowed by front rows. Also customize the Paints for the bars to get slightly brighter and more transparent as they grow.


testMultiRow04

public void testMultiRow04()
Create a multirow bar chart with 3 rows of data and a GradientPaint on the back row. This chart is based on data published at http://www.w3schools.com/browsers/browsers_stats.asp


testMultiRow05

public void testMultiRow05()
Create a multirow bar chart with 3 rows of data, a custom ImageLayer, and transparent bars. This chart is based on data published at http://www.fistmonday.dk/issues/issue9_11/shimizu/


testMultiRow06

public void testMultiRow06()
Create a custom-styled, multirow bar chart with 3 rows of data and Unicode text for title and labels. Any misspellings, witticisms, or other faults are entirely my own. -DCC


testMultiRow07

public void testMultiRow07()
Create a multirow bar chart with 4 rows of data. The data for this chart is based on data published by Netcraft (http://www.netcraft.com)


testMultiRow08

public void testMultiRow08()
Create a multirow bar chart with 4 rows of data and a fancy transparent PNG title ImageLayer.


testMultiRow09

public void testMultiRow09()
Create a multirow bar chart with 2 rows of data, transparent bars with value labels, and a PNG watermark.


testPie01

public void testPie01()
Create a simple pie chart with one dominant category and 3 smaller categories using two ImageLayers. This chart is based on data published by Netcraft at http://news.netcraft.com/archives/web_server_survey.html


testPie02

public void testPie02()
Create a pie chart with GradientPaints, 5 categories that are not sorted according to value and a TextLayer source reference. This chart is based on data published by TechRepublic.


testPie03

public void testPie03()
Create a pie chart with 18 categories. This chart is based on data published at http://www.scotland.gov.uk/library/sas/sa09-22.htm.


testPie04

public void testPie04()
Create a pie chart with 30 categories and custom fonts. This chart is based on data published by SourceForge (http://www.sourceforge.net) as of January 2005.


testPie05

public void testPie05()
Create a pie chart with a custom GradientPaint and some categories that are less than 2% of the total pie. The data is taken from the Free/Libre and Open Source Software Survey and Study by the University of Maastricht and Berlecon Research GmbH, http://www.infonomics.nl/FLOSS/report


testPie06

public void testPie06()
Create a pie chart with 30 sorted categories. Source data is from http://distrowatch.com/stats.php?section=popularity


testPie07

public void testPie07()
Create a pie chart with transparent slices and a watermark behind the pie.


main

public static void main(java.lang.String[] args)
Added so that the test can be run directly

Parameters:
args - Command-line arguments (none expected)


Last update: 20050424 1651