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: package org.pentaho.plugin.jfreereport.reportcharts;
14:
15: import org.jfree.chart.ChartFactory;
16: import org.jfree.chart.JFreeChart;
17: import org.jfree.chart.plot.PlotOrientation;
18: import org.jfree.chart.plot.XYPlot;
19: import org.jfree.chart.renderer.xy.XYBarRenderer;
20: import org.jfree.chart.renderer.xy.XYItemRenderer;
21: import org.jfree.data.time.TimeSeriesCollection;
22: import org.jfree.data.xy.IntervalXYDataset;
23: import org.jfree.data.xy.XYDataset;
24: import org.jfree.data.xy.XYSeriesCollection;
25:
26: /**
27: *
28: * @author gmoran
29: *
30: */
31: public class XYBarChartExpression extends XYChartExpression {
32: private static final long serialVersionUID = -1190325024526412335L;
33:
34: private boolean drawBarOutline;
35:
36: public XYBarChartExpression() {
37: super ();
38: }
39:
40: public boolean isDrawBarOutline() {
41: return isChartSectionOutline();
42: }
43:
44: public void setDrawBarOutline(boolean value) {
45: this .drawBarOutline = value;
46: setChartSectionOutline(value);
47: }
48:
49: public JFreeChart getChart(XYDataset xyDataset) {
50:
51: JFreeChart rtn = null;
52:
53: if (xyDataset instanceof XYSeriesCollection) {
54: rtn = ChartFactory.createXYBarChart(getTitle(),
55: getDomainTitle(), false, getRangeTitle(),
56: (IntervalXYDataset) xyDataset,
57: isHorizontal() ? PlotOrientation.HORIZONTAL
58: : PlotOrientation.VERTICAL, isShowLegend(),
59: false, false);
60: return rtn;
61: }
62:
63: if (xyDataset instanceof TimeSeriesCollection) {
64: rtn = ChartFactory.createTimeSeriesChart(getTitle(),
65: getDomainTitle(), getRangeTitle(), xyDataset,
66: isShowLegend(), false, false);
67:
68: rtn.getXYPlot().setRenderer(new XYBarRenderer());
69:
70: return rtn;
71: }
72:
73: return rtn;
74: }
75:
76: protected void setChartProperties(JFreeChart chart) {
77: super .setChartProperties(chart);
78: XYPlot xypl = chart.getXYPlot();
79: XYItemRenderer renderer = xypl.getRenderer();
80: XYBarRenderer br = (XYBarRenderer) renderer;
81: br.setDrawBarOutline(drawBarOutline);
82:
83: }
84:
85: }
|