krysalis-jcharts/src/java/org/krysalis/jcharts/test StackedBar3DTestDriver.java,NONE,1.1

Chris McKay <[email protected]> Mon, 14 Jun 2004 05:00:32 +0000
Newsgroups gmane.comp.krysalis.jcharts.cvs
Message-ID <[email protected]>
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4140/src/java/org/krysalis/jcharts/test

Added Files:
	StackedBar3DTestDriver.java 
Log Message:
3D stacked bar chart functionality added

--- NEW FILE: StackedBar3DTestDriver.java ---
/***********************************************************************************************
 * Copyright 2002 (C) Nathaniel G. Auvil. All Rights Reserved.
 *
 * Redistribution and use of this software and associated documentation ("Software"), with or
 * without modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain copyright statements and notices.
 * 	Redistributions must also contain a copy of this document.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
 * 	conditions and the following disclaimer in the documentation and/or other materials
 * 	provided with the distribution.
 *
 * 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to endorse or promote
 * 	products derived from this Software without prior written permission of Nathaniel G.
 * 	Auvil.  For written permission, please contact [email protected]
 *
 * 4. Products derived from this Software may not be called "jCharts" nor may "jCharts" appear
 * 	in their names without prior written permission of Nathaniel G. Auvil. jCharts is a
 * 	registered trademark of Nathaniel G. Auvil.
 *
 * 5. Due credit should be given to the jCharts Project (http://jcharts.sourceforge.net/).
 *
 * THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS IS'' AND ANY
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
 * jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
 ************************************************************************************************/

package org.krysalis.jcharts.test;


import java.awt.*;

import org.krysalis.jcharts.axisChart.AxisChart;
import org.krysalis.jcharts.axisChart.customRenderers.axisValue.renderers.ValueLabelPosition;
import org.krysalis.jcharts.axisChart.customRenderers.axisValue.renderers.ValueLabelRenderer;
import org.krysalis.jcharts.chartData.*;
import org.krysalis.jcharts.chartData.interfaces.IAxisDataSeries;
import org.krysalis.jcharts.encoders.*;
import org.krysalis.jcharts.imageMap.ImageMap;
import org.krysalis.jcharts.properties.*;
import org.krysalis.jcharts.properties.util.*;
import org.krysalis.jcharts.types.ChartType;

/******************************************************************************************
 * This file provides examples of how to create all the different chart types provided by
 *  this package.
 *
 * @author Steve Skillcorn
 * @version $Id: StackedBar3DTestDriver.java,v 1.1 2004/06/14 05:00:29 kiwicmc Exp $
 *******************************************************************************************/

public class StackedBar3DTestDriver {
    boolean supportsImageMap() {
        return true;
    }

    public static void main(String[] args) throws PropertyException, ChartDataException {
        ChartProperties               chartProperties = new ChartProperties();
        StackedBarChart3DProperties   stackedBarChart3DProperties = new StackedBarChart3DProperties();;
		IAxisDataSeries               dataSeries;
		AxisChartDataSet              axisChartDataSet;
        AxisProperties                axisProperties = new AxisProperties(false);
        ChartFont                     axisScaleFont;
        ChartFont                     axisTitleFont;

		axisScaleFont = new ChartFont(new Font("Arial", Font.BOLD, 10), Color.black);
		axisTitleFont = new ChartFont(new Font("Arial", Font.BOLD, 10), Color.black);
    
        axisProperties.getYAxisProperties().setShowEndBorder(false);
        axisProperties.getXAxisProperties().setShowEndBorder(false);
        axisProperties.getXAxisProperties().setLabelRotationAngle(30);

        String[] axisLabels = {"Aug 13", "Aug 14", "Aug 15", "Aug 16", "Aug 17", "Aug 18", "Aug 19", "Aug 20"};
        dataSeries = new DataSeries(axisLabels, " ", "Total Backup Events", null);

        //Set the width of the bars and don't show the outline
        stackedBarChart3DProperties.setWidthPercentage( 0.70f );
        stackedBarChart3DProperties.setShowOutlinesFlag(false);

        //Bars
        double[][] barData = { 
          { 11, 120, 163, 150, 107, 148, 152, 169}, 
          {  0,   6,   4,   6,   9,   1,   0,   7},
          {  0,  12,   0,   2,   1,  22,   5,   2}};

        Paint[] paints = {new Color(0x00, 0x56,0x99), new Color(0xD1,0xD6,0x18), new Color(0xB3,0x05,0x05) };
        String[] legendLabels = {"Successful", "Warnings", "Failures"};
        axisChartDataSet = new AxisChartDataSet(barData, legendLabels, paints, ChartType.BAR_STACKED_3D, stackedBarChart3DProperties);

        dataSeries.addIAxisPlotDataSet(axisChartDataSet);

        axisProperties.getXAxisProperties().setScaleChartFont(axisScaleFont);
        axisProperties.getYAxisProperties().setScaleChartFont(axisTitleFont);
        axisProperties.getXAxisProperties().setTitleChartFont(axisScaleFont);
        axisProperties.getYAxisProperties().setTitleChartFont(axisTitleFont);
        axisProperties.getXAxisProperties().setAxisTitleChartFont(axisScaleFont);
        axisProperties.getYAxisProperties().setAxisTitleChartFont(axisTitleFont);

        LegendProperties legendProperties = new LegendProperties();
        legendProperties.setBorderStroke(null);
        legendProperties.setChartFont(axisScaleFont);

        AxisChart axisChart = new AxisChart(dataSeries, chartProperties, axisProperties, legendProperties, 500, 400 );

        axisChart.renderWithImageMap();
        ChartTestDriver.exportImage( axisChart, "c:/temp/jcharts/Stacked3DChart.png" );
	}

}



-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
From Windows to Linux, servers to mobile, InstallShield X is the
one installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504