Coverage Report - org.jtheque.films.stats.view.impl.panels.PanelStats
 
Classes in this File Line Coverage Branch Coverage Complexity
PanelStats
0 %
0/18
N/A
1
 
 1  
 package org.jtheque.films.stats.view.impl.panels;
 2  
 
 3  
 import org.jdesktop.swingx.JXHeader;
 4  
 import org.jfree.chart.ChartFactory;
 5  
 import org.jfree.chart.ChartPanel;
 6  
 import org.jfree.chart.JFreeChart;
 7  
 import org.jfree.data.general.PieDataset;
 8  
 import org.jfree.ui.RectangleAnchor;
 9  
 import org.jtheque.core.managers.Managers;
 10  
 import org.jtheque.core.managers.beans.IBeansManager;
 11  
 import org.jtheque.core.managers.language.ILanguageManager;
 12  
 import org.jtheque.core.managers.language.Internationalizable;
 13  
 import org.jtheque.core.managers.resource.IResourceManager;
 14  
 import org.jtheque.core.managers.resource.ImageType;
 15  
 import org.jtheque.films.stats.StatsModule;
 16  
 import org.jtheque.films.stats.services.able.IStatsService;
 17  
 
 18  
 import javax.swing.JPanel;
 19  
 import java.awt.Color;
 20  
 import java.awt.Component;
 21  
 
 22  
 /*
 23  
  * This file is part of JTheque.
 24  
  *            
 25  
  * JTheque is free software: you can redistribute it and/or modify
 26  
  * it under the terms of the GNU General Public License as published by
 27  
  * the Free Software Foundation, either version 3 of the License. 
 28  
  *
 29  
  * JTheque is distributed in the hope that it will be useful,
 30  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 31  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 32  
  * GNU General Public License for more details.
 33  
  *
 34  
  * You should have received a copy of the GNU General Public License
 35  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 36  
  */
 37  
 
 38  
 /**
 39  
  * An abstract panel to display stats.
 40  
  *
 41  
  * @author Baptiste Wicht
 42  
  */
 43  
 public abstract class PanelStats extends JPanel implements Internationalizable {
 44  0
     private final ILanguageManager resources = Managers.getManager(ILanguageManager.class);
 45  
 
 46  0
     private final JXHeader header = new JXHeader();
 47  
 
 48  
     /**
 49  
      * Construct a new PanelStats.
 50  
      */
 51  
     PanelStats() {
 52  0
         super();
 53  
 
 54  0
         Managers.getManager(ILanguageManager.class).addInternationalizable(this);
 55  0
     }
 56  
 
 57  
     /**
 58  
      * Return the language manager.
 59  
      *
 60  
      * @return The language manager.
 61  
      */
 62  
     final ILanguageManager getResources() {
 63  0
         return resources;
 64  
     }
 65  
 
 66  
     /**
 67  
      * Set the informations of the header.
 68  
      *
 69  
      * @param key         The i18n key.
 70  
      * @param description The description of the header.
 71  
      */
 72  
     final void setHeader(String key, String description) {
 73  0
         header.setTitle(resources.getMessage(key));
 74  0
         header.setDescription(description);
 75  0
         header.setIcon(Managers.getManager(IResourceManager.class).getIcon(
 76  
                 StatsModule.IMAGE_BASE_NAME, "stats-big", ImageType.JPG));
 77  0
     }
 78  
 
 79  
     /**
 80  
      * Return the header of the panel.
 81  
      *
 82  
      * @return The header of the panel.
 83  
      */
 84  
     public final JXHeader getHeader() {
 85  0
         return header;
 86  
     }
 87  
 
 88  
     /**
 89  
      * Create a panel containing a pie chart.
 90  
      *
 91  
      * @param key     The i18 key of the title of the pie chart.
 92  
      * @param dataset The dataset used to populate the pie chart.
 93  
      * @return The component containing the pie chart.
 94  
      */
 95  
     final Component createPieChartPanel(String key, PieDataset dataset) {
 96  0
         JFreeChart pie = ChartFactory.createPieChart3D(resources.getMessage(key), dataset, true, true, true);
 97  
 
 98  0
         pie.getLegend().setLegendItemGraphicLocation(RectangleAnchor.RIGHT);
 99  
 
 100  0
         Managers.getManager(ILanguageManager.class).addInternationalizable(new InternationalizableChart(pie, key));
 101  
 
 102  0
         Component chartPanel = new ChartPanel(pie);
 103  
 
 104  0
         chartPanel.setBackground(Color.white);
 105  
 
 106  0
         return chartPanel;
 107  
     }
 108  
 
 109  
     /**
 110  
      * Return the stats service.
 111  
      *
 112  
      * @return The stats service.
 113  
      */
 114  
     static IStatsService getStatsService() {
 115  0
         return Managers.getManager(IBeansManager.class).getBean("statsService");
 116  
 
 117  
     }
 118  
 }