001    package jp.osdl.jbento2.chart;
002    
003    import org.jfree.chart.ChartFactory;
004    import org.jfree.chart.JFreeChart;
005    import org.jfree.chart.axis.ValueAxis;
006    import org.jfree.chart.labels.StandardXYToolTipGenerator;
007    import org.jfree.chart.plot.PlotOrientation;
008    import org.jfree.chart.plot.XYPlot;
009    import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2;
010    import org.jfree.chart.urls.StandardXYURLGenerator;
011    import org.jfree.data.general.AbstractDataset;
012    import org.jfree.data.xy.TableXYDataset;
013    
014    public class StackedXYAreaChartType implements ChartType {
015        // TODO: strange graf...
016    
017        public JFreeChart getChart(String title, String xLabel, String yLabel,
018                long xMin, long xMax, long yMin, long yMax,
019                AbstractDataset dataset, PlotOrientation orientation,
020                boolean legend, boolean tooltips, boolean urls, boolean shape) {
021    
022            JFreeChart chart = ChartFactory.createStackedXYAreaChart(title, xLabel,
023                    yLabel, (TableXYDataset) dataset, orientation, legend,
024                    tooltips, urls);
025    
026            StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
027    
028            if (tooltips) {
029                renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
030            }
031            if (urls) {
032                renderer.setURLGenerator(new StandardXYURLGenerator());
033            }
034            renderer.setOutline(true);
035    
036            XYPlot plot = chart.getXYPlot();
037            plot.setRenderer(renderer);
038    
039            if (xMax > 0) {
040                ValueAxis xAxis = plot.getDomainAxis();
041                xAxis.setAutoRange(false);
042                xAxis.setRange(xMin, xMax);
043            }
044            
045            ValueAxis yAxis = plot.getRangeAxis();
046            yAxis.setLowerBound(yMin);
047            if (yMax > 0) {
048                yAxis.setRange(yMin, yMax);
049            }
050            return chart;
051        }
052    
053    }