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.FindBugsReportBean;
26  import org.jfree.chart.ChartColor;
27  import org.jfree.data.time.TimeSeries;
28  
29  public class FindBugsTimeChartStrategy extends AbstractTimeChartStrategy
30  {
31  
32      public FindBugsTimeChartStrategy( ResourceBundle bundle, String title, List results, String timeUnit,
33                                        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.findbugs.label.nbclasses" ), this.periodClass );
41          TimeSeries s2 = new TimeSeries( this.bundle.getString( "report.findbugs.label.nbbugs" ), this.periodClass );
42          TimeSeries s3 = new TimeSeries( this.bundle.getString( "report.findbugs.label.nberrors" ), this.periodClass );
43          TimeSeries s4 =
44              new TimeSeries( this.bundle.getString( "report.findbugs.label.nbMissingClasses" ), this.periodClass );
45          Iterator iter = mResults.iterator();
46          while ( iter.hasNext() )
47          {
48  
49              FindBugsReportBean findbugs = (FindBugsReportBean) iter.next();
50              Date date = findbugs.getDateGeneration();
51              s1.addOrUpdate( getChartDate( this.timePeriod.normalize( date ) ), findbugs.getNbClasses() );
52              s2.addOrUpdate( getChartDate( this.timePeriod.normalize( date ) ), findbugs.getNbBugs() );
53              s3.addOrUpdate( getChartDate( this.timePeriod.normalize( date ) ), findbugs.getNbErrors() );
54              s4.addOrUpdate( getChartDate( this.timePeriod.normalize( date ) ), findbugs.getNbMissingClasses() );
55          }
56  
57          defaultdataset.addSeries( s1 );
58          defaultdataset.addSeries( s2 );
59          defaultdataset.addSeries( s3 );
60          defaultdataset.addSeries( s4 );
61  
62      }
63  
64      public Paint[] getPaintColor()
65      {
66          return new Paint[] { ChartColor.BLACK, ChartColor.RED, ChartColor.ORANGE, ChartColor.BLUE };
67      }
68  
69  }