//------------------------------------------------------------------------
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
//------------------------------------------------------------------------

package org.corpstein.image;

import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;

import junit.framework.*;

//-------------------------------------TestChartFactory class------------------
/**
 *
 * 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.
 *
 *  @author <A HREF="mailto:davidcorpstein@corpstein.org">David Corpstein</A>
 *  @version $Revision: 1.2 $ $Date: 2005/02/03 00:09:57 $
 */
//-----------------------------------------------------------------------------
public class TestChartFactory extends TestCase
{

    private ChartFactory factory;

    //---------------------------------TestChartFactory.setUp------------------
    /**
     * Automatically called by JUnit before execution of each test case
     */
    //-------------------------------------------------------------------------
    protected void setUp()
    {
        factory = ChartFactory.getInstance();
    } // TestChartFactory.setUp


    //---------------------------------TestChartFactory.testCanReadFormat------
    /**
     * A unit test to verify ChartFactory.canReadFormat returns the correct 
     * value with several parameters
     */
    //-------------------------------------------------------------------------
    public void testCanReadFormat()
    {
        assertTrue(factory.canReadFormat("png"));
        assertTrue(factory.canReadFormat("jpg"));

        assertFalse(factory.canReadFormat("pdf"));
        assertFalse(factory.canReadFormat("sh"));
        assertFalse(factory.canReadFormat(""));

        try { factory.canReadFormat(null); fail("Expected IllegalArgumentException since the argument is null"); } catch(IllegalArgumentException e) { /* Test Succeeded */ }
    } // TestChartFactory.testCanReadFormat


    //---------------------------------TestChartFactory.testCanWriteFormat-----
    /**
     * A unit test to verify ChartFactory.canWriteFormat returns the correct 
     * value with several parameters
     */
    //-------------------------------------------------------------------------
    public void testCanWriteFormat()
    {
        assertTrue(factory.canWriteFormat("png"));
        assertTrue(factory.canWriteFormat("jpg"));

        assertFalse(factory.canWriteFormat("pdf"));
        assertFalse(factory.canWriteFormat("sh"));
        assertFalse(factory.canWriteFormat(""));

        try { factory.canWriteFormat(null); fail("Expected IllegalArgumentException since the argument is null"); } catch(IllegalArgumentException e) { /* Test Succeeded */ }
    } // TestChartFactory.testCanWriteFormat


    //---------------------------------TestChartFactory.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.
     */
    //-------------------------------------------------------------------------
    public void testBar01()
    {
        ChartData data = new ChartData();

        // Set the chart title.  If the title is too long, the title font size
        // will be decremented until it fits in the image or the font size
        // reaches ChartStyle.titleFontMinimumSize.  If the size has been 
        // decremented as far as possible but the title String is still too
        // wide, the title will be truncated until it fits.
        data.setTitle("Scottish Fishing Vessels by District, 1997");
        
        // Add labels and values to the chart.  Single-row bar charts have
        // the same number of labels and values, so ChartData.addPoint
        // is used to add labels and values at the same time.  When needed
        // (such as line charts that have total_values / total_labels
        // lines), you can also call ChartData.addValue and ChartData.addLabel
        // separately.
        data.addPoint("Aberdeen", 46);
        data.addPoint("Arbroath", 72);
        data.addPoint("Ayr", 181);
        data.addPoint("Buckle", 151);
        data.addPoint("Campbelltown", 190);
        data.addPoint("Eyemouth", 125);
        data.addPoint("Fraserburgh", 271);
        data.addPoint("Kinlochbervie", 28);
        data.addPoint("Lochinver", 32);
        data.addPoint("Mallaig", 248);
        data.addPoint("Oban", 175);
        data.addPoint("Orkney", 206);
        data.addPoint("Peterhead", 159);
        data.addPoint("Pittenweem", 103);
        data.addPoint("Shetland", 221);
        data.addPoint("Stornoway", 353);
        data.addPoint("Ullapool", 60);
        data.addPoint("Wick", 142);

        // Create the bar chart Image using the ChartFactory.  When called
        // with just a ChartData object, ChartFactory.create[Bar|Line|Pie]Chart
        // will use default ChartStyle and ChartMetrics
        Image image = factory.createBarChart(data);
        
        try
        {
            // Write the Image to a file
            factory.writeImage(image, "test/results/TestChartFactory_TestBar01.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }

    } // TestChartFactory.testBar01


    //---------------------------------TestChartFactory.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).
     */
    //-------------------------------------------------------------------------
    public void testBar02()
    {
        // Create a ChartStyle object so that the style can be customized
        // and passed to ChartStyle.create[Bar|Line|Pie]Chart 
        ChartStyle style = new ChartStyle();

        // The "walls" are the 3 planes behind the bars/lines that have
        // the scale drawn on them
        style.setPaint(ChartStyle.COLOR_WALL, new Color(1.0f,  1.0f,  0.8f));

        // Chart borders are a 3 pixel wide color gradient based on the
        // the background color of the chart (lighter if the background
        // is dark; darker if the background is light).  They are drawn
        // around the edge of the chart image.  They are disabled by default
        // but can be enabled by calling ChartStyle.setBorderEnabled(true).
        style.setBorderEnabled(true);
        
        // Value labels are rectangles drawn on the top of the bar.  The 
        // rectangle is bordered in the edge color and uses the Paint (at 
        // alpha 1.0 or 100% opacity) of the bar it is on.  Then the value
        // (showing up to 2 decimal places) is drawn on the rectangle in the
        // edge color.  Value labels are disabled by default but can be
        // enabled by calling ChartStyle.setValueLabelsEnabled(true)
        style.setValueLabelsEnabled(true);

        // There are 3 key types for single-row charts: diagonal labels, 
        // horizontal labels, and bar-color association.  For line charts 
        // or multi-row bar charts, bar-color association is used for
        // series and diagonal or horizontal labels are used for x-axis
        // labels
        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        
        // setBarPaint(Paint) changes the paint used to paint all of the
        // bars.  setBarPaint(index, Paint) only changes the paint for
        // one bar.  To make the bar color transparent, use a Color with
        // an alpha value less than 1.0.  You can also use a GradientPaint
        // with two colors and an x,y value for each color.
        style.setBarPaint(Color.YELLOW);

        // To embed an image into the chart, use ChartStyle.addLayer(Layer).
        // The Layer class has two generic subclasses for adding images
        // (ImageLayer) or text labels (TextLayer).  We will use an ImageLayer,
        // which takes a filename (String), java.awt.Image or URI in the constructor.  
        // We want to place the embeded image above the backdrop (the walls that
        // are behind the bars and the scale lines) and below the scale, so
        // we set the z-index of the layer slightly higher than the backdrop.
        // The embeded image file contains an alpha channel (transparency). 
        try
        {
            ImageLayer layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage10.gif").getPath()));
            layer.setX(40);
            layer.setY(406);
            layer.setZ(ChartMetrics.Z_INDEX_BACKDROP + 1);
            style.addLayer(layer);
        }
        catch(URISyntaxException e)
        {
            e.printStackTrace(System.err);
            fail("Unable to access the image URI: " + e);   
        }

        ChartData data = new ChartData();
        data.setTitle("April 2003 Java Servlet Engine IP Addresses (www.netcraft.com)");
        
        data.addPoint("Tomcat",        9253);
        data.addPoint("Resin",         9059);
        data.addPoint("IBM",           9049);
        data.addPoint("Oracle",        5156);
        data.addPoint("WebLogic",      1716);
        data.addPoint("Orion",         1062);
        data.addPoint("Jetty",          635);
        data.addPoint("JavaWebServer",  388);
        data.addPoint("SilverStream",   370);
        data.addPoint("JRun",           264);

        // Use the data and the custom style to create the image
        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestBar02.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testBar02


    //---------------------------------TestChartFactory.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).
     */
    //-------------------------------------------------------------------------
    public void testBar03()
    {
        ChartStyle style = new ChartStyle();

        // Customize all of the default ChartStyle colors except for bar colors
        style.setPaint(ChartStyle.COLOR_LABEL,      new Color(1.0f, 1.0f, 0.9f)); 
        style.setPaint(ChartStyle.COLOR_SHADOW,     new Color(0.0f, 0.2f, 0.0f));
        style.setPaint(ChartStyle.COLOR_BACKGROUND, new Color(0.1f, 0.5f, 0.1f));
        style.setPaint(ChartStyle.COLOR_WALL,       new Color(0.4f, 0.8f, 0.4f));
        style.setPaint(ChartStyle.COLOR_EDGE,       new Color(0.0f, 0.1f, 0.0f));    

        // The default color for the first bar is green, which would not work
        // well with the green background and walls that we defined above.
        // Change the color for just the first bar to yellow.  To change the
        // color of all bars, we would omit the first parameter (the index)
        style.setBarPaint(0, new Color(0.9f, 0.9f, 0.6f));
        
        // Since we are creating a single-row bar chart, we can use any of the 
        // three key types.  We will use bar color association, which 
        // draws labeled, color-coded boxes at the bottom of the chart that 
        // match the color of the associated bar
        style.setKeyType(ChartStyle.KEY_TYPE_BAR_COLOR_ASSOCIATION);
        style.setValueLabelsEnabled(true);
        style.setBorderEnabled(true);
        
        // To embed a floating label in the chart, we will use a TextLayer
        // with text in a white font.  We want the TextLayer to appear
        // above the backdrop and behind the scale, so we set the z-index
        // to ChartMetrics.Z_INDEX_BACKDROP + 1.
        TextLayer layer = new TextLayer("Source: Netcraft (www.netcraft.com)");
        layer.setFont(new Font("SansSerif", Font.BOLD, 12));
        layer.setFontColor(Color.WHITE);
        layer.setX(300);
        layer.setY(100);
        layer.setZ(ChartMetrics.Z_INDEX_BACKDROP + 1);
        style.addLayer(layer);
        
        ChartData data = new ChartData();
        data.setTitle("April 2003 Java Servlet Engine Sites");
        
        data.addPoint("Tomcat",        64532);
        data.addPoint("Resin",        138664);
        data.addPoint("IBM",           38730);
        data.addPoint("Oracle",        18072);
        data.addPoint("WebLogic",       6819);
        data.addPoint("Orion",          6358);
        data.addPoint("Jetty",          1865);
        data.addPoint("JavaWebServer",   949);
        data.addPoint("SilverStream",    966);
        data.addPoint("JRun",          17859);

        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestBar03.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }

    } // TestChartFactory.testBar03


    //---------------------------------TestChartFactory.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
     */
    //-------------------------------------------------------------------------
    public void testBar04()
    {
        ChartStyle style = new ChartStyle();

        style.setPaint(ChartStyle.COLOR_LABEL,      new Color(1.0f, 1.0f, 0.9f));
        style.setPaint(ChartStyle.COLOR_SHADOW,     new Color(0.0f, 0.2f, 0.0f));
        
        // Let's create a GradientPaint that starts with green in the middle of the
        // image and fades to darker green in the bottom right.  We will use this
        // gradient to paint the background of the chart.
        style.setPaint(ChartStyle.COLOR_BACKGROUND, new GradientPaint(320, 240, new Color(0.1f, 0.5f, 0.1f), 640, 480, new Color(0.0f, 0.3f, 0.1f)));
        
        // Change the backdrop to use a lighter green that fades in the same direction
        style.setPaint(ChartStyle.COLOR_WALL,       new GradientPaint(250, 135, new Color(0.4f, 0.8f, 0.4f), 500, 270, new Color(0.3f, 0.7f, 0.3f)));
        style.setPaint(ChartStyle.COLOR_EDGE,       new Color(0.0f, 0.1f, 0.0f));    

        style.setBarPaint(new Color(0.9451f, 0.9451f, 0.1059f));   // All bars

        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);

        // Embed a transparent gif in the chart, setting its z-index value so that
        // it is above the backdrop (the 3 walls behind the bars) and the scale
        // but below the bars.
        try
        {
            ImageLayer layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage03.gif").getPath()));
            layer.setX(416);
            layer.setY(231);
            layer.setZ(ChartMetrics.Z_INDEX_SCALE + 1);
            style.addLayer(layer);
        }
        catch(URISyntaxException e)
        {
            e.printStackTrace(System.err);
            fail("Unable to access the image URI: " + e);   
        }
        
        // Add a TextLayer that places a caption above the ImageLayer
        TextLayer textLayer = new TextLayer("Tornado reported at 22:56:00");
        textLayer.setFont(new Font("SansSerif", Font.BOLD, 14));
        textLayer.setFontColor(Color.WHITE);
        textLayer.setX(355);
        textLayer.setY(195);
        textLayer.setZ(ChartMetrics.Z_INDEX_SCALE + 1);
        style.addLayer(textLayer);

        // Add a TextLayer that places a source reference in the lower right corner
        textLayer = new TextLayer("http://thunder.msfc.nasa.gov/bookshelf/docs/white_paper_driscoll.html");
        textLayer.setFont(new Font("SansSerif", Font.BOLD, 14));
        textLayer.setFontColor(Color.WHITE);
        textLayer.setX(60);
        textLayer.setY(430);
        textLayer.setZ(ChartMetrics.Z_INDEX_TITLE + 1);
        style.addLayer(textLayer);

        ChartData data = new ChartData();
        data.setTitle("Storm Cell Lightning Strikes (17 Apr 1995)");
        
        data.addPoint("22:50:00",     2);
        data.addPoint("22:50:30",     1);
        data.addPoint("22:51:00",     2);
        data.addPoint("22:51:30",     1);
        data.addPoint("22:52:00",    75);
        data.addPoint("22:52:30",   121);
        data.addPoint("22:53:00",    95);
        data.addPoint("22:53:30",    58);
        data.addPoint("22:54:00",    51);
        data.addPoint("22:54:30",    30);
        data.addPoint("22:55:00",     5);
        data.addPoint("22:55:30",     3);
        data.addPoint("22:56:00",     0);
        data.addPoint("22:56:30",     2);
        data.addPoint("22:57:00",     1);
        data.addPoint("22:57:30",     0);

        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestBar04.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }

    } // TestChartFactory.testBar04


    //---------------------------------TestChartFactory.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).
     */
    //-------------------------------------------------------------------------
    public void testBar05()
    {
        ChartStyle style = new ChartStyle();

        style.setBorderEnabled(true);
        style.setLabelFont(new Font("SansSerif", Font.BOLD, 12));
        style.setKeyType(ChartStyle.KEY_TYPE_HORIZONTAL_BAR_LABELS);
        style.setValueLabelsEnabled(true);
        
        try
        {
            // Add a fancy title image that is a transparent PNG.  Since
            // we want to wrap up this class and everything it needs in a jar
            // file, we will use the ImageLayer(URI) constructor to define
            // the title image in the jar.
            ImageLayer layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage04.png").getPath()));
            layer.setX(20);
            layer.setY(20);
            layer.setZ(ChartMetrics.Z_INDEX_TITLE + 1);
            style.addLayer(layer);

            // Put another transparent PNG under the first bar
            layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage09.png").getPath()));
            layer.setX(40);
            layer.setY(396);
            style.addLayer(layer);

            // Put a transparent PNG along the y axis
            layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage14.png").getPath()));
            layer.setX(12);
            layer.setY(180);
            style.addLayer(layer);

        }
        catch(URISyntaxException e)
        {
            e.printStackTrace(System.err);
            fail("Unable to access the image URI: " + e);   
        }

        TextLayer textLayer = new TextLayer("Source: Netcraft (www.netcraft.com)");
        textLayer.setFont(new Font("SansSerif", Font.PLAIN, 12));
        textLayer.setFontColor(new Color(0.0f, 0.0f, 1.0f));
        textLayer.setX(415);
        textLayer.setY(455);
        textLayer.setZ(ChartMetrics.Z_INDEX_TITLE + 1);
        style.addLayer(textLayer);

        ChartData data = new ChartData();
        data.addPoint("Apache",    68.43);
        data.addPoint("Microsoft", 20.86);
        data.addPoint("Sun",       3.14);
        data.addPoint("Zeus",      1.19);

        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestBar05.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }

    } // TestChartFactory.testBar05


    //---------------------------------TestChartFactory.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.
     */
    //-------------------------------------------------------------------------
    public void testBar06()
    {
        ChartStyle style = new ChartStyle();

        style.setPaint(ChartStyle.COLOR_LABEL,  new Color(0.5f,  0.0f,  0.0f));
        style.setPaint(ChartStyle.COLOR_SHADOW, new Color(0.95f, 0.85f, 0.85f));
        style.setPaint(ChartStyle.COLOR_WALL,   new Color(1.0f,  1.0f,  0.8f));
        style.setPaint(ChartStyle.COLOR_EDGE,   new Color(0.2f,  0.0f,  0.0f));    

        TextLayer layer = new TextLayer("Source: TechRepublic survey");
        layer.setFontColor(new Color(0.5f, 0.0f, 0.0f));
        layer.setX(390);
        layer.setY(445);
        style.addLayer(layer);

        style.setValueLabelsEnabled(true);
        style.setKeyType(ChartStyle.KEY_TYPE_BAR_COLOR_ASSOCIATION);
        
        ChartData data = new ChartData();
        data.setTitle("Most Influential Factors in Moving to Linux");
        
        data.addPoint("Cost", 40.0);
        data.addPoint("Ease of Implementation", 10.0);
        data.addPoint("Ease of Training", 3.6);
        data.addPoint("Reliability", 39.2);
        data.addPoint("Scalability", 7.2);

        // For each bar, set its paint to a GradientPaint that starts with 
        // the default color at the bottom of the bar and gets brighter as 
        // it grows.  We use the convenience class Palette to brighten or
        // darken Colors or GradientPaints (based on a blend of the two
        // gradient colors).
        for(int i=0; i<data.getTotalValues(); i++)
        {
            style.setBarPaint(i, new GradientPaint(330, 340, (Color)style.getBarPaint(i), 330, 200, Palette.brighten(style.getBarPaint(i), 3)));
        }
            
        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestBar06.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }

    } // TestChartFactory.testBar06


    //---------------------------------TestChartFactory.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
     */
    //-------------------------------------------------------------------------
    public void testBar07()
    {
        ChartStyle style = new ChartStyle();

        style.setPaint(ChartStyle.COLOR_WALL, new Color(0.16f, 0.36f, 0.35f));
        style.setPaint(ChartStyle.COLOR_EDGE, new Color(0.0f,  0.2f,  0.0f));    
        style.setValueLabelsEnabled(true);

        // Embed a 116KB JPEG
        try
        {
            ImageLayer layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage05.jpg").getPath()));
            layer.setX(77);
            layer.setY(74);
            layer.setZ(ChartMetrics.Z_INDEX_BACKDROP + 1);
            style.addLayer(layer);
        }
        catch(URISyntaxException e)
        {
            e.printStackTrace(System.err);
            fail("Unable to access the image URI: " + e);   
        }

        TextLayer textLayer = new TextLayer("Source: British Columbia Ministry of Water, Land, and Air Protection");
        textLayer.setFont(new Font("SansSerif", Font.BOLD, 12));
        textLayer.setFontColor(new Color(0.0f, 0.0f, 1.0f));
        textLayer.setX(120);
        textLayer.setY(410);
        style.addLayer(textLayer);

        textLayer = new TextLayer("http://wlapwww.gov.bc.ca/soerpt/995wildlife/gheron.html");
        textLayer.setFont(new Font("SansSerif", Font.BOLD, 12));
        textLayer.setFontColor(new Color(0.0f, 0.0f, 1.0f));
        textLayer.setX(145);
        textLayer.setY(425);
        style.addLayer(textLayer);

        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        // Since the backdrop has a nice ImageLayer on it, let's set all of the
        // bar colors to yellow with some transparency.  Since we can use any 
        // java.awt.Paint, we can choose between Colors, GradientPaints, and
        // TexturePaints.
        style.setBarPaint(new Color(0.94f, 0.94f, 0.0f, 0.9f));  

        ChartData data = new ChartData();
        data.setTitle("PCB Contaminants in Great Blue Heron Eggs (mg/kg)");
        
        data.addPoint("1977", 7.3);
        data.addPoint("1982", 4.4);
        data.addPoint("1983", 1.6);
        data.addPoint("1985", 2.4);
        data.addPoint("1986", 1.1);
        data.addPoint("1987", 1.2);
        data.addPoint("1988", 1.3);
        data.addPoint("1989", 0.8);
        data.addPoint("1990", 1);
        data.addPoint("1991", 1.8);
        data.addPoint("1992", 1);
        data.addPoint("1993", 1.7);
        data.addPoint("1994", 1.9);
        data.addPoint("1996", 3.4);
        data.addPoint("1998", 0.9);
        data.addPoint("2000", 1.1);
        
        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestBar07.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }

    } // TestChartFactory.testBar07


    //---------------------------------TestChartFactory.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.
     */
    //-------------------------------------------------------------------------
    public void testBar08()
    {
        ChartStyle style = new ChartStyle();

        style.setPaint(ChartStyle.COLOR_LABEL,      new Color(1.0f,  1.0f,  1.0f));
        style.setPaint(ChartStyle.COLOR_SHADOW,     new Color(0.16f, 0.35f, 0.64f));
        style.setPaint(ChartStyle.COLOR_BACKGROUND, new GradientPaint(210, 160, new Color(0.16f, 0.35f, 0.64f), 420, 320, new Color(0.1f, 0.3f, 0.5f)));
        style.setPaint(ChartStyle.COLOR_WALL,       new Color(0.84f, 0.84f, 1.0f));
        style.setPaint(ChartStyle.COLOR_EDGE,       new Color(0.0f,  0.0f,  0.0f));   
        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        
        style.setBarPaint(new Color(0.64f, 0.92f, 0.55f));
        style.setBorderEnabled(true);

        ChartData data = new ChartData();
        data.setTitle("Long Title String Long Title String Long Title String Long Title String Long Title String Long Title String");
        
        data.addPoint("- -", -1200);
        data.addPoint("\"Watch out for", 91253);
        data.addPoint("novel uses for COMGRAM", 90549);
        data.addPoint("(CONtractor GRAMmar", -12020);
        data.addPoint("defined by the", 3995156);
        data.addPoint("imperfect past,", 0.0);
        data.addPoint("the insufficient present", 10362.0);
        data.addPoint("and the absolutely", 6375);
        data.addPoint("perfect future.\"", 3688);
        data.addPoint("-- Grammar advice from", 2135370);
        data.addPoint("Amron Katz", 2464);
        data.addPoint("- -", 97253);
        data.addPoint("I took a course in", 96059);
        data.addPoint("speed reading and was", -11200);
        data.addPoint("able to read War and Peace", 8995156);
        data.addPoint("in twenty minutes.", 0);
        data.addPoint("It's about Russia.", 1062.1);
        data.addPoint("-- Woody Allen", 6135);
        data.addPoint("- -", 3818);
        data.addPoint("Quidquid latine dictum sit,", 3701);
        data.addPoint("altum viditur.", 2641);
        data.addPoint("(Whatever is said in Latin", 92532);
        data.addPoint("sounds profound)", 90593);
        data.addPoint("- -", -13200);
        data.addPoint("If you are", 7295254);
        data.addPoint("seeing these, I", 0);
        data.addPoint("must have finally", 1062.0);
        data.addPoint("gotten around to", 635);
        data.addPoint("fixing ChartStyle.MAX_BARS.", 388);
        data.addPoint("Bully", 370);
        data.addPoint("for", 264);
        data.addPoint("me", 18995156);
        data.addPoint("- -", 1277);
        data.addPoint("Children are unpredictable.  You never know what inconsistency they're going to catch you in next.  --Franklin P. Jones", 71234);

        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestBar08.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testBar08


    //---------------------------------TestChartFactory.testLine01-------------
    /**
     * Create a simple line chart with custom colors and 2 series. 
     */
    //-------------------------------------------------------------------------
    public void testLine01()
    {
        ChartStyle style = new ChartStyle();

        // Instead of calling ChartFactory.createLineChart, we can also define
        // the chart type in the custom ChartStyle object.  If we do, we can
        // call ChartFactory.createChart(data, style) and it will create the
        // correct chart type.
        style.setChartType(ChartStyle.CHART_TYPE_LINE);
        
        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        
        // Change the default color for the first 2 lines
        style.setBarPaint(0, new Color(0.4f, 0.0f, 0.3f));
        style.setBarPaint(1, new Color(0.9f, 0.2f, 0.1f));

        ChartData data = new ChartData();
        data.setTitle("Turn Results");

        // The key label is the label on the series that will be used in the
        // bar color association key for line charts or multi-row bar charts
        data.addKeyLabel("BoN/K");
        data.addKeyLabel("Masada");
        
        data.addLabel("0");
        data.addValue(20);
        data.addValue(20);
        data.addLabel("1");
        data.addValue(19);
        data.addValue(20);
        data.addLabel("2");
        data.addValue(18);
        data.addValue(20);
        data.addLabel("3");
        data.addValue(18);
        data.addValue(20);
        data.addLabel("BoN");
        data.addValue(18);
        data.addValue(20);
        data.addLabel("5");
        data.addValue(15);
        data.addValue(20);
        data.addLabel("6");
        data.addValue(12);
        data.addValue(16);
        data.addLabel("CoP");
        data.addValue(12);
        data.addValue(16);
        data.addLabel("ET");
        data.addValue(12);
        data.addValue(16);
        data.addLabel("K");
        data.addValue(12);
        data.addValue(9);
        data.addLabel("10");
        data.addValue(12);
        data.addValue(2);
        data.addLabel("11");
        data.addValue(7);
        data.addValue(0);

        Image image = factory.createChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestLine01.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testLine01


    //---------------------------------TestChartFactory.testLine02-------------
    /**
     * Create a line chart with 8 lines, a gradient background, and point 
     * marks enabled.
     */
    //-------------------------------------------------------------------------
    public void testLine02()
    {
        ChartStyle style = new ChartStyle();

        style.setChartType(ChartStyle.CHART_TYPE_LINE);
        
        style.setPaint(ChartStyle.COLOR_LABEL,      new Color(1.0f, 1.0f, 0.9f)); 
        style.setPaint(ChartStyle.COLOR_SHADOW,     new Color(0.0f, 0.2f, 0.0f));
        style.setPaint(ChartStyle.COLOR_BACKGROUND, new GradientPaint(210, 160, new Color(0.1f, 0.5f, 0.1f), 420, 320, new Color(0.0f, 0.45f, 0.0f)));
        style.setPaint(ChartStyle.COLOR_WALL,       new Color(0.4f, 0.8f, 0.4f));
        style.setPaint(ChartStyle.COLOR_EDGE,       new Color(0.0f, 0.1f, 0.0f));    
        style.setBorderEnabled(true);
        
        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);

        // Point marks are the small squares drawn on the line where
        // values are defined.  They are disabled by default.  You can
        // adjust the default size of point marks by calling
        // ChartStyle.setPointMarkSize(int)
        style.setShowPointMarks(true);
        
        style.setBarPaint(0, new Color(0.9451f, 0.1882f, 0.10f, 0.8f));
        style.setBarPaint(1, new Color(0.9843f, 0.5961f, 0.07f, 0.8f));
        style.setBarPaint(2, new Color(0.3f,    1.0f,    0.3f,  0.8f));
        style.setBarPaint(3, new Color(0.2f,    0.2f,    1.0f,  0.8f));
        style.setBarPaint(4, new Color(0.9451f, 0.1059f, 0.94f, 0.8f));
        style.setBarPaint(5, new Color(0.8f,    0.8f,    0.0f,  0.8f));
        style.setBarPaint(6, new Color(0.6f,    0.1f,    0.2f,  0.8f));
        style.setBarPaint(7, new Color(1.0f,    1.0f,    1.0f,  0.8f));
        
        ChartData data = new ChartData();
        data.setTitle("Peak Categories by Number of Calls");

        data.addKeyLabel("Custom - Ardvaark");
        data.addKeyLabel("Custom - Galleto");
        data.addKeyLabel("Custom - Integrated POD");
        data.addKeyLabel("Custom - MRP");
        data.addKeyLabel("Desktop - Malware");
        data.addKeyLabel("Servers - Document Management");
        data.addKeyLabel("Networks - Connectivity");
        data.addKeyLabel("Networks - Email");
        
        // Since there are several values for each label (x-value), we call
        // data.addLabel and data.addValue separately.
        data.addLabel("M 9/6");
        data.addValue(1);
        data.addValue(4);
        data.addValue(11);
        data.addValue(2);
        data.addValue(0);
        data.addValue(4);
        data.addValue(7);
        data.addValue(6);
        data.addLabel("T 9/7");
        data.addValue(0);
        data.addValue(6);
        data.addValue(3);
        data.addValue(1);
        data.addValue(0);
        data.addValue(4);
        data.addValue(8);
        data.addValue(5);
        data.addLabel("W 9/8");
        data.addValue(1);
        data.addValue(3);
        data.addValue(10);
        data.addValue(1);
        data.addValue(0);
        data.addValue(5);
        data.addValue(1);
        data.addValue(4);
        data.addLabel("T 9/9");
        data.addValue(0);
        data.addValue(1);
        data.addValue(3);
        data.addValue(2);
        data.addValue(0);
        data.addValue(4);
        data.addValue(0);
        data.addValue(9);
        data.addLabel("F 9/10");
        data.addValue(1);
        data.addValue(1);
        data.addValue(2);
        data.addValue(4);
        data.addValue(0);
        data.addValue(4);
        data.addValue(0);
        data.addValue(7);
        data.addLabel("S 9/11");
        data.addValue(0);
        data.addValue(1);
        data.addValue(0);
        data.addValue(3);
        data.addValue(0);
        data.addValue(0);
        data.addValue(0);
        data.addValue(0);
        data.addLabel("S 9/12");
        data.addValue(0);
        data.addValue(0);
        data.addValue(1);
        data.addValue(1);
        data.addValue(0);
        data.addValue(0);
        data.addValue(0);
        data.addValue(0);
        data.addLabel("M 9/13");
        data.addValue(12);
        data.addValue(3);
        data.addValue(0);
        data.addValue(19);
        data.addValue(1);
        data.addValue(4);
        data.addValue(0);
        data.addValue(0);
        data.addLabel("T 9/14");
        data.addValue(16);
        data.addValue(7);
        data.addValue(0);
        data.addValue(12);
        data.addValue(6);
        data.addValue(5);
        data.addValue(0);
        data.addValue(0);
        data.addLabel("W 9/15");
        data.addValue(4);
        data.addValue(8);
        data.addValue(0);
        data.addValue(12);
        data.addValue(0);
        data.addValue(1);
        data.addValue(0);
        data.addValue(0);
        data.addLabel("T 9/16");
        data.addValue(0);
        data.addValue(12);
        data.addValue(1);
        data.addValue(5);
        data.addValue(1);
        data.addValue(0);
        data.addValue(0);
        data.addValue(0);
        data.addLabel("F 9/17");
        data.addValue(0);
        data.addValue(3);
        data.addValue(4);
        data.addValue(1);
        data.addValue(0);
        data.addValue(0);
        data.addValue(0);
        data.addValue(0);
        data.addLabel("S 9/18");
        data.addValue(0);
        data.addValue(0);
        data.addValue(2);
        data.addValue(2);
        data.addValue(0);
        data.addValue(0);
        data.addValue(0);
        data.addValue(0);
        data.addLabel("S 9/19");
        data.addValue(0);
        data.addValue(0);
        data.addValue(1);
        data.addValue(5);
        data.addValue(0);
        data.addValue(0);
        data.addValue(0);
        data.addValue(0);

        Image image = factory.createChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestLine02.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testLine02


    //---------------------------------TestChartFactory.testLine03-------------
    /**
     * Create a line chart with 8 lines and custom-sized point marks.  
     */
    //-------------------------------------------------------------------------
    public void testLine03()
    {
        ChartStyle style = new ChartStyle();

        style.setChartType(ChartStyle.CHART_TYPE_LINE);

        style.setPaint(ChartStyle.COLOR_LABEL, new Color(0.0f,  0.1f,  0.7f));
        style.setPaint(ChartStyle.COLOR_WALL,  new Color(1.0f,  1.0f,  0.9f));
        style.setPaint(ChartStyle.COLOR_EDGE,  new Color(0.0f,  0.0f,  0.0f));

        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        style.setBorderEnabled(true);
        style.setShowPointMarks(true);
        
        // Change the size of the point marks from the default of 4
        style.setPointMarkSize(6);
        
        style.setBarPaint(0, new Color(0.9451f, 0.1882f, 0.1059f));
        style.setBarPaint(1, new Color(0.9843f, 0.5961f, 0.0667f));
        style.setBarPaint(2, new Color(0.1882f, 0.7451f, 0.1059f));
        style.setBarPaint(3, new Color(0.2f,    0.2f,    1.0f));
        style.setBarPaint(4, new Color(0.9451f, 0.1059f, 0.9451f));
        style.setBarPaint(5, new Color(0.8f,    0.8f,    0.0f));
        style.setBarPaint(6, new Color(0.6f,    0.1f,    0.2f));
        style.setBarPaint(7, new Color(0.0f,    0.4f,    0.1f));

        ChartData data = new ChartData();
        data.setTitle("Compromised Windows 2K+ Server Traffic");

        data.addKeyLabel("Microsoft-DS Sources");
        data.addKeyLabel("Microsoft-DS Targets");
        data.addKeyLabel("MS-SQL-S Sources");
        data.addKeyLabel("MS-SQL-S Targets");
        data.addKeyLabel("NetBIOS-NS Sources");
        data.addKeyLabel("NetBIOS-NS Targets");
        data.addKeyLabel("NetBIOS-SSN Sources");
        data.addKeyLabel("NetBIOS-SSN Targets");
        
        data.addLabel("8/28");
        data.addValue(369111 );
        data.addValue(151330);
        data.addValue(9923 );
        data.addValue(14843);
        data.addValue(15930 );
        data.addValue(148900);
        data.addValue(24629 );
        data.addValue(30750);
        data.addLabel("8/29");
        data.addValue(792567 );
        data.addValue(209094);
        data.addValue(21780);
        data.addValue(40687);
        data.addValue(21553 );
        data.addValue(215164);
        data.addValue(30995 );
        data.addValue(98002);
        data.addLabel("8/30");
        data.addValue(504577 );
        data.addValue(122203);
        data.addValue(18231);
        data.addValue(17233);
        data.addValue(21134 );
        data.addValue(167229);
        data.addValue(52692 );
        data.addValue(112815);
        data.addLabel("8/31");
        data.addValue(814728 );
        data.addValue(253267);
        data.addValue(22374);
        data.addValue(37019);
        data.addValue(36492 );
        data.addValue(230224);
        data.addValue(51340 );
        data.addValue(87729);
        data.addLabel("9/1");
        data.addValue(797670 );
        data.addValue(268238);
        data.addValue(24345);
        data.addValue(33067);
        data.addValue(36491 );
        data.addValue(238555);
        data.addValue(48476 );
        data.addValue(170650);
        data.addLabel("9/2");
        data.addValue(740808 );
        data.addValue(243930);
        data.addValue(24011);
        data.addValue(44851);
        data.addValue(35553 );
        data.addValue(232850);
        data.addValue(47752 );
        data.addValue(198998);
        data.addLabel("9/3");
        data.addValue(735762 );
        data.addValue(215556);
        data.addValue(22116);
        data.addValue(39651);
        data.addValue(33838 );
        data.addValue(232527);
        data.addValue(46141 );
        data.addValue(211998);
        data.addLabel("9/4");
        data.addValue(699300 );
        data.addValue(188257);
        data.addValue(19288);
        data.addValue(87331);
        data.addValue(23767 );
        data.addValue(178592);
        data.addValue(42219 );
        data.addValue(173769);
        data.addLabel("9/5");
        data.addValue(696474 );
        data.addValue(211101);
        data.addValue(19581);
        data.addValue(34480);
        data.addValue(20999 );
        data.addValue(157343);
        data.addValue(40266 );
        data.addValue(78668);
        data.addLabel("9/6");
        data.addValue(741702);
        data.addValue(180191);
        data.addValue(22087);
        data.addValue(95206);
        data.addValue(31363 );
        data.addValue(193665);
        data.addValue(46611 );
        data.addValue(157081);
        data.addLabel("9/7");
        data.addValue(447580);
        data.addValue(226929);
        data.addValue(16576);
        data.addValue(67022);
        data.addValue(19476 );
        data.addValue(218071);
        data.addValue(34471 );
        data.addValue(130507);

        Image image = factory.createChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestLine03.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testLine03


    //---------------------------------TestChartFactory.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)
     */
    //-------------------------------------------------------------------------
    public void testLine04()
    {
        ChartStyle style = new ChartStyle();

        style.setChartType(ChartStyle.CHART_TYPE_LINE);
        
        // Set the paint for the backdrop to change from green in the bottom left
        // to lighter green in the top right
        style.setPaint(ChartStyle.COLOR_WALL,   new GradientPaint(310, 205, new Color(0.7f, 1.0f, 0.7f), 240, 305, new Color(0.3f, 1.0f, 0.3f)));
        style.setPaint(ChartStyle.COLOR_LABEL,  new Color(0.0f, 0.0f, 0.6f));
        style.setPaint(ChartStyle.COLOR_SHADOW, new Color(0.9f, 0.9f, 1.0f));
        style.setPaint(ChartStyle.COLOR_EDGE,   new Color(0.0f, 0.1f, 0.0f));    

        TextLayer layer = new TextLayer("Source: Netcraft (www.netcraft.com)");
        layer.setFont(new Font("SansSerif", Font.PLAIN, 12));
        layer.setFontColor(new Color(0.0f, 0.0f, 0.6f));
        layer.setX(400);
        layer.setY(462);
        style.addLayer(layer);

        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        style.setShowPointMarks(true);
        style.setPointMarkSize(5);
        
        style.setBarPaint(0, Color.RED);
        style.setBarPaint(1, Color.BLUE);
        style.setBarPaint(2, Color.GRAY);
        style.setBarPaint(3, new Color(0.7f, 0.0f, 0.7f));
        style.setBarPaint(4, new Color(1.0f, 1.0f, 0.4f));

        ChartData data = new ChartData();
        data.setTitle("Totals for Active Servers Across All Domains");

        data.addKeyLabel("Apache");
        data.addKeyLabel("Microsoft");
        data.addKeyLabel("Sun");
        data.addKeyLabel("NCSA");
        data.addKeyLabel("Other");
        
        data.addLabel("Jun 00");
        data.addValue(383000);
        data.addValue(190000);
        data.addValue(21000);
        data.addValue(0);
        data.addValue(84000);
        data.addLabel("Sep 00");
        data.addValue(540000);
        data.addValue(198000);
        data.addValue(22500);
        data.addValue(0);
        data.addValue(88000);
        data.addLabel("Dec 00");
        data.addValue(630000);
        data.addValue(206000);
        data.addValue(19500);
        data.addValue(0);
        data.addValue(88500);
        data.addLabel("Mar 01");
        data.addValue(660000);
        data.addValue(270000);
        data.addValue(20000);
        data.addValue(0);
        data.addValue(87000);
        data.addLabel("Jun 01");
        data.addValue(730000);
        data.addValue(340000);
        data.addValue(19000);
        data.addValue(0);
        data.addValue(92000);
        data.addLabel("Sep 01");
        data.addValue(790000);
        data.addValue(360000);
        data.addValue(19500);
        data.addValue(0);
        data.addValue(90000);
        data.addLabel("Dec 01");
        data.addValue(890000);
        data.addValue(359000);
        data.addValue(21000);
        data.addValue(0);
        data.addValue(88000);
        data.addLabel("Mar 02");
        data.addValue(960000);
        data.addValue(380000);
        data.addValue(20500);
        data.addValue(0);
        data.addValue(91000);
        data.addLabel("Jun 02");
        data.addValue(1080000);
        data.addValue(430000);
        data.addValue(21000);
        data.addValue(0);
        data.addValue(92500);
        data.addLabel("Sep 02");
        data.addValue(1060000);
        data.addValue(420000);
        data.addValue(20000);
        data.addValue(0);
        data.addValue(93000);
        data.addLabel("Dec 02");
        data.addValue(1080000);
        data.addValue(415000);
        data.addValue(18500);
        data.addValue(0);
        data.addValue(93500);
        data.addLabel("Mar 03");
        data.addValue(1160000);
        data.addValue(440000);
        data.addValue(19000);
        data.addValue(0);
        data.addValue(93000);
        data.addLabel("Jun 03");
        data.addValue(1260000);
        data.addValue(445000);
        data.addValue(21000);
        data.addValue(0);
        data.addValue(92500);
        data.addLabel("Sep 03");
        data.addValue(1350000);
        data.addValue(476000);
        data.addValue(20500);
        data.addValue(0);
        data.addValue(93000);
        data.addLabel("Dec 03");
        data.addValue(1476000);
        data.addValue(486000);
        data.addValue(18000);
        data.addValue(0);
        data.addValue(94000);
        data.addLabel("Mar 04");
        data.addValue(1530000);
        data.addValue(522000);
        data.addValue(17500);
        data.addValue(0);
        data.addValue(94500);
        data.addLabel("Jun 04");
        data.addValue(1620000);
        data.addValue(540000);
        data.addValue(16500);
        data.addValue(0);
        data.addValue(94000);
        data.addLabel("Sep 04");
        data.addValue(1746000);
        data.addValue(558000);
        data.addValue(16500);
        data.addValue(0);
        data.addValue(94500);
        
        Image image = factory.createChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestLine04.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testLine04


    //---------------------------------TestChartFactory.testLine05-------------
    /**
     * Create a line chart of sine waves with custom fonts and colors.  Use a 
     * UNICODE character in data labels.
     */
    //-------------------------------------------------------------------------
    public void testLine05()
    {
        String pi = "" + '\u03C0';
        
        ChartStyle style = new ChartStyle();

        style.setChartType(ChartStyle.CHART_TYPE_LINE);
        
        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        
        style.setBarPaint(0, new Color(0.9451f, 0.1882f, 0.1059f));
        style.setBarPaint(1, new Color(0.9843f, 0.5961f, 0.0667f));
        style.setBarPaint(2, new Color(0.1882f, 0.7451f, 0.1059f));
        style.setBarPaint(3, new Color(0.2f,    0.2f,    1.0f));
        style.setBarPaint(4, new Color(0.9451f, 0.1059f, 0.9451f));
        style.setBarPaint(5, new Color(0.8f,    0.8f,    0.0f));
        style.setBarPaint(6, new Color(0.6f,    0.1f,    0.2f));
        style.setBarPaint(7, new Color(0.0f,    0.4f,    0.1f));

        // Since the title is very short, let's crank up the title font.  
        // If we pick a font so large that the title string is too long
        // to fit in the title area, the size will be decremented
        // until the string fits or the ChartStyle.DEFAULT_TITLE_FONT_MINIMUM_SIZE
        // is reached.  If the title is still too long, it will be truncated.
        style.setTitleFont(new Font("Dialog", Font.BOLD, 40));

        ChartData data = new ChartData();
        data.setTitle("y = F(x)");

        data.addKeyLabel("y = sin(x) + 2");
        data.addKeyLabel("y = cos(x) + 2");
        data.addKeyLabel("y = sin(x + " + pi + ") + 2");
        data.addKeyLabel("y = cos(x + " + pi + ") + 2");
        data.addKeyLabel("y = 2sin(x) + 2");
        data.addKeyLabel("y = 2cos(x) + 2");
        data.addKeyLabel("y = 2sin(x + " + pi + ") + 2");
        data.addKeyLabel("y = 2cos(x + " + pi + ") + 2");
        
        double x;
        for(int i=0; i<24; i++)
        {
            x = i * 0.27318 - Math.PI;
            // Only label the first and last x values
            if(i == 0)
            {
                data.addLabel("-" + pi);    
            }
            else if(i == 23)
            {
                data.addLabel("" + pi);
            }
            else
            {
                data.addLabel("");
            }
            
            data.addValue(Math.sin(x) + 2.0);
            data.addValue(Math.cos(x) + 2.0);
            data.addValue(Math.sin(x + Math.PI) + 2.0);
            data.addValue(Math.cos(x + Math.PI) + 2.0);
            data.addValue(2.0 * Math.sin(x) + 2.0);
            data.addValue(2.0 * Math.cos(x) + 2.0);
            data.addValue(2.0 * Math.sin(x + Math.PI) + 2.0);
            data.addValue(2.0 * Math.cos(x + Math.PI) + 2.0);
            
        }

        Image image = factory.createChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestLine05.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testLine05


    //---------------------------------TestChartFactory.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.
     */
    //-------------------------------------------------------------------------
    public void testLine06()
    {
    
        ChartStyle style = new ChartStyle();

        // Set the color for the backdrop to 70% opacity so that the ImageLayer
        // will be visible through it.
        style.setPaint(ChartStyle.COLOR_WALL, new Color(0.7f, 0.7f, 1.0f, 0.7f));

        try
        {
            // Place an ImageLayer behind the backdrop so that it will show through the
            // transparency
            ImageLayer layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage01.png").getPath()));
            layer.setX(164);
            layer.setY(138);
            layer.setZ(ChartMetrics.Z_INDEX_BACKDROP - 1);
            style.addLayer(layer);
        }
        catch(URISyntaxException e)
        {
            e.printStackTrace(System.err);
            fail("Unable to access the image URI: " + e);   
        }

        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        style.setShowPointMarks(true);
        
        style.setBarPaint(0, new Color(0.9451f, 0.1882f, 0.1059f));
        style.setBarPaint(1, new Color(0.9843f, 0.5961f, 0.0667f));
        style.setBarPaint(2, new Color(0.1882f, 0.7451f, 0.1059f));
        style.setBarPaint(3, new Color(0.2f,    0.2f,    1.0f));
        style.setBarPaint(4, new Color(0.9451f, 0.1059f, 0.9451f));
        style.setBarPaint(5, new Color(0.8f,    0.8f,    0.0f));
        style.setBarPaint(6, new Color(0.6f,    0.1f,    0.2f));
        style.setBarPaint(7, new Color(0.0f,    0.4f,    0.1f));

        // Since the title is very short, let's crank up the title font.  
        // If we pick a font so large that the title string is too long
        // to fit in the title area, the size will be decremented
        // until the string fits or the ChartStyle.DEFAULT_TITLE_FONT_MINIMUM_SIZE
        // is reached.  If the title is still too long, it will be truncated.
        style.setTitleFont(new Font("Serif", Font.PLAIN, 40));

        ChartData data = new ChartData();
        data.setTitle("y = F(x)");

        final char POW2 = '\u00B2';
        final char POW3 = '\u00B3';
        final char POW4 = '\u2074';
        
        data.addKeyLabel("y = x" + POW2);
        data.addKeyLabel("y = 2x" + POW2);
        data.addKeyLabel("y = x" + POW2 + " / 2");
        data.addKeyLabel("y = x" + POW4 + " / 100");
        data.addKeyLabel("y = -(x" + POW2 + ") + 200");
        data.addKeyLabel("y = -(2x" + POW2 + ") + 200");
        data.addKeyLabel("y = (x" + POW2 + " / -2) + 200");
        data.addKeyLabel("y = |x" + POW3 + "| / 5");
        
        for(int i=-10; i<=10; i++)
        {
            data.addLabel("" + i);
            data.addValue(i * i);
            data.addValue(2.0 * i * i);
            data.addValue(i * i / 2);
            data.addValue(i * i * i * i / 100.0);
            data.addValue(-1.0 * i * i + 200.0);
            data.addValue(-2.0 * i * i + 200.0);
            data.addValue(i * i / -2.0 + 200.0);
            data.addValue(Math.abs(i * i * i) / 5.0);
        }

        Image image = factory.createLineChart(data, style);

        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestLine06.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testLine06


    //---------------------------------TestChartFactory.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 
     */
    //-------------------------------------------------------------------------
    public void testMultiRow01()
    {
        ChartStyle style = new ChartStyle();

        style.setPaint(ChartStyle.COLOR_WALL, new Color(1.0f,  1.0f,  0.8f));

        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        
        style.setBarPaint(0, new Color(0.94f, 0.2f,  0.0f));
        style.setBarPaint(1, new Color(0.5f,  0.7f, 0.94f));

        ChartData data = new ChartData();
        data.setTitle("Contaminants in Great Blue Heron Eggs (mg/kg)");
        
        // Just like line charts, multi-row bar charts need key labels to
        // identify the different series
        data.addKeyLabel("PCB");
        data.addKeyLabel("DDE");

        data.addLabel("1977");
        data.addValue(7.3);
        data.addValue(2.4);
        data.addLabel("1982");
        data.addValue(4.4);
        data.addValue(1.4);
        data.addLabel("1983");
        data.addValue(1.6);
        data.addValue(0.6);
        data.addLabel("1985");
        data.addValue(2.4);
        data.addValue(1);
        data.addLabel("1986");
        data.addValue(1.1);
        data.addValue(0.3);
        data.addLabel("1987");
        data.addValue(1.2);
        data.addValue(0.5);
        data.addLabel("1988");
        data.addValue(1.3);
        data.addValue(0.4);
        data.addLabel("1989");
        data.addValue(0.8);
        data.addValue(0.5);
        data.addLabel("1990");
        data.addValue(1);
        data.addValue(0.4);
        data.addLabel("1991");
        data.addValue(1.8);
        data.addValue(0.8);
        data.addLabel("1992");
        data.addValue(1);
        data.addValue(0.3);
        data.addLabel("1993");
        data.addValue(1.7);
        data.addValue(1.6);
        data.addLabel("1994");
        data.addValue(1.9);
        data.addValue(1);
        data.addLabel("1996");
        data.addValue(3.4);
        data.addValue(0.9);
        data.addLabel("1998");
        data.addValue(0.9);
        data.addValue(0.3);
        data.addLabel("2000");
        data.addValue(1.1);
        data.addValue(0.4);

        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestMultiRow01.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testMultiRow01


    //---------------------------------TestChartFactory.testMultiRow02---------
    /**
     * Create a multirow bar chart with 3 rows of data, a transparent backdrop
     * and a PNG ImageLayer showing through the transparency.
     */
    //-------------------------------------------------------------------------
    public void testMultiRow02()
    {
        ChartStyle style = new ChartStyle();

        // Set the color for the backdrop to 70% opacity so that the ImageLayer
        // will be visible through it.
        style.setPaint(ChartStyle.COLOR_WALL, new Color(0.7f, 0.7f, 1.0f, 0.7f));
        
        try
        {
            // Add an ImageLayer for a title
            ImageLayer layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage12.png").getPath()));
            layer.setX(110);
            layer.setY(10);
            style.addLayer(layer);
            
            // Add another ImageLayer.  Set its z-index behind the backdrop so that it
            // will show through the transparency.
            layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage01.png").getPath()));
            layer.setX(164);
            layer.setY(136);
            layer.setZ(ChartMetrics.Z_INDEX_BACKDROP - 1);
            style.addLayer(layer);
        }
        catch(URISyntaxException e)
        {
            e.printStackTrace(System.err);
            fail("Unable to access the image URI: " + e);   
        }

        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        
        // Use custom colors for the 3 series
        style.setBarPaint(0, new Color(1.0f,  0.39f, 0.39f));
        style.setBarPaint(1, new Color(0.48f, 0.95f, 0.74f));
        style.setBarPaint(2, new Color(0.97f, 0.95f, 0.74f));

        ChartData data = new ChartData();
        data.addKeyLabel("Budget");
        data.addKeyLabel("Actual");
        data.addKeyLabel("Variance");

        data.addLabel("GM");
        data.addValue(91000);
        data.addValue(90000);
        data.addValue(1000);
        data.addLabel("CFO");
        data.addValue(12000);
        data.addValue(12000);
        data.addValue(0);
        data.addLabel("Legal");
        data.addValue(8000);
        data.addValue(7500);
        data.addValue(500);
        data.addLabel("R & D");
        data.addValue(11500);
        data.addValue(9500);
        data.addValue(2000);
        data.addLabel("MFG");
        data.addValue(53000);
        data.addValue(49000);
        data.addValue(4000);
        data.addLabel("QUAL");
        data.addValue(2700);
        data.addValue(2300);
        data.addValue(400);
        data.addLabel("INF");
        data.addValue(30000);
        data.addValue(26000);
        data.addValue(4000);
        data.addLabel("D & C");
        data.addValue(5100);
        data.addValue(3800);
        data.addValue(1300);
        data.addLabel("HR");
        data.addValue(17000);
        data.addValue(13500);
        data.addValue(3500);
        data.addLabel("PR");
        data.addValue(21000);
        data.addValue(18000);
        data.addValue(3000);
        data.addLabel("ENG");
        data.addValue(35000);
        data.addValue(32000);
        data.addValue(3000);

        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestMultiRow02.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testMultiRow02


    //---------------------------------TestChartFactory.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. 
     */
    //-------------------------------------------------------------------------
    public void testMultiRow03()
    {
        ChartStyle style = new ChartStyle();

        style.setPaint(ChartStyle.COLOR_LABEL, new Color(0.20f, 0.35f, 0.64f));

        try
        {
            // Put a title image at the top of the chart
            ImageLayer layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage02.png").getPath()));
            layer.setX(44);
            layer.setY(20);
            style.addLayer(layer);
        }
        catch(URISyntaxException e)
        {
            e.printStackTrace(System.err);
            fail("Unable to access the image URI: " + e);   
        }

        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        
        // Customize the Paints for the bars so that they get brighter and more 
        // transparent as they grow
        style.setBarPaint(0, new GradientPaint(320, 360, new Color(0.1f, 0.6f, 0.0f, 1.0f), 320, 115, new Color(0.4f, 0.9f, 0.3f, 0.9f)));
        style.setBarPaint(1, new GradientPaint(320, 360, new Color(0.8f, 0.1f, 0.0f, 1.0f), 320, 115, new Color(1.0f, 0.4f, 0.3f, 0.9f)));
        style.setBarPaint(2, new GradientPaint(320, 360, new Color(0.9f, 0.9f, 0.2f, 1.0f), 320, 115, new Color(1.0f, 1.0f, 0.4f, 0.9f)));

        // We wont' define a title for this ChartData object since we have
        // placed an ImageLayer at the top of the chart
        ChartData data = new ChartData();
        data.addKeyLabel("Anderson Appreciation");
        data.addKeyLabel("DCC Strategic Allocation Growth");
        data.addKeyLabel("Richards Small-Cap Value");

        data.addLabel("Dec 01");
        data.addValue(16317);
        data.addValue(5122);
        data.addValue(7321);
        data.addLabel("Mar 02");
        data.addValue(15817);
        data.addValue(5322);
        data.addValue(7121);
        data.addLabel("Jun 02");
        data.addValue(15200);
        data.addValue(6120);
        data.addValue(7220);
        data.addLabel("Sep 02");
        data.addValue(16500);
        data.addValue(6820);
        data.addValue(7520);
        data.addLabel("Dec 02");
        data.addValue(17700);
        data.addValue(7820);
        data.addValue(7120);
        data.addLabel("Mar 03");
        data.addValue(18200);
        data.addValue(9130);
        data.addValue(7500);
        data.addLabel("Jun 03");
        data.addValue(18400);
        data.addValue(12000);
        data.addValue(8300);
        data.addLabel("Sep 03");
        data.addValue(14100);
        data.addValue(13100);
        data.addValue(9300);
        data.addLabel("Dec 03");
        data.addValue(15000);
        data.addValue(13000);
        data.addValue(9700);
        data.addLabel("Mar 04");
        data.addValue(16000);
        data.addValue(15500);
        data.addValue(11700);
        data.addLabel("Jun 04");
        data.addValue(16200);
        data.addValue(17500);
        data.addValue(12500);
        data.addLabel("Sep 04");
        data.addValue(14300);
        data.addValue(19200);
        data.addValue(15100);
        data.addLabel("Dec 04");
        data.addValue(13100);
        data.addValue(19800);
        data.addValue(17500);
        data.addLabel("Mar 05");
        data.addValue(11100);
        data.addValue(20000);
        data.addValue(19500);
        data.addLabel("Jun 05");
        data.addValue(12100);
        data.addValue(19500);
        data.addValue(21500);
        data.addLabel("Sep 05");
        data.addValue(15100);
        data.addValue(22500);
        data.addValue(22000);

        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestMultiRow03.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testMultiRow03


    //---------------------------------TestChartFactory.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
     */
    //-------------------------------------------------------------------------
    public void testMultiRow04()
    {
        ChartStyle style = new ChartStyle();

        try
        {
            // Place an ImageLayer logo next to the middle series
            ImageLayer layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage11.png").getPath()));
            layer.setX(147);
            layer.setY(424);
            layer.setZ(ChartMetrics.Z_INDEX_BACKDROP + 1);
            style.addLayer(layer);

            // Put a transparent PNG along the y axis
            layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage14.png").getPath()));
            layer.setX(12);
            layer.setY(180);
            style.addLayer(layer);
        }
        catch(URISyntaxException e)
        {
            e.printStackTrace(System.err);
            fail("Unable to access the image URI: " + e);   
        }

        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        
        // Customize the paint for the back row so that it gets brighter
        // as the x-value grows
        style.setBarPaint(0, new GradientPaint(560, 110, new Color(0.3f, 1.0f, 0.3f), 75, 340, new Color(0.0f, 0.5f, 0.0f)));
        style.setBarPaint(1, new Color(0.9451f, 0.1882f, 0.1059f));
        style.setBarPaint(2, new Color(0.9f,    0.9f,    0.2f));

        ChartData data = new ChartData();
        data.setTitle("Browser Trends for w3schools.com Visitors");

        data.addKeyLabel("Internet Explorer");
        data.addKeyLabel("Mozilla / Mozilla Firefox");
        data.addKeyLabel("Opera");

        data.addLabel("1/04");
        data.addValue(84.1);
        data.addValue(8.2);
        data.addValue(2.1);
        data.addLabel("2/04");
        data.addValue(83);
        data.addValue(9);
        data.addValue(2.2);
        data.addLabel("3/04");
        data.addValue(82.8);
        data.addValue(9.6);
        data.addValue(2.1);
        data.addLabel("4/04");
        data.addValue(82.5);
        data.addValue(10.3);
        data.addValue(2.1);
        data.addLabel("5/04");
        data.addValue(81.8);
        data.addValue(11);
        data.addValue(2.2);
        data.addLabel("6/04");
        data.addValue(80.7);
        data.addValue(11.8);
        data.addValue(2.3);
        data.addLabel("7/04");
        data.addValue(78.7);
        data.addValue(13.8);
        data.addValue(2.3);
        data.addLabel("8/04");
        data.addValue(77.3);
        data.addValue(15.5);
        data.addValue(2.3);
        data.addLabel("9/04");
        data.addValue(75.8);
        data.addValue(16.9);
        data.addValue(2.3);
        data.addLabel("10/04");
        data.addValue(75.2);
        data.addValue(17.5);
        data.addValue(2.2);
        data.addLabel("11/04");
        data.addValue(73.5);
        data.addValue(19.3);
        data.addValue(2.2);
        data.addLabel("12/04");
        data.addValue(70.8);
        data.addValue(21.3);
        data.addValue(2.0);
        data.addLabel("1/05");
        data.addValue(69.7);
        data.addValue(23.3);
        data.addValue(1.9);
        data.addLabel("2/05");
        data.addValue(69);
        data.addValue(26.6);
        data.addValue(2.1);
        data.addLabel("3/05");
        data.addValue(67.7);
        data.addValue(26.7);
        data.addValue(1.8);
        data.addLabel("4/05");
        data.addValue(65.8);
        data.addValue(28.5);
        data.addValue(1.9);
        
        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestMultiRow04.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testMultiRow04


    //---------------------------------TestChartFactory.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/
     */
    //-------------------------------------------------------------------------
    public void testMultiRow05()
    {
        ChartStyle style = new ChartStyle();

        style.setKeyType(ChartStyle.KEY_TYPE_HORIZONTAL_BAR_LABELS);

        // Make the bars 20% transparent
        style.setBarPaint(0, new Color(0.2f, 0.9f, 0.1f, 0.8f));
        style.setBarPaint(1, new Color(0.9f, 0.2f, 0.1f, 0.8f));
        style.setBarPaint(2, new Color(1.0f, 1.0f, 0.2f, 0.8f));
        
        try
        {
            // Add an ImageLayer logo beneath the first set of bars
            ImageLayer layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage07.png").getPath()));
            layer.setX(80);
            layer.setY(404);
            layer.setZ(ChartMetrics.Z_INDEX_BACKDROP + 1);
            style.addLayer(layer);

            // Put a transparent PNG along the y axis
            layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage14.png").getPath()));
            layer.setX(12);
            layer.setY(180);
            style.addLayer(layer);
        }
        catch(URISyntaxException e)
        {
            e.printStackTrace(System.err);
            fail("Unable to access the image URI: " + e);   
        }

        ChartData data = new ChartData();
        data.setTitle("Favored Development Platform for Free/Libre and Open Source Developers");

        data.addKeyLabel("EU");
        data.addKeyLabel("Japan");
        data.addKeyLabel("Asia");

        data.addLabel("Linux");
        data.addValue(85.3);
        data.addValue(50.6);
        data.addValue(71.4);
        data.addLabel("BSD");
        data.addValue(6.6);
        data.addValue(8.8);
        data.addValue(8.3);
        data.addLabel("Mac OS");
        data.addValue(0.9);
        data.addValue(5.2);
        data.addValue(2.3);
        data.addLabel("Windows");
        data.addValue(2.2);
        data.addValue(31.2);
        data.addValue(15.0);
        data.addLabel("Other");
        data.addValue(5.0);
        data.addValue(4.3);
        data.addValue(3.0);
        
        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestMultiRow05.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testMultiRow05


    //---------------------------------TestChartFactory.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
     */
    //-------------------------------------------------------------------------
    public void testMultiRow06()
    {
        ChartStyle style = new ChartStyle();
        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        style.setTitleFont(new Font("SansSerif", Font.PLAIN, 34));
        style.setKeyFont(new Font("SansSerif", Font.PLAIN, 12));
        
        // Paint the first three bars with a gradient that gets lighter and
        // more transparent as the bars grow
        style.setBarPaint(0, new GradientPaint(320, 120, new Color(0.2f, 0.9f, 0.1f, 0.7f), 320, 480, new Color(0.0f, 0.5f, 0.0f, 0.9f)));
        style.setBarPaint(1, new GradientPaint(320, 120, new Color(0.4f, 0.4f, 1.0f, 0.7f), 320, 480, new Color(0.1f, 0.1f, 1.0f, 0.9f)));
        style.setBarPaint(2, new GradientPaint(320, 120, new Color(1.0f, 0.4f, 0.2f, 0.7f), 320, 480, new Color(0.9f, 0.2f, 0.1f, 0.9f)));
        
        ChartData data = new ChartData();

        // Some Arabic script Unicode constants
        final char Ae = '\u0623';
        final char A = '\u0627';
        final char B = '\u0628';
        final char e = '\u0629';
        final char T = '\u062A';
        final char J = '\u062C';
        final char H = '\u062D';
        final char D = '\u062F';
        final char R = '\u0631';
        final char S = '\u0633';
        final char s = '\u0634';
        final char X = '\u0635';
        final char V = '\u0636';
        final char U = '\u0637';
        final char a = '\u0639';
        final char G = '\u063A';
        final char F = '\u0641';
        final char Q = '\u0642';
        final char K = '\u0643';
        final char L = '\u0644';
        final char M = '\u0645';
        final char N = '\u0646';
        final char W = '\u0648';
        final char I = '\u064A';
        final char N1 = '\u0661';
        final char N2 = '\u0662';
        final char N4 = '\u0664';
        final char N6 = '\u0666';
        final char N8 = '\u0668';
        final char N9 = '\u0669';
        
        data.setTitle("" + A+L+G+A+M + ' ' + M+V+A+V + ' ' + L+L+Ae+F+R+A+D);

        data.addKeyLabel("" + B+U+N + ' ' + A+L+F+I+L);
        data.addKeyLabel("" + A+F+N+D+M + ' ' + N9+N8+N1);
        data.addKeyLabel("" + A+S+D + ' ' + F+I + ' ' + A+L+X+H+R+Ae);

        data.addLabel("" + R+B+a+e);
        data.addValue(430);
        data.addValue(320);
        data.addValue(20);
        data.addLabel("" + M + ' ' + N4+N6);
        data.addValue(340);
        data.addValue(40);
        data.addValue(0);
        data.addLabel("" + U+L + ' ' + N9);
        data.addValue(50);
        data.addValue(30);
        data.addValue(10);
        data.addLabel("" + A+L+R+B+A+T);
        data.addValue(10);
        data.addValue(180);
        data.addValue(70);
        data.addLabel("" + B+L+B+I+S);
        data.addValue(180);
        data.addValue(50);
        data.addValue(30);
        data.addLabel("" + K+W+N+T+S);
        data.addValue(80);
        data.addValue(120);
        data.addValue(20);
        data.addLabel("" + A+B+W + ' ' + M);
        data.addValue(140);
        data.addValue(60);
        data.addValue(40);
        data.addLabel("" + M + ' ' + N1+N4);
        data.addValue(80);
        data.addValue(80);
        data.addValue(90);
        data.addLabel("" + U+N+T+e);
        data.addValue(10);
        data.addValue(300);
        data.addValue(0);
        data.addLabel("" + s+B+A+K);
        data.addValue(10);
        data.addValue(10);
        data.addValue(0);
        data.addLabel("" + U+L + ' ' + B+A+D+R);
        data.addValue(30);
        data.addValue(110);
        data.addValue(40);
        data.addLabel("" + M + ' ' + N2+N1);
        data.addValue(0);
        data.addValue(20);
        data.addValue(0);
        data.addLabel("" + U+L + ' ' + N4);
        data.addValue(0);
        data.addValue(20);
        data.addValue(60);
        data.addLabel("" + M+Q+H+e);
        data.addValue(0);
        data.addValue(240);
        data.addValue(0);
        data.addLabel("" + M+D+I+N+e);
        data.addValue(130);
        data.addValue(130);
        data.addValue(0);
        data.addLabel("" + A+B+W + ' ' + F);
        data.addValue(70);
        data.addValue(20);
        data.addValue(0);
        
        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestMultiRow06.png");
        }
        catch(Exception x)
        {
            x.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testMultiRow06


    //---------------------------------TestChartFactory.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)
     */
    //-------------------------------------------------------------------------
    public void testMultiRow07()
    {
        ChartStyle style = new ChartStyle();

        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        
        style.setBarPaint(0, new GradientPaint(320, 360, new Color(0.1f, 0.6f, 0.0f, 1.0f), 320, 115, new Color(0.4f, 0.9f, 0.3f, 0.9f)));
        style.setBarPaint(1, new GradientPaint(320, 360, new Color(0.8f, 0.1f, 0.0f, 1.0f), 320, 115, new Color(1.0f, 0.4f, 0.3f, 0.9f)));
        style.setBarPaint(2, new GradientPaint(320, 360, new Color(0.4f, 0.4f, 1.0f, 1.0f), 320, 115, new Color(0.8f, 0.8f, 1.0f, 0.9f)));
        style.setBarPaint(3, new GradientPaint(320, 360, new Color(0.9f, 0.9f, 0.2f, 1.0f), 320, 115, new Color(1.0f, 1.0f, 0.4f, 0.9f)));

        TextLayer textLayer = new TextLayer("Source: Netcraft (www.netcraft.com)");
        textLayer.setFont(new Font("SansSerif", Font.PLAIN, 12));
        textLayer.setFontColor(Color.BLUE);
        textLayer.setX(415);
        textLayer.setY(455);
        textLayer.setZ(ChartMetrics.Z_INDEX_TITLE + 1);
        style.addLayer(textLayer);

        final String labels[] =
        {
            "Jun 00", "Sep 00", "Dec 00", "Mar 01", "Jun 01", "Sep 01", "Dec 01", "Mar 02", "Jun 02", 
            "Sep 02", "Dec 02", "Mar 03", "Jun 03", "Sep 03", "Dec 03", "Mar 04", "Jun 04", "Sep 04",
            "Dec 04"
        };
        final int values[] = 
        {
             383000, 190000, 21000, 84000,
             540000, 198000, 22500, 88000,
             630000, 206000, 19500, 88500,
             660000, 270000, 20000, 87000,
             730000, 340000, 19000, 92000,
             790000, 360000, 19500, 90000,
             890000, 359000, 21000, 88000,
             960000, 380000, 20500, 91000,
            1080000, 430000, 21000, 92500,
            1060000, 420000, 20000, 93000,
            1080000, 415000, 18500, 93500,
            1160000, 440000, 19000, 93000,
            1260000, 445000, 21000, 92500,
            1350000, 476000, 20500, 93000,
            1476000, 486000, 18000, 94000,
            1530000, 522000, 17500, 94500,
            1620000, 540000, 16500, 94000,
            1746000, 558000, 16500, 94500,
            1850000, 560000, 16200, 95000,
        };
        
        ChartData data = new ChartData();
        data.setTitle("Totals for Active Servers Across All Domains");
        data.addKeyLabel("Apache");
        data.addKeyLabel("Microsoft");
        data.addKeyLabel("Sun");
        data.addKeyLabel("Other");
        

        for(int i=0; i<labels.length; i++)
        {
            data.addLabel(labels[i]);
            data.addValue(values[i * 4]);
            data.addValue(values[i * 4 + 1]);
            data.addValue(values[i * 4 + 2]);
            data.addValue(values[i * 4 + 3]);
        }

        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestMultiRow07.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testMultiRow07


    //---------------------------------TestChartFactory.testMultiRow08---------
    /**
     * Create a multirow bar chart with 4 rows of data and a fancy transparent
     * PNG title ImageLayer. 
     */
    //-------------------------------------------------------------------------
    public void testMultiRow08()
    {
        ChartStyle style = new ChartStyle();

        style.setPaint(ChartStyle.COLOR_LABEL, new Color(0.20f, 0.35f, 0.64f));

        try
        {
            // Put a title image at the top of the chart
            ImageLayer layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage02.png").getPath()));
            layer.setX(44);
            layer.setY(20);
            style.addLayer(layer);
        }
        catch(URISyntaxException e)
        {
            e.printStackTrace(System.err);
            fail("Unable to access the image URI: " + e);   
        }

        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        
        // Customize the Paints for the bars so that they get brighter and more 
        // transparent as they grow
        style.setBarPaint(0, new GradientPaint(320, 360, new Color(0.1f, 0.6f, 0.0f, 1.0f), 320, 115, new Color(0.4f, 0.9f, 0.3f, 0.9f)));
        style.setBarPaint(1, new GradientPaint(320, 360, new Color(0.8f, 0.1f, 0.0f, 1.0f), 320, 115, new Color(1.0f, 0.4f, 0.3f, 0.9f)));
        style.setBarPaint(2, new GradientPaint(320, 360, new Color(0.9f, 0.9f, 0.2f, 1.0f), 320, 115, new Color(1.0f, 1.0f, 0.4f, 0.9f)));
        style.setBarPaint(3, new GradientPaint(320, 360, new Color(0.4f, 0.4f, 1.0f, 1.0f), 320, 115, new Color(0.8f, 0.8f, 1.0f, 0.9f)));

        final String labels[] =
        {
            "Dec 01", "Mar 02", "Jun 02", "Sep 02", "Dec 02", "Mar 03", "Jun 03", "Sep 03",
            "Dec 03", "Mar 04", "Jun 04", "Sep 04", "Dec 04", "Mar 05", "Jun 05", "Sep 05",
        };
        final int values[] = 
        {
            16317,  5122,  7321, 2150,
            15817,  5322,  7121, 2200,
            15200,  6120,  7220, 2260,
            16500,  6820,  7520, 2510,
            17700,  7820,  7120, 2480,
            18200,  9130,  7500, 2710,
            18400, 12000,  8300, 2900,
            14100, 13100,  9300, 3100,
            15000, 13000,  9700, 3450,
            16000, 15500, 11700, 3600,
            16200, 17500, 12500, 3650,
            14300, 19200, 15100, 3200,
            13100, 19800, 17500, 3000,
            11100, 20000, 19500, 2400,
            12100, 19500, 21500, 2100,
            15100, 22500, 22000, 1700,
        };
        
        // We wont' define a title for this ChartData object since we have
        // placed an ImageLayer at the top of the chart
        ChartData data = new ChartData();
        data.addKeyLabel("Anderson Appreciation");
        data.addKeyLabel("DCC Strategic Allocation Growth");
        data.addKeyLabel("Richards Small-Cap Value");
        data.addKeyLabel("Grozny Venture Fund");
        
        for(int i=0; i<labels.length; i++)
        {
            data.addLabel(labels[i]);
            data.addValue(values[i * 4]);
            data.addValue(values[i * 4 + 1]);
            data.addValue(values[i * 4 + 2]);
            data.addValue(values[i * 4 + 3]);
        }

        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestMultiRow08.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testMultiRow08


    //---------------------------------TestChartFactory.testMultiRow09---------
    /**
     * Create a multirow bar chart with 2 rows of data, transparent bars with
     * value labels, and a PNG watermark.
     */
    //-------------------------------------------------------------------------
    public void testMultiRow09()
    {
        ChartStyle style = new ChartStyle();
        style.setKeyType(ChartStyle.KEY_TYPE_DIAGONAL_BAR_LABELS);
        style.setPaint(ChartStyle.COLOR_EDGE, new Color(0.0f, 0.0f, 0.2f, 0.5f));
        style.setPaint(ChartStyle.COLOR_WALL, new GradientPaint(250, 135, new Color(0.7f, 0.7f, 1.0f, 0.6f), 500, 270, new Color(0.6f, 0.6f, 1.0f, 0.6f)));
        style.setValueLabelsEnabled(true); 
        style.setBarPaint(0, new Color(0.2f, 0.9f, 0.1f, 0.8f));
        style.setBarPaint(1, new Color(1.0f, 1.0f, 0.2f, 0.8f));

        try
        {
            ImageLayer titleLayer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage13.png").getPath()));
            titleLayer.setX(140);
            titleLayer.setY(16);
            titleLayer.setZ(ChartMetrics.Z_INDEX_BACKDROP - 1);
            style.addLayer(titleLayer);
            
            ImageLayer watermarkLayer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage01.png").getPath()));
            watermarkLayer.setX(155);
            watermarkLayer.setY(178);
            watermarkLayer.setZ(ChartMetrics.Z_INDEX_BACKDROP - 1);
            style.addLayer(watermarkLayer);
        }
        catch(URISyntaxException e)
        {
            e.printStackTrace(System.err);
            fail("Unable to access the image URI: " + e);   
        }

        ChartData data = new ChartData();
        data.addKeyLabel("Assets");
        data.addKeyLabel("Shareable Content Objects");
        
        data.addLabel("2/05");
        data.addValue(62);
        data.addValue(72);
        data.addLabel("3/05");
        data.addValue(8);
        data.addValue(12);
        data.addLabel("4/05");
        data.addValue(41);
        data.addValue(12);
        data.addLabel("5/05");
        data.addValue(63);
        data.addValue(8);
        data.addLabel("6/05");
        data.addValue(82);
        data.addValue(7);
        data.addLabel("7/05");
        data.addValue(71);
        data.addValue(17);
        data.addLabel("8/05");
        data.addValue(42);
        data.addValue(9);
        data.addLabel("9/05");
        data.addValue(24);
        data.addValue(33);
        data.addLabel("10/05");
        data.addValue(41);
        data.addValue(21);
        data.addLabel("11/05");
        data.addValue(21);
        data.addValue(7);
        data.addLabel("12/05");
        data.addValue(26);
        data.addValue(17);
        data.addLabel("1/06");
        data.addValue(32);
        data.addValue(24);

        ChartFactory factory = ChartFactory.getInstance();
        Image image = factory.createBarChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestMultiRow09.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }
    } // TestChartFactory.testMultiRow09


    //---------------------------------TestChartFactory.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
     */
    //-------------------------------------------------------------------------
    public void testPie01()
    {
        ChartStyle style = new ChartStyle();
        
        try
        {
            ImageLayer layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage09.png").getPath()));
            layer.setX(230);
            layer.setY(130);
            layer.setZ(ChartMetrics.Z_INDEX_BACKDROP - 1);
            style.addLayer(layer);
            
            layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage04.png").getPath()));
            layer.setX(20);
            layer.setY(10);
            layer.setZ(ChartMetrics.Z_INDEX_TITLE + 1);
            style.addLayer(layer);
        }
        catch(URISyntaxException e)
        {
            e.printStackTrace(System.err);
            fail("Unable to access the image URI: " + e);   
        }

        TextLayer textLayer = new TextLayer("Source: Netcraft (www.netcraft.com)");
        textLayer.setFont(new Font("SansSerif", Font.PLAIN, 12));
        textLayer.setFontColor(new Color(0.0f, 0.0f, 1.0f));
        textLayer.setX(370);
        textLayer.setY(430);
        textLayer.setZ(ChartMetrics.Z_INDEX_TITLE + 1);
        style.addLayer(textLayer);

        ChartData data = new ChartData();
        data.addPoint("Apache",    68.43);
        data.addPoint("Microsoft", 20.86);
        data.addPoint("Sun",       3.14);
        data.addPoint("Zeus",      1.19);

        // Make the pie slices 60% opaque
        for(int i=0; i<data.getTotalValues(); i++)
        {
            style.setBarPaint(i, Palette.setAlpha(style.getBarPaint(i), 0.6f));
        }

        Image image = factory.createPieChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestPie01.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }

    } // TestChartFactory.testPie01


    //---------------------------------TestChartFactory.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.
     */
    //-------------------------------------------------------------------------
    public void testPie02()
    {
        ChartStyle style = new ChartStyle();

        style.setChartType(ChartStyle.CHART_TYPE_PIE);

        TextLayer layer = new TextLayer("Source: TechRepublic survey");
        layer.setFont(new Font("SansSerif", Font.PLAIN, 12));
        layer.setFontColor(new Color(0.5f, 0.0f, 0.0f));
        layer.setX(425);
        layer.setY(460);
        layer.setZ(ChartMetrics.Z_INDEX_SLICES + 1);
        style.addLayer(layer);

        style.setPaint(ChartStyle.COLOR_LABEL,  new Color(0.5f,  0.0f,  0.0f));
        style.setPaint(ChartStyle.COLOR_SHADOW, new Color(0.95f, 0.85f, 0.85f));
        style.setPaint(ChartStyle.COLOR_WALL,   new Color(1.0f,  1.0f,  0.8f));
        style.setPaint(ChartStyle.COLOR_EDGE,   new Color(0.2f,  0.0f,  0.0f)); 

        ChartData data = new ChartData();
        data.setTitle("Most Influential Factors in Moving to Linux");
        
        data.addPoint("Cost", 40.0);
        data.addPoint("Ease of Implementation", 10.0);
        data.addPoint("Ease of Training", 3.6);
        data.addPoint("Reliability", 39.2);
        data.addPoint("Scalability", 7.2);

        // Loop through all of the pie slices and set their paint to gradient from 
        // bright in the front of the pie to darker in the back
        for(int i=0; i<ChartStyle.MAX_BARS && i<data.getTotalValues(); i++)
        {
            style.setBarPaint(i, new GradientPaint(320, 315, Palette.brighten(style.getBarPaint(i), 3), 230, 75, (Color)style.getBarPaint(i)));
        }
        
        Image image = factory.createChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestPie02.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }

    } // TestChartFactory.testPie02


    //---------------------------------TestChartFactory.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.
     */
    //-------------------------------------------------------------------------
    public void testPie03()
    {
        ChartStyle style = new ChartStyle();
        style.setChartType(ChartStyle.CHART_TYPE_PIE);
        style.setBorderEnabled(true);

        ChartData data = new ChartData();
        data.setTitle("Scottish Fishing Vessels by District, 1997");
        
        data.addPoint("Aberdeen", 46);
        data.addPoint("Arbroath", 72);
        data.addPoint("Ayr", 181);
        data.addPoint("Buckle", 151);
        data.addPoint("Campbelltown", 190);
        data.addPoint("Eyemouth", 125);
        data.addPoint("Fraserburgh", 271);
        data.addPoint("Kinlochbervie", 28);
        data.addPoint("Lochinver", 32);
        data.addPoint("Mallaig", 248);
        data.addPoint("Oban", 175);
        data.addPoint("Orkney", 206);
        data.addPoint("Peterhead", 159);
        data.addPoint("Pittenweem", 103);
        data.addPoint("Shetland", 221);
        data.addPoint("Stornoway", 353);
        data.addPoint("Ullapool", 60);
        data.addPoint("Wick", 142);

        Image image = factory.createChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestPie03.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }

    } // TestChartFactory.testPie03


    //---------------------------------TestChartFactory.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.
     */
    //-------------------------------------------------------------------------
    public void testPie04()
    {
        ChartStyle style = new ChartStyle();

        style.setPaint(ChartStyle.COLOR_LABEL,  new Color(0.5f,  0.0f,  0.0f));
        style.setPaint(ChartStyle.COLOR_SHADOW, new Color(0.95f, 0.85f, 0.85f));
        style.setPaint(ChartStyle.COLOR_EDGE,   new Color(0.5f,  0.0f,  0.0f));
        
        // The label font will be initially set to 40pt TimesRoman.
        // Once all of the labels are added, the label font will be
        // decremented since the longest label at that size is too wide
        // to display in the given area.  However, once the label 
        // font is decremented down to the lower limit of 
        // ChartStyle.DEFAULT_KEY_FONT_MINIMUM_SIZE, at least one of the
        // labels will still be too wide.  Any label that is still too
        // long will be truncated until it fits.
        style.setLabelFont(new Font("TimesRoman", Font.PLAIN, 40));
        
        // The title font will also be set to 40pt TimesRoman.  Since
        // it is short enough to fit within the title area at this size,
        // the font will not be adjusted.
        style.setTitleFont(new Font("TimesRoman", Font.BOLD, 40));

        ChartData data = new ChartData();
        data.setTitle("Top SourceForge.net Downloads");
        
        data.addPoint("eMule",             84619648);
        data.addPoint("Azureus - BitTorrent Client", 36135722);
        data.addPoint("BitTorrent",        31994567);
        data.addPoint("CDex",              22181638);
        data.addPoint("DC++",              20865622);
        data.addPoint("VirtualDub",        17337162);
        data.addPoint("ZSNES",              8339503);
        data.addPoint("eMule Plus",         6031716);
        data.addPoint("phpMyAdmin",         5953722);
        data.addPoint("Dev-C++",            5617685);
        data.addPoint("Gaim",               5425713);
        data.addPoint("phpBB",              5318085);
        data.addPoint("JBoss.org",          5118948);
        data.addPoint("TightVNC",           4882808);
        data.addPoint("ffdshow",            4585258);
        data.addPoint("guliverkli",         4427596);
        data.addPoint("Shareaza",           4231303);
        data.addPoint("AFPL Ghostscript",   4064166);
        data.addPoint("ABC [Yet Another Bittorrent Client", 3987273);
        data.addPoint("Webmin",             3970738);
        data.addPoint("Miranda",            3836720);
        data.addPoint("FileZilla",          3686691);
        data.addPoint("The CvsGui project", 3545563);
        data.addPoint("7-Zip",              3523815);
        data.addPoint("AC3Filter",          3251402);
        data.addPoint("GnuWin32",           3080029);
        data.addPoint("AMSN",               2974954);
        data.addPoint("WinSCP",             2832310);
        data.addPoint("FlasKMPEG",          2775972);
        data.addPoint("VisualBoyAdvance",   2700694);

        Image image = factory.createPieChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestPie04.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }

    } // TestChartFactory.testPie04


    //---------------------------------TestChartFactory.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
     */
    //-------------------------------------------------------------------------
    public void testPie05()
    {
        ChartStyle style = new ChartStyle();
        
        // Set custom paints on the pie slices, including a gradient on the 
        // largest slice that gets brighter in the bottom right 
        style.setBarPaint(0, new GradientPaint(540, 240, new Color(1.0f, 1.0f, 0.5f), 240, 70, new Color(1.0f, 1.0f, 0.2f)));
        style.setBarPaint(1, new Color(1.0f, 0.0f, 0.0f));
        style.setBarPaint(2, new Color(0.1f, 0.0f, 1.0f));
        style.setBarPaint(3, new Color(0.5f, 1.0f, 0.0f));
        style.setBarPaint(4, new Color(0.8f, 0.8f, 0.3f));
        style.setBarPaint(6, new Color(0.5f, 0.5f, 0.5f));

        try
        {
            ImageLayer layer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage06.png").getPath()));
            layer.setX(355);
            layer.setY(110);
            layer.setZ(ChartMetrics.Z_INDEX_SLICES + 1);
            style.addLayer(layer);
        }
        catch(URISyntaxException e)
        {
            e.printStackTrace(System.err);
            fail("Unable to access the image URI: " + e);   
        }

        ChartData data = new ChartData();
        data.setTitle("Favored OS / Distribution of Free/Libre and Open Source Developers");
        
        data.addPoint("Debian",   48.1);
        data.addPoint("Red Hat",  13.8);
        data.addPoint("Mandrake",  9.8);
        data.addPoint("SuSE",      9.2);
        data.addPoint("FreeBSD",   4.9);
        data.addPoint("Slackware", 4.4);
        data.addPoint("Windows",   2.2);
        data.addPoint("OpenBSD",   1.3);
        data.addPoint("MacOS",     1.0);
        data.addPoint("BeOs",      0.9);
        data.addPoint("Solaris",   0.5);
        data.addPoint("NetBSD",    0.4);
        data.addPoint("OS/2",      0.2);
        data.addPoint("DOS",       0.1);
        data.addPoint("Other",     3.2);

        Image image = factory.createPieChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestPie05.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }

    } // TestChartFactory.testPie05


    //---------------------------------TestChartFactory.testPie06--------------
    /**
     * Create a pie chart with 30 sorted categories.  Source data is from
     * http://distrowatch.com/stats.php?section=popularity
     */
    //-------------------------------------------------------------------------
    public void testPie06()
    {
        ChartStyle style = new ChartStyle();

        style.setPaint(ChartStyle.COLOR_LABEL,      new Color(1.0f, 1.0f, 0.2f));
        style.setPaint(ChartStyle.COLOR_SHADOW,     new Color(0.1f, 0.1f, 0.1f));
        style.setPaint(ChartStyle.COLOR_BACKGROUND, new Color(0.0f, 0.0f, 0.0f));
        style.setPaint(ChartStyle.COLOR_WALL,       new Color(0.4f, 0.8f, 0.4f));
        style.setPaint(ChartStyle.COLOR_EDGE,       new Color(0.2f, 0.2f, 0.2f));    

        ChartData data = new ChartData();
        data.setTitle("2004 distrowatch.com Average Page Hits per Day");
        
        data.addPoint("Mandrake",  1457);
        data.addPoint("Fedora",    1202);
        data.addPoint("KNOPPIX",    910);
        data.addPoint("SuSE",       858);
        data.addPoint("Debian",     832);
        data.addPoint("MEPIS",      694);
        data.addPoint("Gentoo",     832);
        data.addPoint("Slackware",  669);
        data.addPoint("PCLinuxOS",  451);
        data.addPoint("Damn Small", 416);
        data.addPoint("Xandros",    367);
        data.addPoint("Red Hat",    343);
        data.addPoint("Ubuntu",     300);
        data.addPoint("Vine",       290);
        data.addPoint("FreeBSD",    290);
        data.addPoint("SLAX",       263);
        data.addPoint("Yoper",      242);
        data.addPoint("Linspire",   226);
        data.addPoint("Vector",     192);
        data.addPoint("Gnoppix",    192);
        data.addPoint("KANOTIX",    186);
        data.addPoint("Arch",       180);
        data.addPoint("Feather",    176);
        data.addPoint("Lycoris",    175);
        data.addPoint("Aurox",      162);
        data.addPoint("Buffalo",    158);
        data.addPoint("Turbolinux", 154);
        data.addPoint("Libranet",   147);
        data.addPoint("Mandows",    136);
        data.addPoint("Onebase",    131);

        Image image = factory.createPieChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestPie06.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }

    } // TestChartFactory.testPie06


    //---------------------------------TestChartFactory.testPie07--------------
    /**
     * Create a pie chart with transparent slices and a watermark behind
     * the pie.
     */
    //-------------------------------------------------------------------------
    public void testPie07()
    {
        ChartStyle style = new ChartStyle();
        style.setChartType(ChartStyle.CHART_TYPE_PIE);

        try
        {
            ImageLayer titleLayer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage02.png").getPath()));
            titleLayer.setX(40);
            titleLayer.setY(16);
            titleLayer.setZ(ChartMetrics.Z_INDEX_BACKDROP - 1);
            style.addLayer(titleLayer);

            ImageLayer watermarkLayer = new ImageLayer(new URI("file://" + TestChartMetrics.class.getResource("/../test/TestImage01.png").getPath()));
            watermarkLayer.setX(155);
            watermarkLayer.setY(178);
            watermarkLayer.setZ(ChartMetrics.Z_INDEX_BACKDROP - 1);
            style.addLayer(watermarkLayer);
        }
        catch(URISyntaxException e)
        {
            e.printStackTrace(System.err);
            fail("Unable to access the image URI: " + e);   
        }

        TextLayer textLayer = new TextLayer("Updated " + new SimpleDateFormat("dd MMM yyyy").format(new Date()));
        textLayer.setFont(new Font("SansSerif", Font.PLAIN, 10));
        textLayer.setFontColor(new Color(0.0f, 0.0f, 0.7f));
        textLayer.setX(510);
        textLayer.setY(460);
        textLayer.setZ(ChartMetrics.Z_INDEX_SLICES + 1);
        style.addLayer(textLayer);

        ChartData data = new ChartData();
        data.addPoint("DCC Strategic Allocation Growth", 10000);
        data.addPoint("Anderson Appreciation", 6000);
        data.addPoint("Richards Small-Cap Value", 3700);
        data.addPoint("Isokaze Pacific Rim Growth Fund", 2500);
        data.addPoint("Genju Venture Fund", 2400);

        style.setBarPaint(0, new GradientPaint(320, 315, new Color(0.4f, 1.0f, 0.4f, 0.6f), 230, 75, new Color(0.0f, 1.0f, 0.0f, 0.6f)));
        style.setBarPaint(1, new GradientPaint(320, 315, new Color(0.4f, 0.4f, 1.0f, 0.6f), 230, 75, new Color(0.0f, 0.0f, 1.0f, 0.6f)));
        style.setBarPaint(2, new GradientPaint(320, 315, new Color(1.0f, 0.4f, 0.4f, 0.6f), 230, 75, new Color(1.0f, 0.0f, 0.0f, 0.6f)));
        style.setBarPaint(3, new GradientPaint(320, 315, new Color(1.0f, 1.0f, 0.4f, 0.6f), 230, 75, new Color(1.0f, 1.0f, 0.0f, 0.6f)));
        style.setBarPaint(4, new GradientPaint(320, 315, new Color(0.9f, 0.4f, 1.0f, 0.6f), 230, 75, new Color(0.6f, 0.0f, 1.0f, 0.6f)));
        
        ChartFactory factory = ChartFactory.getInstance();
        Image image = factory.createChart(data, style);
        
        try
        {
            factory.writeImage(image, "test/results/TestChartFactory_TestPie07.png");
        }
        catch(Exception e)
        {
            e.printStackTrace(System.err);
            fail("Unable to write image");
        }

    } // ChartGenerator.testPie07


    //---------------------------------TestChartFactory.main-------------------
    /**
     * Added so that the test can be run directly
     *
     * @param args Command-line arguments (none expected)
     */
    //-------------------------------------------------------------------------
    public static void main(String[] args)
    {
        junit.textui.TestRunner.run(new TestSuite(TestChartFactory.class));
        System.exit(0);
    } // TestChartFactory.main


} // TestChartFactory class

//-----------------------------------------------------------------------------
// $Log: TestChartFactory.java,v $
// Revision 1.2  2005/02/03 00:09:57  davidcorpstein
// Refactored method names to testBar, testLine, testMultiRow, and testPie.
// Changed all of the output file names to reflect the new method names.
// Removed "watermark" tests and added numerous ImageLayers and TextLayers.
// Added transparency to different chart elements.
//
// Revision 1.16  2005/01/26 14:52:30  david
// Added testPie01 - testPie06 to exercise the new pie charts.  Also
// added testMultiRow05 and testMultiRow06.  Updated all existing methods
// to reflect the new default ChartStyle.isBorderEnabled of false.
//
// Revision 1.15  2005/01/24 13:59:00  david
// Added numerous in-line comments to make the source code a better 
// example for how to create different kinds of charts.
//
// Revision 1.14  2005/01/22 06:45:52  david
// Fixed calls to new URI("file:/" + ...) to read new URI("file://" + ...)
// and added testMultiRow04.
//
// Revision 1.13  2005/01/21 18:41:52  david
// Changed the transparent PNG watermark and added description comments to 
// test methods.
//
// Revision 1.12  2005/01/20 16:24:10  david
// Adjusted calls to follow the new standard ChartData, ChartStyle, then
// ChartMetrics order
//
// Revision 1.11  2005/01/19 10:04:50  david
// Adjusted testBar04 to move the watermark according to the new
// bar spacing.  Added a watermark to testMultiRow02 and testLine06.
// Moved the testBar05 watermark to accomodate the new TestImage01.png
// image.
//
// Revision 1.10  2004/10/27 20:31:50  dcorpste
// Updated labels in testMultiRow02.  Added testMultiRow03.
//
// Revision 1.9  2004/09/08 18:08:35  dcorpste
// Added testLine05 and testLine06.
//
// Revision 1.8  2004/09/07 21:03:54  dcorpste
// Added testLine02, testLine03, and testLine04.
//
// Revision 1.7  2004/09/03 13:14:34  dcorpste
// Added testLine01 to test new line chart methods in ChartFactory.
//
// Revision 1.6  2004/04/23 20:50:05  dcorpste
// Added three unit tests: testBar08, testMultiRow01, testMultiRow02
//
// Revision 1.5  2004/04/22 15:29:23  dcorpste
// Added testBar07.
//
// Revision 1.4  2004/04/21 20:49:27  dcorpste
// Moved testBar01 to testBar05 and added testBar01 and testBar06.
//
// Revision 1.3  2004/04/20 13:22:29  dcorpste
// Added testBar04 and changed testBar01.
//
// Revision 1.2  2004/04/15 20:55:30  dcorpste
// Added two new unit test: testBar02 and testBar03.
//
// Revision 1.1  2004/04/14 21:06:45  dcorpste
// Initial import into CVS.
//
//-----------------------------------------------------------------------------




SourceForge.net Logo