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.XYDataset; 013 014 public class StackedTimeSeriesChartType implements ChartType { 015 016 public JFreeChart getChart(String title, String xLabel, String yLabel, 017 long xMin, long xMax, long yMin, long yMax, 018 AbstractDataset dataset, PlotOrientation orientation, 019 boolean legend, boolean tooltips, boolean urls, boolean shape) { 020 021 // JFreeChart chart = ChartFactory.createStackedXYAreaChart(title, 022 // xLabel, 023 // yLabel, (TableXYDataset) dataset, orientation, legend, 024 // tooltips, urls); 025 JFreeChart chart = ChartFactory.createTimeSeriesChart(title, xLabel, 026 yLabel, (XYDataset) dataset, legend, tooltips, urls); 027 028 StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(); 029 030 if (tooltips) { 031 renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); 032 } 033 if (urls) { 034 renderer.setURLGenerator(new StandardXYURLGenerator()); 035 } 036 renderer.setOutline(true); 037 038 XYPlot plot = chart.getXYPlot(); 039 plot.setRenderer(renderer); 040 041 if (xMax > 0) { 042 ValueAxis xAxis = plot.getDomainAxis(); 043 xAxis.setAutoRange(false); 044 xAxis.setRange(xMin, xMax); 045 } 046 047 ValueAxis yAxis = plot.getRangeAxis(); 048 yAxis.setLowerBound(yMin); 049 if (yMax > 0) { 050 yAxis.setRange(yMin, yMax); 051 } 052 return chart; 053 } 054 }