View Javadoc

1   package org.codehaus.mojo.dashboard.report.plugin.chart;
2   
3   /*
4    * Copyright 2008 David Vicente
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import java.awt.image.BufferedImage;
20  import java.io.IOException;
21  import java.util.List;
22  
23  import org.jfree.chart.JFreeChart;
24  
25  public abstract class AbstractChartDecorator implements IChartRenderer{
26  
27  	protected IChartRenderer decoratedChart;
28  	protected List results;
29  	/**
30  	 * Wrapped chart.
31  	 */
32  	protected JFreeChart report = null;
33  
34  	public AbstractChartDecorator(IChartRenderer chartToDecorate, List markersToPlot) {
35  		super();
36  		this.decoratedChart = chartToDecorate;
37  		this.results = markersToPlot;
38  		//this.decoratedChart.createChart();
39  		this.report = this.decoratedChart.getChart();
40  		createChart();
41  	}
42  	public abstract void createChart();
43  
44  	public BufferedImage createBufferedImage(int imageWidth, int imageHeight) {
45  		return this.decoratedChart.createBufferedImage(imageWidth, imageHeight);
46  	}
47  
48  	public String getFileExtension() {
49  		return this.decoratedChart.getFileExtension();
50  	}
51  
52  	public String getMimeType() {
53  		return this.decoratedChart.getMimeType();
54  	}
55  
56  	public boolean isEmpty() {
57  		return this.decoratedChart.isEmpty();
58  	}
59  
60  	public void saveToFile(String filename) throws IOException {
61  		this.decoratedChart.saveToFile(filename);
62  	}
63  
64  	public void setHeight(int _height) {
65  		this.decoratedChart.setHeight(_height);
66  	}
67  
68  	public void setWidth(int _width) {
69  		this.decoratedChart.setWidth(_width);
70  	}
71  
72  	public JFreeChart getChart() {
73  		return this.report;
74  	}
75  
76  }