View Javadoc

1   package org.codehaus.mojo.dashboard.report.plugin.chart.time;
2   
3   /*
4    * Copyright 2007 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.Date;
21  import java.util.Iterator;
22  import java.util.List;
23  import java.util.ResourceBundle;
24  
25  import org.codehaus.mojo.dashboard.report.plugin.beans.CheckstyleReportBean;
26  import org.codehaus.mojo.dashboard.report.plugin.utils.ChartUtils;
27  import org.jfree.chart.ChartColor;
28  import org.jfree.data.time.TimeSeries;
29  
30  public class CheckstyleTimeChartStrategy extends AbstractTimeChartStrategy
31  {
32      
33      public CheckstyleTimeChartStrategy(ResourceBundle bundle, String title,List results, String timeUnit, Date startDate, Date endDate)
34      {
35          super(bundle, title, results,timeUnit, startDate, endDate);
36      }
37      
38      public void fillDataset()
39      {
40          TimeSeries s1 = new TimeSeries(this.bundle.getString( "report.checkstyle.files" ), this.periodClass);
41          TimeSeries s2 = new TimeSeries(this.bundle.getString( "report.checkstyle.column.total" ),  this.periodClass);
42          TimeSeries s3 = new TimeSeries(this.bundle.getString( "report.checkstyle.column.infos" ),  this.periodClass);
43          TimeSeries s4 = new TimeSeries(this.bundle.getString( "report.checkstyle.column.warnings" ),  this.periodClass);
44          TimeSeries s5 = new TimeSeries(this.bundle.getString( "report.checkstyle.column.errors" ),  this.periodClass);
45          Iterator iter = mResults.iterator();
46          while(iter.hasNext()){
47              
48              CheckstyleReportBean check = (CheckstyleReportBean)iter.next();
49              Date date = check.getDateGeneration();
50              s1.addOrUpdate( getChartDate(this.timePeriod.normalize( date )), check.getNbClasses() );
51              s2.addOrUpdate( getChartDate(this.timePeriod.normalize( date )), check.getNbTotal());
52              s3.addOrUpdate( getChartDate(this.timePeriod.normalize( date )), check.getNbInfos());
53              s4.addOrUpdate( getChartDate(this.timePeriod.normalize( date )), check.getNbWarnings());
54              s5.addOrUpdate( getChartDate(this.timePeriod.normalize( date )), check.getNbErrors());
55          }
56          
57          defaultdataset.addSeries(s1);
58          defaultdataset.addSeries(s2);
59          defaultdataset.addSeries(s3);
60          defaultdataset.addSeries(s4);
61          defaultdataset.addSeries(s5);
62  
63      }
64      
65      public Paint[] getPaintColor()
66      {
67          return new Paint[] { ChartColor.GREEN, ChartColor.BLACK, ChartUtils.BLUE_LIGHT, ChartUtils.YELLOW_LIGHT, ChartColor.RED };
68      }
69  
70  }