View Javadoc

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.ResourceBundle;
21  
22  import org.codehaus.mojo.dashboard.report.plugin.beans.CheckstyleReportBean;
23  import org.codehaus.mojo.dashboard.report.plugin.beans.IDashBoardReportBean;
24  import org.codehaus.mojo.dashboard.report.plugin.utils.ChartUtils;
25  import org.jfree.chart.ChartColor;
26  
27  /**
28   *
29   * @author <a href="dvicente72@gmail.com">David Vicente</a>
30   *
31   */
32  public class CheckstylePieChartStrategy extends AbstractPieChartStrategy
33  {
34  
35      /**
36       * Default constructor
37       *
38       * @param bundle
39       * @param title
40       * @param dashboardReport
41       */
42      public CheckstylePieChartStrategy( ResourceBundle bundle, String title, IDashBoardReportBean dashboardReport )
43      {
44          super( bundle, title, dashboardReport );
45      }
46  
47      /**
48       *
49       */
50      public void fillDataset()
51      {
52          if ( mDashboardReport instanceof CheckstyleReportBean )
53          {
54              CheckstyleReportBean checkstyleReportBean = (CheckstyleReportBean) mDashboardReport;
55  
56              int info = checkstyleReportBean.getNbInfos();
57              int error = checkstyleReportBean.getNbErrors();
58              int warn = checkstyleReportBean.getNbWarnings();
59  
60              this.defaultdataset.setValue( this.bundle.getString( "report.checkstyle.column.infos" ) + " = " + info,
61                                            info );
62  
63              this.defaultdataset.setValue( this.bundle.getString( "report.checkstyle.column.errors" ) + " = " + error,
64                                            error );
65  
66              this.defaultdataset.setValue( this.bundle.getString( "report.checkstyle.column.warnings" ) + " = " + warn,
67                                            warn );
68          }
69      }
70  
71      /**
72       *
73       */
74      public Paint[] getPaintColor()
75      {
76          return new Paint[] { ChartUtils.BLUE_LIGHT, ChartColor.RED, ChartUtils.YELLOW_LIGHT };
77      }
78  }