net.sf.statcvs.output.xml.chart.AbstractBarChart.java Source code

Java tutorial

Introduction

Here is the source code for net.sf.statcvs.output.xml.chart.AbstractBarChart.java

Source

/*
StatCvs - CVS statistics generation 
Copyright (C) 2002  Lukasz Pekacki <lukasz@pekacki.de>
http://statcvs.sf.net/
    
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
    
This library 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
Lesser General Public License for more details.
    
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    
   $RCSfile: AbstractBarChart.java,v $
   $Date: 2003/12/05 12:52:55 $ 
*/
package net.sf.statcvs.output.xml.chart;

import net.sf.statcvs.Settings;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.DefaultCategoryDataset;

/**
 * AbtractBarChart
 * 
 * @author Tammo van Lessen
 */
public abstract class AbstractBarChart extends AbstractChart {

    DefaultCategoryDataset dataset;

    /**
     * @param filename
     * @param title
     */
    public AbstractBarChart(String filename, String title) {
        super(filename, title);
        dataset = new DefaultCategoryDataset();
        createChart();
    }

    /**
     * 
     */
    private void createChart() {
        // create the chart...
        JFreeChart chart = ChartFactory.createBarChart3D(Settings.getProjectName(), // chart title
                "no desc", // domain axis label
                "no desc", // range axis label
                dataset, // data
                PlotOrientation.HORIZONTAL, true, // include legend
                true, // tooltips
                false // urls
        );
        setChart(chart);
        //placeTitle();      
    }

    public void setCategoryAxisLabel(String text) {
        CategoryPlot plot = getChart().getCategoryPlot();
        plot.getDomainAxis().setLabel(text);
    }

    public void setValueAxisLabel(String text) {
        CategoryPlot plot = getChart().getCategoryPlot();
        ValueAxis axis = plot.getRangeAxis();
        axis.setLabel(text);
    }

}