1 package jp.osdl.jbento2.chart;
2
3 import org.jfree.chart.ChartFactory;
4 import org.jfree.chart.JFreeChart;
5 import org.jfree.chart.axis.ValueAxis;
6 import org.jfree.chart.labels.StandardXYToolTipGenerator;
7 import org.jfree.chart.plot.PlotOrientation;
8 import org.jfree.chart.plot.XYPlot;
9 import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2;
10 import org.jfree.chart.urls.StandardXYURLGenerator;
11 import org.jfree.data.general.AbstractDataset;
12 import org.jfree.data.xy.TableXYDataset;
13
14 public class StackedXYAreaChartType implements ChartType {
15
16
17 public JFreeChart getChart(String title, String xLabel, String yLabel,
18 long xMin, long xMax, long yMin, long yMax,
19 AbstractDataset dataset, PlotOrientation orientation,
20 boolean legend, boolean tooltips, boolean urls, boolean shape) {
21
22 JFreeChart chart = ChartFactory.createStackedXYAreaChart(title, xLabel,
23 yLabel, (TableXYDataset) dataset, orientation, legend,
24 tooltips, urls);
25
26 StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
27
28 if (tooltips) {
29 renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
30 }
31 if (urls) {
32 renderer.setURLGenerator(new StandardXYURLGenerator());
33 }
34 renderer.setOutline(true);
35
36 XYPlot plot = chart.getXYPlot();
37 plot.setRenderer(renderer);
38
39 if (xMax > 0) {
40 ValueAxis xAxis = plot.getDomainAxis();
41 xAxis.setAutoRange(false);
42 xAxis.setRange(xMin, xMax);
43 }
44
45 ValueAxis yAxis = plot.getRangeAxis();
46 yAxis.setLowerBound(yMin);
47 if (yMax > 0) {
48 yAxis.setRange(yMin, yMax);
49 }
50 return chart;
51 }
52
53 }