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.SurefireReportBean;
26  import org.jfree.chart.ChartColor;
27  import org.jfree.data.time.TimeSeries;
28  
29  public class SurefireTimeChartStrategy extends AbstractTimeChartStrategy
30  {
31  
32      public SurefireTimeChartStrategy( 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.surefire.label.tests" ), this.periodClass );
41          TimeSeries s2 = new TimeSeries( this.bundle.getString( "report.surefire.label.errors" ), this.periodClass );
42          TimeSeries s3 = new TimeSeries( this.bundle.getString( "report.surefire.label.failures" ), this.periodClass );
43          TimeSeries s4 = new TimeSeries( this.bundle.getString( "report.surefire.label.skipped" ), this.periodClass );
44          Iterator iter = mResults.iterator();
45          while ( iter.hasNext() )
46          {
47  
48              SurefireReportBean surefire = (SurefireReportBean) iter.next();
49              Date date = surefire.getDateGeneration();
50              s1.addOrUpdate( getChartDate( this.timePeriod.normalize( date ) ), surefire.getNbTests() );
51              s2.addOrUpdate( getChartDate( this.timePeriod.normalize( date ) ), surefire.getNbErrors() );
52              s3.addOrUpdate( getChartDate( this.timePeriod.normalize( date ) ), surefire.getNbFailures() );
53              s4.addOrUpdate( getChartDate( this.timePeriod.normalize( date ) ), surefire.getNbSkipped() );
54          }
55  
56          defaultdataset.addSeries( s1 );
57          defaultdataset.addSeries( s2 );
58          defaultdataset.addSeries( s3 );
59          defaultdataset.addSeries( s4 );
60  
61      }
62      /**
63       * 
64       */
65      public Paint[] getPaintColor()
66      {
67          return new Paint[] { ChartColor.GREEN, ChartColor.RED, ChartColor.ORANGE, ChartColor.YELLOW};
68      }
69  
70  }