1 package org.codehaus.mojo.dashboard.report.plugin.chart;
2
3 /*
4 * Copyright 2006 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.Paint;
20 import java.util.Iterator;
21 import java.util.Map;
22 import java.util.ResourceBundle;
23
24 import org.codehaus.mojo.dashboard.report.plugin.beans.CheckstyleReportBean;
25 import org.codehaus.mojo.dashboard.report.plugin.utils.ChartUtils;
26 import org.jfree.chart.ChartColor;
27 import org.jfree.data.category.DefaultCategoryDataset;
28
29 /**
30 *
31 * @author <a href="dvicente72@gmail.com">David Vicente</a>
32 *
33 */
34 public class CheckstyleBarChartStrategy extends AbstractCategoryChartStrategy
35 {
36 /**
37 * Default constructor
38 *
39 * @param bundle
40 * @param title
41 * @param datas
42 */
43 public CheckstyleBarChartStrategy( ResourceBundle bundle, String title, Map datas )
44 {
45 super( bundle, title, datas );
46 }
47
48 public void fillDataset()
49 {
50 if ( datas != null && !datas.isEmpty() )
51 {
52 Iterator iter = datas.keySet().iterator();
53
54 while ( iter.hasNext() )
55 {
56 String key = (String) iter.next();
57 CheckstyleReportBean checkReportBean = (CheckstyleReportBean) datas.get( key );
58 int info = checkReportBean.getNbInfos();
59 int error = checkReportBean.getNbErrors();
60 int warn = checkReportBean.getNbWarnings();
61
62 ( (DefaultCategoryDataset) defaultdataset ).setValue(
63 info,
64 this.bundle.getString( "report.checkstyle.column.infos" ),
65 key );
66
67 ( (DefaultCategoryDataset) defaultdataset ).setValue(
68 error,
69 this.bundle.getString( "report.checkstyle.column.errors" ),
70 key );
71
72 ( (DefaultCategoryDataset) defaultdataset ).setValue(
73 warn,
74 this.bundle.getString( "report.checkstyle.column.warnings" ),
75 key );
76 }
77 }
78 }
79
80 public Paint[] getPaintColor()
81 {
82 return new Paint[] { ChartUtils.BLUE_LIGHT, ChartColor.RED, ChartUtils.YELLOW_LIGHT };
83 }
84
85 }