01: /*
02: * Copyright 2006 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: *
13: * @author Gretchen Moran
14: */
15: package org.pentaho.plugin.jfreereport.reportcharts;
16:
17: import org.jfree.chart.ChartFactory;
18: import org.jfree.chart.JFreeChart;
19: import org.jfree.chart.plot.PlotOrientation;
20: import org.jfree.chart.renderer.xy.XYDifferenceRenderer;
21: import org.jfree.chart.renderer.xy.XYItemRenderer;
22: import org.jfree.chart.renderer.xy.XYStepAreaRenderer;
23: import org.jfree.chart.renderer.xy.XYStepRenderer;
24: import org.jfree.data.time.TimeSeriesCollection;
25: import org.jfree.data.xy.XYDataset;
26: import org.jfree.data.xy.XYSeriesCollection;
27:
28: public class ExtendedXYLineChartExpression extends
29: XYLineChartExpression {
30: private static final long serialVersionUID = -167639029520233427L;
31:
32: public ExtendedXYLineChartExpression() {
33: super ();
34: }
35:
36: String chartType = ChartConstants.LINE_CHART_STR;
37:
38: public JFreeChart getChart(XYDataset xyDataset) {
39: JFreeChart rtn = null;
40:
41: if (xyDataset instanceof XYSeriesCollection) {
42:
43: rtn = ChartFactory.createXYLineChart(getTitle(),
44: getDomainTitle(), getRangeTitle(), xyDataset,
45: isHorizontal() ? PlotOrientation.HORIZONTAL
46: : PlotOrientation.VERTICAL, isShowLegend(),
47: false, false);
48: } else if (xyDataset instanceof TimeSeriesCollection) {
49:
50: rtn = ChartFactory.createTimeSeriesChart(getTitle(),
51: getDomainTitle(), getRangeTitle(), xyDataset,
52: isShowLegend(), false, false);
53: }
54:
55: if (rtn == null) {
56: return rtn;
57: }
58:
59: int type = ChartConstants.getChartType(getChartType());
60:
61: XYItemRenderer renderer = null;
62: switch (type) {
63: case ChartConstants.STEP_CHART_TYPE:
64: renderer = new XYStepRenderer(null, null);
65: break;
66: case ChartConstants.STEP_AREA_CHART_TYPE:
67: int style = isMarkersVisible() ? XYStepAreaRenderer.AREA_AND_SHAPES
68: : XYStepAreaRenderer.AREA;
69: renderer = new XYStepAreaRenderer(style);
70: break;
71: case ChartConstants.DIFFERENCE_CHART_TYPE:
72: renderer = new XYDifferenceRenderer();
73: break;
74: default:
75: }
76:
77: if (renderer != null) {
78: rtn.getXYPlot().setRenderer(renderer);
79: }
80: return rtn;
81: }
82:
83: protected void setChartProperties(JFreeChart chart) {
84: super .setChartProperties(chart);
85: }
86:
87: public String getChartType() {
88: return chartType;
89: }
90:
91: public void setChartType(String chartType) {
92: this.chartType = chartType;
93: }
94:
95: }
|