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.PmdReportBean;
26  import org.jfree.chart.ChartColor;
27  import org.jfree.data.time.TimeSeries;
28  
29  public class PmdTimeChartStrategy extends AbstractTimeChartStrategy
30  {
31  
32      public PmdTimeChartStrategy( ResourceBundle bundle, String title, List results, String timeUnit, Date startDate,
33                                   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.pmd.label.nbclasses" ), this.periodClass );
41          TimeSeries s2 = new TimeSeries( this.bundle.getString( "report.pmd.label.nbviolations" ), this.periodClass );
42          Iterator iter = mResults.iterator();
43          while ( iter.hasNext() )
44          {
45  
46              PmdReportBean pmd = (PmdReportBean) iter.next();
47              Date date = pmd.getDateGeneration();
48              s1.addOrUpdate( getChartDate( this.timePeriod.normalize( date ) ), pmd.getNbClasses() );
49              s2.addOrUpdate( getChartDate( this.timePeriod.normalize( date ) ), pmd.getNbViolations() );
50          }
51  
52          defaultdataset.addSeries( s1 );
53          defaultdataset.addSeries( s2 );
54  
55      }
56      public Paint[] getPaintColor()
57      {
58          return new Paint[] { ChartColor.GREEN, ChartColor.RED };
59      }
60  }