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.Font;
20  
21  import org.jfree.chart.ChartFactory;
22  import org.jfree.chart.plot.PiePlot3D;
23  import org.jfree.data.general.PieDataset;
24  import org.jfree.util.Rotation;
25  
26  /**
27   * Pie Chart 3D renderer.
28   * Refactoring by <a href="mailto:dvicente72@gmail.com">David Vicente</a>
29   * @author <a href="srivollet@objectif-informatique.fr">Sylvain Rivollet</a>
30   */
31  public class PieChart3DRenderer extends AbstractChartRenderer
32  {
33  
34      private static final double START_ANGLE = 45D;
35  
36      private static final float FOREGROUND_ALPHA = 0.5f;
37  
38      /**
39       *
40       */
41      private static final int FONT_SIZE = 10;
42  
43      /**
44       *
45       * @param dashboardReport
46       * @param strategy
47       */
48      public PieChart3DRenderer( IChartStrategy strategy )
49      {
50          super( strategy );
51      }
52  
53      /**
54       *
55       * @param dashboardReport
56       * @param strategy
57       * @param width
58       * @param height
59       */
60      public PieChart3DRenderer( IChartStrategy strategy, int width, int height )
61      {
62          super( strategy, width, height );
63      }
64  
65      public void createChart()
66      {
67          PieDataset dataset = (PieDataset) this.datasetStrategy.getDataset();
68          report = ChartFactory.createPieChart3D( this.datasetStrategy.getTitle(), dataset, false, true, true );
69  
70          PiePlot3D plot3D = (PiePlot3D) report.getPlot();
71          plot3D.setDirection( Rotation.ANTICLOCKWISE );
72          plot3D.setStartAngle( PieChart3DRenderer.START_ANGLE );
73          plot3D.setForegroundAlpha( PieChart3DRenderer.FOREGROUND_ALPHA );
74          plot3D.setLabelFont( new Font("Lucida", 0, PieChart3DRenderer.FONT_SIZE ) );
75  
76      }
77  }